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.

Newcomers DBPro Corner / One Thousand Sprites Split Up

Author
Message
MightyMagi82
14
Years of Service
User Offline
Joined: 9th Apr 2010
Location: Kansas
Posted: 9th Apr 2010 17:08
I'm trying to get a program running where 1000 sprites are running around the screen, and used the clone sprites command for sprites 1 through 999. Unfortunately, it seems they all follow the same path, when I want them to split up and move about randomly. How can I get them to split up? I'm posting a copy of my source code, hopefully I can get an answer, which I appreciate greatly.

Attachments

Login to view attachments
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 9th Apr 2010 19:59
You should use an array to store all the different positions of each spiders.

Put your FOR*NEXT loop inside the DO*LOOP. And "SpiderNum = 1 + SpiderNum" is not needed because the FOR*NEXT loop already inc SpiderNum every iteration.

Move the sync along with the LOOP statement, you sync right before you loop.

Hear are the changes to the code.
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 9th Apr 2010 20:38 Edited at: 9th Apr 2010 20:41
duh... i`m stupid, sorry

Where there is a will, there is a way.
I often edit my posts, that`s who i am
MightyMagi82
14
Years of Service
User Offline
Joined: 9th Apr 2010
Location: Kansas
Posted: 9th Apr 2010 20:50
Thanks, I appreciate the help on that problem a lot!
MightyMagi82
14
Years of Service
User Offline
Joined: 9th Apr 2010
Location: Kansas
Posted: 10th Apr 2010 00:04
Now I just need help on how to wrap the sprites around the screen instead of being bounced off the edge of the screen. Anyone know how I can do that on a 640 x 480 window? Thanks!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Apr 2010 01:38
Sprites can be placed off the screen. The furthest left for example is NOT 0 (zero).

So, you can actually place a sprite at X=-100 if you like. Therefore...

If you are deducting a value from the sprite's X position variable (to move it left across the screen), instead of reversing when it reaches 0, just keep going until it's off the screen.

If your sprite is 128 pixels wide, then when the X position variable reaches -129 then it's completely off the left side of the screen.

At this point, set the X variable to 641 (just off the right side of the screen) and continue ad infinitum - if required.

TDK

Login to post a reply

Server time is: 2024-09-28 16:37:37
Your offset time is: 2024-09-28 16:37:37