creating random falling asteroids..
Author |
Message |
Aniota
|
Posted: Wed May 28, 2008 6:32 pm Post subject: creating random falling asteroids.. |
|
|
I want to create falling asteroids(circles), that appear randomly, looped. I have looked up how to create a random integer but i can't seem to be able to make it a variable and then use that variable when i draw a circle. I am not sure if i am thinking in the wrong direction.
Does anyone know how i would do this?
thanks =) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
shadowman544
![](http://compsci.ca/v3/uploads/user_avatars/1469754643483deb7b5d9d7.jpg)
|
Posted: Wed May 28, 2008 7:30 pm Post subject: Re: creating random falling asteroids.. |
|
|
create a random int between maxx and minx and assign it to the x coordinate create another random loop that with a ranmdom generator for a numbert between say 1 and 100 and if an int of i is greater than say 95 then randomly generate an asteroid at the random, x value given. if this helps then good if not tell me an i will type it out in more detail |
|
|
|
|
![](images/spacer.gif) |
Aniota
|
Posted: Thu May 29, 2008 11:17 am Post subject: Re: creating random falling asteroids.. |
|
|
I tried that and it helped, (or maybe i didnt understand what u meant) but then i had some more problems. They started to just spam the screen I figured i needed to put them in arrays.
This is what i have started to do, but to test it and the brackets keep giving errors. Ack im such a noob >_<
View.Set ("graphics:800;600,offscreenonly")
var xx, y : int
var a : array 1 .. 800 of int
loop
xx:= Rand.Int (1, 800)
y:= Rand.Int (1, 600)
if y > 500 then
for i : 1 .. upper(a)
if y(i) <=775 then
y(i) += 5
drawoval (xx , y , 8, 8, red)
end if
end for
end loop
Thanks for the help shadowman544 =) |
|
|
|
|
![](images/spacer.gif) |
Aniota
|
Posted: Sun Jun 01, 2008 2:08 pm Post subject: Re: creating random falling asteroids.. |
|
|
argh figured out why i was having problems, i had to post cls at the beginning... still dont know what that is but hey my program works now |
|
|
|
|
![](images/spacer.gif) |
andrew.
|
Posted: Sun Jun 01, 2008 8:08 pm Post subject: RE:creating random falling asteroids.. |
|
|
cls means Clear Screen. That means that everytime you loop around, you clear the screen and redraw everything. |
|
|
|
|
![](images/spacer.gif) |
Aniota
|
Posted: Sun Jun 01, 2008 10:00 pm Post subject: Re: creating random falling asteroids.. |
|
|
Thanks andrew! that really helped, i had no idea what that meant. |
|
|
|
|
![](images/spacer.gif) |
|
|