Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How could I randomly place objects

Author
Message
sskethan
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 29th Dec 2012 20:19
Hello all,
How could i randomly place trees throughout a map that is say 1024 x 1024?

Thank you for everyones help so far. Here's a link to the progress so far.
http://www.youtube.com/watch?v=A1meEY0LgwM&feature=youtu.be
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 29th Dec 2012 20:50
Put the SpritePosition code inside the for loop, otherwise the forloop will run thru, setting t to 300, then 301 and so on. When it reaches 400, it will exit the loop and run the code following it. So by the time it reaches the setSpritePosition, "t" will be 400 and it will run the code once. I hope that helps you!
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 29th Dec 2012 20:52
As Zoq2 mentions, the positioning must be done in the loop itself. Also, "random ( 1024, 1024 )" will only return the number 1024. You should instead use "random ( 0, 1024 )" to get a number between 0 and 1024.
sskethan
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 30th Dec 2012 03:02
Thank you both. that's just what i needed.

Login to post a reply

Server time is: 2024-11-24 06:51:42
Your offset time is: 2024-11-24 06:51:42