%The GUI contains the predefined subprograms for creating & using a Graphical
%User Interface
import GUI
%Setcreen creates a window, enters graphic mode, changes the window to 1000
%x600 and turns of the cursor
setscreen ("graphics:1000;600,nocursor")
%This variable is an integers and allow the scope to be drawn anywhere
var x, y, button : int
var mspace1 : int
var spaceship : int
spaceship := Pic.FileNew ("shipf.bmp")
var spacex, spacey : int
var background : int
background := Pic.FileNew ("background.bmp")
spacex := 450
spacey := 300
% this loop is used to randomly generate direction of movement for the space ship
procedure draw (x, y : int)
View.Set ("offscreenonly")
loop
randint (mspace1, 1, 4)
if mspace1 = 1 then
spacey := (spacey + 50)
else
if mspace1 = 2 then
spacex := (spacex - 50)
else
if mspace1 = 3 then
spacey := (spacey - 50)
else
if mspace1 = 4 then
spacex := (spacex + 50)
end if
end if
end if
end if
Pic.Draw (spaceship, spacex, spacey, picUnderMerge)
delay (300)
View.Update
cls
Pic.Draw (background, 0, 0, picUnderMerge)
%Scope casting
Draw.FillOval (x, y, 55, 55, black)
Draw.FillOval (x, y, 50, 50, white)
%Thick crosshair threads
Draw.ThickLine (x - 50, y, x - 35, y, 3, black)
Draw.ThickLine (x + 50, y, x + 35, y, 3, black)
Draw.ThickLine (x, y - 50, x, y - 35, 3, black)
Draw.ThickLine (x, y + 50, x, y + 35, 3, black)
%Thin threads
Draw.Line (x - 20, y, x + 20, y, red)
Draw.Line (x, y - 20, x, y + 20, red)
end loop % this ends the loop of movement
end draw
loop
Mouse.Where (x, y, button)
draw (x, y)
end loop
|