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.

Author
Message
Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 5th Mar 2010 22:59
I've finally started to understand arrays, and how they can be applied in my programs. I have one question, though. What if I want to have identical variables on 100 different strings? For instance:

Would I have to keep saying StringName$(Number)="5" one hundred times, or is there some way to set the array up otherwise?
Mew151
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location: Glitch city
Posted: 6th Mar 2010 01:19
How about using a for loop?



Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 10th Mar 2010 23:30
Thanks Mew, I didn't think I could use that when creating an array. Unfortunately, that didn't help me, because I think I'm doing this wrong. Let me explain:

My Goal:
Find an easy way to make tons of sprites (a la zombie horde) appear on the screen without having to manually set them up.

What I Know:
I've read that the trick to doing this is using the awesome power of arrays. So I learned a little about 'em. Arrays can be used to store information such as variables, real numbers, and strings. Arrays can also have as many as five "sub compartments," like a box in a box in a box, etc. I think that I can use this with the "sprite number" of a sprite to solve my little dilemma, but I don't know how.

[b]What YOU can do to Helpb]
What would be great is an explanation or an example of how I can apply arrays to make large quantities of identical sprites. ANY help would be appreciated.
Mew151
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location: Glitch city
Posted: 11th Mar 2010 00:22 Edited at: 11th Mar 2010 00:25
How about something like this:



(... I'm not really sure if this works or not, as I haven't tested it.)

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 11th Mar 2010 00:23
Found a good snippet relating to what you want to do.


for loops are ESPECIALLY useful for scrolling through arrays to do anything. Making a bunch of sprites:

for a= 1 to 100
make sprite a,100,53,1
next a


Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 11th Mar 2010 22:55
Of course! I was trying it out myself, and it never occurred to me that I would have to make an array for the sprites' x and y position. Thanks Mew. And good example NeuroFuzzy.

Login to post a reply

Server time is: 2024-11-24 20:40:49
Your offset time is: 2024-11-24 20:40:49