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 (xl = xle) and (xr = xre) and (yb = ybe) and (yt = yte) then
planelife := planelife - 1 % subtracts 1 life if the enemy touches you
end if
%/%%%%%%%%%%%%%%%%%%%%
% Draw Life Bars %
%%%%%%%%%%%%%%%%%%%%\% for different amount of life you have
loop
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 loop
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
end loop
end fly
|