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.

2D All the way! / arrays

Author
Message
Ads
20
Years of Service
User Offline
Joined: 13th Sep 2003
Location:
Posted: 24th Sep 2003 20:26
what is an array exactly and how is it useful and what are they used for and hows?
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Sep 2003 20:40
An array is a list of numbers.

Example..Dim List(10)

for n = 1 to 10
List(n) = n
Next n

Puts 1 to 10 in the list.

Print list(5)

Prints 5 because we just stored 5 in there.

Arrays can be more than 1 dimension.

Dim Map(10,10)

can be used for map references, or collisions with a map reference on a 10*10 grid. Think of it as Dim(X,Y)

Pincho.
TheAbomb12
20
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 24th Sep 2003 21:52
hey ads,
can you post these questions in the newcomers corner? arrays have little to do with 2d ( unless its map references). try checking the newcomers corner for your questions as well.

also, try looking at both the dark basic pro and dark basic classic tutorials.

Those who Fight with swords get killed by those who don't
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Sep 2003 12:11
Yeah, he's looking into arrays for a 2D tile drawing system I think.

If you say your map is 128x128 tiles, then you'd dim an Array (like Pincho says, I'll just elaborate a bit):



Fill it with a blank collision check (say 0):



Draw a safety box around the edges to avoid range problems (say 1):



Set a random scattering of tiles on the map (1 in every 16 tiles is a collision):



Draw the map using the array:



Check for a collision, return a 1 if collided with background:



HTH.


Van-B

My cats breath smells of cat food.

Login to post a reply

Server time is: 2024-05-05 13:14:32
Your offset time is: 2024-05-05 13:14:32