program line;
private
drawn; i;
fpg; int all;
struct balls[12];
posx;
posy;
color;
movex;
movey;
s;
end;
begin
set_mode(320,240,16);
fpg=LOAD_FPG("test.fpg");
put(fpg,1,0,0);
x=30; y=30; all=0;
from i=1 to 12 step 1:
balls[i].posx=RAND(20,300);
balls[i].posy=RAND(20,220);
balls[i].color=RAND(24,26);
balls[i].s=20;
balls[i].movex=RAND(-4,4);
balls[i].movey=RAND(-4,4);
end
SET_TEXT_COLOR(rgb(255,0,255));
loop
if(key(_up))y=y-3;end;
if(key(_down))y=y+3;end;
if(key(_left))x=x-3;end;
if(key(_right))x=x+3;end;
delete_draw(drawn);
from i=1 to 12 step 1:
drawing_color(balls[i].color);
DRAW_CIRCLE(balls[i].posx,balls[i].posy,balls[i].s);
if (balls[i].posx-20<0 ) balls[i].movex=-balls[i].movex; end
if (balls[i].posx+20>320) balls[i].movex=-balls[i].movex; end
if (balls[i].posy-20<0) balls[i].movey=-balls[i].movey; end
if (balls[i].posy+20>240) balls[i].movey=-balls[i].movey; end
if (balls[i].color==70) balls[i].posx=400; end
if (balls[i].color==71) balls[i].s=5; balls[i].color=70; end
if (balls[i].color==72) balls[i].s=10; balls[i].color=71; end
if (balls[i].color==73) balls[i].s=15; balls[i].color=72; end
if (balls[i].color<70)
if (balls[i].posx<=x+30 and balls[i].posx>=x-30
and balls[i].posy<=y+30 and balls[i].posy>=y-30) all=all+1; balls[i].movey=0;balls[i].movex=0;balls[i].color=73; end
end
balls[i].posx=balls[i].posx+balls[i].movex;
balls[i].posy=balls[i].posy+balls[i].movey;
end
DRAWING_COLOR(rgb(255,0,255));
DRAW_CIRCLE(x,y,20);
put(fpg,3,160,120);
DELETE_TEXT(0);
WRITE(0,262,2,0,"FPS: "+FPS);
write(0,2,2,0,"Dead balls: "+all);
write(0,234,230,0,"Version 0.0.1");
if (all==12) write(0,125,170,0,"!!!YOU ROCK!!!"); end
frame;
if(key(_esc)) exit("",0); end
end;
end;