Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 creating random falling asteroids..
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Aniota




PostPosted: 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 =)
Sponsor
Sponsor
Sponsor
sponsor
shadowman544




PostPosted: 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
Aniota




PostPosted: 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 =)
Aniota




PostPosted: 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
andrew.




PostPosted: 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.
Aniota




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: