%background current
colourback (black)
View.Set ("offscreenonly")
%--------------------------------------------------------------------------
var picID, picID2, picIDflip, picIDboss : int
var x : int := 0 %moves the character,sets the screen limits
var y : int := 0 %%moves the character,sets the screen limits
var chars : array char of boolean %character movement
var pts : int := 1 %point system
var key : string (1) %moves the intro to the main game
var i : int %allows the intro to run in random colours
var h, g : int := 1
var ID : array 1 .. 10 of string %sets the ammount of names to ten
var score : array 1 .. 10 of int %sets the ammount of names to ten
var s := 0
var num : int %checks first value
var d : int
%--------------------------------------------------------------------------
proc intro
randint (i, 1, 255) % random number from 1 to 255
drawfillbox (0, 0, maxx, maxy, i) % draws a box in a random colour
Text.Color (white)
locate (15, 30)
put "Space evasion!" ..
end intro
% proc highscore
%
% open : d, "high_score.txt", get % accesses the data file
% assert d > 0 %checks if the file is made
% %-----------------------------------------------------------
% %checks data file
% get : d, num
%
% if num = 0 then
% put "the file is currently empty, please continue the game."
% else
%
% put "file not empty reading the data."
% delay (500)
% open : d, "high_score.txt", get
% assert d > 0
% loop %repeats till data is read
% s := s + 1 %adds up the number of players
% get : d, score (s) %retrived score
% put score (s) %display
% get : d, ID (s) %retrives names
% put ID (s) %display
%
% exit when eof (d)
% end loop
% end if
%
% close : d
% delay (3000)
% cls
%
% loop
% s := s + 1 %give the data a number
% put "Please enter your name."
% put "When finished press q to exit."
% get ID (s) %gets the players name
% exit when ID (s) = "q"
% put "Please enter your score."
% get score (s) %gets the players score
% cls
% end loop
% s := s - 1
% %saves data when person quits
%
% open : d, "high_score.txt", put % accesses the data file
% assert d > 0
% for n : 1 .. s %prepeats for the ammount of people
% %places the data into the txt file
% put : d, score (s) %places the data into the txt file
% put : d, ID (s)
% end for
%
% close : d
% cls
% end highscore
%-------------------------------------------------------------------------
proc gamepiece
drawline (0, 10, 20, 50, red) %... main body
drawline (40, 10, 20, 50, red) %... main body
drawline (0, 10, 20, 20, red) %... main body
drawline (40, 10, 20, 20, red) %... main body
for i : 1 .. 15
drawline (0, 10, 20, 20 + i, blue) %... engine
drawline (40, 10, 20, 20 + i, blue) %... engine
drawline (13, 35, 27, 35, green) %... engine
drawline (20, 20 + i, 13, 35, green) %...weapon type
drawline (27, 34, 20, 20 + i, green) %...weapon type
View.Update
end for
end gamepiece
%--------------------------------------------------------------------------
proc boss
drawfillbox (5, 5, 10, 50, yellow) %...cannon
drawfillbox (30, 5, 35, 50, yellow) %...cannon
drawline (0, 10, 20, 50, purple) %... main body
drawline (40, 10, 20, 50, purple) %... main body
drawline (0, 10, 20, 20, purple) %... main body
drawline (40, 10, 20, 20, purple) %... main body
for i : 1 .. 15
drawline (0, 10, 20, 20 + i, blue) %... engine
drawline (40, 10, 20, 20 + i, blue) %... engine
drawline (13, 35, 27, 35, green) %... engine
drawline (20, 20 + i, 13, 35, green) %...weapon type
drawline (27, 34, 20, 20 + i, green) %...weapon type
View.Update
end for
end boss
%--------------------------------------------------------------------------
proc atk
Draw.FillOval (350 - h, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (260 + h, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (350, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (260, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (350, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (260, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (350 + h, 360 - h, 15, 20, white) %.. boss attack
Draw.FillOval (260 - h, 360 - h, 15, 20, white) %.. boss attack
h += 1
g += 1
if h = 400 then
h := 2
end if
if g = 20 then
g := 2
end if
Pic.Draw (picID, x, y, picMerge)
View.Update
cls
end atk
proc atk2
Draw.FillOval (350 - h + 50, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (260 + h + 50, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (350, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (260, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (350, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (260, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (350 + h + 50, 360 - h + 50, 15, 20, white) %.. boss attack
Draw.FillOval (260 - h + 50, 360 - h + 50, 15, 20, white) %.. boss attack
h += 1
g += 1
if h = 400 then
h := 2
end if
if g = 20 then
g := 2
end if
Pic.Draw (picID, x, y, picMerge)
View.Update
cls
end atk2
%--------------------------------------------------------------------------
%highscore
intro % intro screen
getch (key) % move onto the main game
cls
gamepiece % draws the character
picID := Pic.New (0, 8, 42, 50) % allows the character to move
boss
picID2 := Pic.New (0, 8, 42, 221) % draws unaltered version of boss
cls
picIDflip := Pic.Flip (picID2) % flips the boss pic
Pic.Draw (picIDflip, 20, 20, picMerge)
cls
picID2 := Pic.Scale (picIDflip, 3 * 50, 3 * 150)
Pic.Draw (picID2, (1 - 1) * maxx div 3 + 300, (1 - 1) * maxy div 3 + 120, picMerge) % rescales the size of the image
%-----------------------------main game------------------------------------
loop
%... background procedure for the program
Pic.Draw (picID2, 235, 10, picMerge)
locate (1, 1) % places in top left corner
Text.Color (white) % point text is in white
put "points! ", pts .. % points are time based
pts := pts + 2
%--------------------------------------------------------------------------
Input.KeyDown (chars)
locate (1, 1)
if chars (KEY_UP_ARROW) then % move character up
y := y + 5
else
end if
if chars (KEY_RIGHT_ARROW) then % move character right
x := x + 5
else
end if
if chars (KEY_LEFT_ARROW) then % move character left
x := x - 5
else
end if
if chars (KEY_DOWN_ARROW) then % move character dowm
y := y - 5
else
end if
%--------------------------------------------------------------------------
%prevents offscreen
if x < 0 then
x := x + 5
end if
if x > 595 then
x := x - 5
end if
if y < 0 then
y := y + 5
end if
if y > 300 then
y := y - 5
end if
atk
atk2
%--------------------------------------------------------------------------
end loop
|