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.

DarkBASIC Discussion / Randomizing Sprites

Author
Message
I NEED HELP FAST !!!
17
Years of Service
User Offline
Joined: 9th Aug 2007
Location:
Posted: 6th Oct 2007 03:13
ok i have no where to begin >_< i have 10 sprites that are in a section of my game and i have it setup to go to this sprite when this key is pressed how do i make it so when i press this key it can go to any other 9 ? plus still have the key setup to follow with the sprite >_< thank you
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th Oct 2007 04:27
you're not being very clear?
I was bored so I made a program that does what I think you're saying

The switching is not so good but does this help?

In programming, nothing exists
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Oct 2007 10:45
If your 9 sprites are numbered say 4-12, then the following would work:


sprite = rnd(8)+4

rnd will return a number between 0 and 8. We add 4 because our first sprite number starts at 4.

If your sprites are not in a linear order, you'll need to store their image numbers in an array.


Login to post a reply

Server time is: 2025-05-31 21:25:30
Your offset time is: 2025-05-31 21:25:30