
-----------------------------------
MysticVegeta
Mon Jun 20, 2005 7:54 am

Multiple asteroids.
-----------------------------------
Hi, I am making a game and its a spaceship game, so i took the code posted before and here it is. The only problem is that how do i make it so there are more rocks at the same time. I tried to make the rocks variable to 20 but they al come at once and then they start flickering, here is the code.
var winId := Window.Open ("graphics:max,max; nobuttonbar; offscreenonly")
var rocks : int := 2

colorback (255)

%%%%%%%%%%%%%%%%%%%%%%% O T H E R           S H I P S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var rock : array 1 .. 100 of
    record
        x, y, size, spd, dx : int
    end record
for i : 1 .. upper (rock) %The amount in array (which is 100)
    rock (i).x := Rand.Int (maxx, maxx + 400)
    rock (i).y := Rand.Int (0, maxy)
    rock (i).size := Rand.Int (10, 20)
    rock (i).spd := Rand.Int (10, 20)
end for

proc asteroids
    % Make move
    for i : 1 .. rocks div 2
        rock (i).x -= rock (i).spd
        drawfilloval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, yellow)
        if rock (i).x 