
-----------------------------------
vagyb
Mon May 24, 2004 12:52 pm

help wit random placement of astroids
-----------------------------------
here is my code and when i try to put the x and y values of the astroids to random they get messed up and keep repeating in same place, could someone take a look at my code and tell me how i can put the astroids in a different location every time they come?

-----------------------------------
SuperGenius
Mon May 24, 2004 1:14 pm


-----------------------------------
your problem is that you have defined your variables as random numbers and the start of your program, and then not called randint again to change them. To fix this you need to call randint for your variables inside your main loop so they will have different values each time the loop executes

-----------------------------------
vagyb
Mon May 24, 2004 1:20 pm


-----------------------------------
i think i understand wat u mean but once i do that the rocks start flashing on the screen :S, if any1 is kind enough could u try to fix it or do w/e SuperGenius is tryin to say and post the code here again? or explain to me in other simplier way?

-----------------------------------
guruguru
Mon May 24, 2004 1:39 pm


-----------------------------------
Ok. You have variable boulder1Y. Then you make a random number and assign it to variable number4. Lets say that the random number outputed 150. number4 is equal to 150.  Then you makeboulder1Y equal to number4- so now boudler1Y is equal to 150.

Then you begin your loop. The first time through the loop, the boulder is drawn at boulder1Y- which is 150. The second time it is draw and boulder1Y, which again is 150 because you have never changed the value of it.

To solve your problem, you have assign a random number to boulder1Y every time it reaches the end of the screen. What you could do is change this code:

    
if boulder1X + boulderWidth 