/***************************************************************
* Images *
***************************************************************/
var xx : array 1 .. 4 of int := init (0, 0, 0, 0) % plain array
var intro : array 1 .. 7 of int
intro (1) := Pic.FileNew ("ar.bmp")
intro (2) := Pic.FileNew ("ar2.bmp")
intro (3) := Pic.FileNew ("ar3.bmp")
intro (4) := Pic.FileNew ("ar4.bmp")
intro (5) := Pic.FileNew ("ar5.bmp")
intro (6) := Pic.FileNew ("ar6.bmp")
intro (7) := Pic.FileNew ("ar7.bmp")
var buttons : array 1 .. 3 of int
buttons (1) := Pic.FileNew ("button.bmp")
buttons (2) := Pic.FileNew ("button2.bmp")
buttons (3) := Pic.FileNew ("button3.bmp")
var sprite : array 1 .. 4 of int % your ship
sprite (1) := Pic.FileNew ("redplane1.bmp")
sprite (2) := Pic.FileNew ("redplane2.bmp")
sprite (3) := Pic.FileNew ("redplane3.bmp")
sprite (4) := Pic.FileNew ("redplane4.bmp")
var sprite1 : array 1 .. 6 of int % life bar
sprite1 (1) := Pic.FileNew ("life1.bmp")
sprite1 (2) := Pic.FileNew ("life2.bmp")
sprite1 (3) := Pic.FileNew ("life3.bmp")
sprite1 (4) := Pic.FileNew ("life4.bmp")
sprite1 (5) := Pic.FileNew ("life5.bmp")
sprite1 (6) := Pic.FileNew ("life6.bmp")
var sprite3 : array 1 .. 4 of int % enemy planes
sprite3 (1) := Pic.FileNew ("enemy1.bmp")
sprite3 (2) := Pic.FileNew ("enemy2.bmp")
sprite3 (3) := Pic.FileNew ("enemy3.bmp")
sprite3 (4) := Pic.FileNew ("enemy4.bmp")
var background : int := Pic.FileNew ("back.bmp") % background
/***************************************************************
* Movement *
***************************************************************/
var chars : array char of boolean
var bxr, byt : int := 0 % right x,left x
var yt, yb : int := 0 % plane up y,bottom y,
var xr, xl : int := 0 % plane right x,left x
var re, le, te, be : int := 0
/***************************************************************
* Other *
***************************************************************/
var font : int := Font.New ("Times New Roman:10") % font for menu section
var planelife : int := 5 % plane life
var num : int := 4 % number of enemy to be randomized
var plane_count : int := 0 % plains destroyed
/***************************************************************
* Ending *
***************************************************************/
procedure introduction
Pic.Draw (intro (5), 180, 50, picMerge)
end introduction
procedure endin
cls
Pic.Draw (intro (6), 120, 50, picMerge)
Pic.Draw (sprite (4), 270, 50, picMerge)
delay (2000)
cls
Pic.Draw (intro (7), 270, 50, picMerge)
end endin
/***************************************************************
* Game Code *
***************************************************************/
process enemy
var exr, eyt, xre, xle, yte, ybe : int := 0 % local variable for enemy
%/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Randomize Enemy's and Location %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\%
randint (eyt, 0, maxx)
for decreasing x : maxy .. 1
exr += +xre + xle % x postion of enemy
eyt += +yte + ybe % y postion of enemy
randomize
randint (num, 1, 4) % randomizes 4 enemys to be displayed on the screen
Pic.Draw (sprite3 (num), eyt, exr + x, picMerge) % draws the random enemy on the screen
end for
%/%%%%%%%%%%%%%%%%%%
% Score Counter %
%%%%%%%%%%%%%%%%%%\%
if (xre = 0 and xle = 0) then
plane_count := plane_count + 50 % for every plane to reach 0 adds 50 points to final score
end if
%/%%%%%%%%%%%%%%%%%%
% Life Counter %
%%%%%%%%%%%%%%%%%%\%
% bxr += +xl + xr
% byt += +yb + yt
% exr += +xre + xle
% eyt += +yte + ybe
if (xre = bxr) and (xle = bxr) and (yte = byt) and (ybe = byt) then
planelife := planelife - 1 % subtracts 1 life if the enemy touches you
end if
%/%%%%%%%%%%%%%%%%%%%%
% Draw Life Bars %
%%%%%%%%%%%%%%%%%%%%\% for different amount of life you have
for x : 1 .. 6
if planelife = 5 then
Pic.Draw (sprite1 (1), 0, 160, picMerge)
elsif planelife = 4 then
Pic.Draw (sprite1 (2), 0, 160, picMerge)
elsif planelife = 3 then
Pic.Draw (sprite1 (3), 0, 160, picMerge)
elsif planelife = 2 then
Pic.Draw (sprite1 (4), 0, 160, picMerge)
elsif planelife = 1 then
Pic.Draw (sprite1 (5), 0, 160, picMerge)
else
endin
end if
end for
end enemy
procedure fly
View.Set ("offscreenonly,nobuttonbar")
setscreen ("graphics:maxx;maxy,noecho,nocursor")
%/%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input Keys For Plane %
%%%%%%%%%%%%%%%%%%%%%%%%%%\%
loop
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
for x : 1 .. 1
xx (x) := x
yt := 8
end for
elsif chars (KEY_RIGHT_ARROW) then
for x : 1 .. 1
xx (x) := 2
xr := 8
end for
elsif chars (KEY_DOWN_ARROW) then
for x : 1 .. 1
xx (x) := x
yb := yb - 8
end for
elsif chars (KEY_LEFT_ARROW) then
for x : 1 .. 1
xx (x) := x + 2
xl := xl - 8
end for
end if
%/%%%%%%%%%%%%%%%%%%%
% Move Airplane %
%%%%%%%%%%%%%%%%%%%\%
if xx (1) > 0 then
for x : 1 .. 1
bxr += +xl + xr % x position of plane
byt += +yb + yt % y position of plane
Pic.Draw (background, 0, 0, picCopy)
Pic.Draw (sprite1 (1), 0, 160, picMerge)
Pic.Draw (sprite (xx (x)), bxr, byt, picMerge)
Draw.Text ("S C O R E :", 5, 370, font, black) % draws score bar
Font.Draw (intstr (plane_count), 70, 370, font, black) % converts score to string so it can aplly font
end for
View.Update
end if
%/%%%%%%%%%%%%%%%%%
% Boundries %
%%%%%%%%%%%%%%%%%\%
for x : 1 .. 1
if byt >= maxy then
byt := maxy - 15
Pic.Draw (sprite (x), xr, xl, picMerge)
elsif byt = -40 then
byt := 40
Pic.Draw (sprite (x), xr, xl, picMerge)
elsif bxr >= maxx then
bxr := maxx - 80
Pic.Draw (sprite (x), yb, yt, picMerge)
elsif bxr = -40 then
bxr := 40
Pic.Draw (sprite (x), yb, yt, picMerge)
end if
end for
%/%%%%%%%%%%%%%%%%%
% Clear Modes %
%%%%%%%%%%%%%%%%%\%
xl := 0
xr := 0
yt := 0
yb := 0
fork enemy % puts enemy on the screen with life bars etc..
end loop
end fly
/***************************************************************
* Introduction *
***************************************************************/
procedure intr
var mx, my, mb, buttonupdown : int := 0
setscreen ("noecho,nocursor,nobuttonbar")
colorback (black)
cls
Pic.Draw (intro (1), 120, 50, picMerge)
Pic.Draw (intro (2), 250, -120, picMerge)
delay (2000)
cls
Pic.Draw (intro (3), 180, 50, picMerge)
delay (2000)
cls
Pic.Draw (intro (3), 180, 180, picMerge)
Pic.Draw (buttons (1), 250, 200, picMerge)
Pic.Draw (buttons (2), 250, 150, picMerge)
Pic.Draw (buttons (3), 250, 100, picMerge)
View.Update
Mouse.Where (mx, my, mb)
buttonwait ("down", mx, my, mb, buttonupdown)
if (mx >= 250 and mx <= 400) and (my <= 235 and my >= 200) and (mb = 1) then
fly
elsif (mx >= 250 and mx <= 400) and (my <= 150 and my >= 185) and (mb = 1) then
Pic.Draw (intro (4), 180, 50, picMerge)
elsif (mx >= 250 and mx <= 400) and (my <= 100 and my >= 135) and (mb = 1) then
Pic.Draw (intro (5), 180, 50, picMerge)
end if
end intr
/***************************************************************
* Game Run Code *
***************************************************************/
fly
|