// main global script file
DynamicSprite *screen_sprite;
int startx = 0;
int starty = 0;
function draw_line_on_screen(int from_x, int from_y, int to_x, int to_y, int r, int g, int b)
{
DrawingSurface *surface = screen_sprite.GetDrawingSurface();
surface.Clear();
surface.DrawingColor = Game.GetColorFromRGB(r, g, b);
surface.DrawLine(from_x, from_y, to_x, to_y);
surface.Release();
gScreenGUI.BackgroundGraphic = screen_sprite.Graphic;
}
function clear_screen()
{
DrawingSurface *surface = screen_sprite.GetDrawingSurface();
surface.Clear();
surface.Release();
gScreenGUI.BackgroundGraphic = screen_sprite.Graphic;
}
// called when the game starts, before the first room is loaded
function game_start()
{
screen_sprite = DynamicSprite.Create(System.ViewportWidth, System.ViewportHeight);
}
// put anything you want to happen every game cycle in here
function repeatedly_execute()
{
if( gPieMain01.Visible == true )
draw_line_on_screen(startx, starty, mouse.x, mouse.y, 192, 0, 0);
else
clear_screen();
}
// put here anything you want to happen every game cycle, even when the game is blocked
function repeatedly_execute_always()
{
}
// called when a key is pressed. keycode holds the key's ASCII code
function on_key_press(eKeyCode keycode)
{
if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses
if (keycode == eKeyCtrlQ) QuitGame(1); // Ctrl-Q
if (keycode == eKeyF9) RestartGame(); // F9
if (keycode == eKeyF12) SaveScreenShot("scrnshot.pcx"); // F12
if (keycode == eKeyCtrlS) Debug(0,0); // Ctrl-S, give all inventory
if (keycode == eKeyCtrlV) Debug(1,0); // Ctrl-V, version
if (keycode == eKeyCtrlA) Debug(2,0); // Ctrl-A, show walkable areas
if (keycode == eKeyCtrlX) Debug(3,0); // Ctrl-X, teleport to room
}
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
{
}
else if (button == eMouseLeft)
{
if( gPieMain01.Visible == false )
{
gPieMain01.SetPosition( mouse.x - (gPieMain01.Width / 2), mouse.y - (gPieMain01.Height / 2) );
//if( gPieMain01.Y < 60 ) gPieMain01.Y = 60;
//if( (gPieMain01.Y + gPieMain01.Height) > 420 ) gPieMain01.Y = 420 - gPieMain01.Height;
gPieMain01.Visible = true;
startx = mouse.x;
starty = mouse.y;
}
else
{
if( mouse.x > (gPieMain01.X + 54) && mouse.x < ( (gPieMain01.X + gPieMain01.Width) - 54) )
{
if( mouse.y > (gPieMain01.Y + 54) && mouse.y < ( (gPieMain01.Y + gPieMain01.Height) - 54) )
{
gPieMain01.Visible = false;
}
}
}
}
else if (button == eMouseRight) // right-click, so cycle cursor
{
//mouse.SelectNextMode();
ProcessClick(mouse.x,mouse.y, mouse.Mode);
}
}
function dialog_request(int param) {
}