program fire;
global
shooting=0;
shipx=100;
rockcnt=0;
score=0;
lives=3;
begin
load_fpg ("new.fpg");
put_screen(0,2);
while (!key(_tab) and lives >0 ):
ship();
if (key(_control) and !shooting)
fireshot(shipx);
end;
if (rockcnt <10 and rand(0,10) >3 )
rockcnt+=1;
rocks();
end;
doscore();
frame;
end;
if (lives <1)
signal(type ship,s_kill);
signal(type rocks,s_kill);
signal(type fireshot,s_kill);
delete_text(0);
while !(key(_tab)):
graph = 203;
x = 150;
y= 80;
write (0,120,120,0,"Score = "+score);
frame;
end;
end;
end;
process doscore();
begin
delete_text(0);
write (0,0,0,0,"Score = "+score);
write (0,250,0,0," Lives = "+lives);
end;
process ship();
private
shipcoll=0;
begin
graph=150;
y = 180;
if (key(_left) and shipx >0)
shipx -= 10;
end;
if (key(_right) and shipx <320)
shipx += 10;
end;
x = shipx;
size =50;
shipcoll = collision(type rocks);
if (shipcoll)
signal(shipcoll,s_kill);
lives -= 1;
rockcnt -= 1;
end;
frame;
end;
process fireshot(newx);
private
firecoll;
begin
shooting=1;
graph = 250;
size =75;
for (y = 160;Y>0;y=y-10);
firecoll=collision(type rocks);
if (firecoll)
signal(firecoll,s_kill);
shooting=0;
signal(type fireshot,s_kill);
score += 1;
rockcnt -= 1;
end;
x = newx;
frame;
end;
shooting=0;
end;
process rocks();
begin
graph = 200 + rand(0,2);
size = 80 + (rand(0,2)*25);
x = rand(0,320);
for (y =-10;y <220;y=y+5)
frame;
end;
rockcnt = rockcnt-1;
end;