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! / Data?!

Author
Message
Seannny
18
Years of Service
User Offline
Joined: 21st Apr 2007
Location: California
Posted: 3rd May 2007 07:33
What is this...Data! in which you all speak! im a noob, lets all throw pies at me! but after that tell me, what is
Data 1,2,3,1,2,3
data 1,0,0,0,0,1
data 1,2,3,1,2,3

I see it, i see it is.. making some sort of... pattern.. But what does it do? how does it work? im in dark basic pro and apperently you use data to make some sort of map for a 2d rpg. i wanna make a 2d overhead one but im not sure how? is this the way? if it is\\isnt i wanna know what the heck this data stuff is!
help!

hey, im a db noob. Lets all throw pies at me.
Saiochi
18
Years of Service
User Offline
Joined: 17th Sep 2006
Location: Under your bed
Posted: 3rd May 2007 08:07 Edited at: 3rd May 2007 08:07
You'd be much better off not using data. I just posted a Map Reading Function that doesn't use the data command.

http://forum.thegamecreators.com/?m=forum_view&t=105528&b=4

If you have X-ray vision, can you see through your own eyelids?
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd May 2007 19:42
View this pixel-scrolling tutorial:
http://zimnox.com/?page=dbTutorials

It doesn't really go in depth about DATA, but it does demonstrate its use specifically for an overhead-style map.

For a game with multiple levels, you wouldn't want DATA but rather save/load the info from a file like Saiochi's function.


DATA can store numbers or strings. It's a way of storing information within the program. In the example you're referring to, it can store a tilemap or even an image. For example, suppose you have a map with 16 tiles across and 16 tiles down. You would have 16 DATA statements each containing 16 numbers. Each number represents a different tile. Let's say 0 is a grass tile, 1 is dirt, 2 is water, and 3 is a bush. You use the READ command to read the next element in the DATA. Everytime you call READ it automatically increments its internal pointer to the next element. To start back over or to start reading from a different point in the DATA, you call RESTORE <label>. The <label> is just like a label you would make when using a GOTO statement. So read in your DATA into an array and then when you draw your map you check which image to paste by looking at the number.
Here's a quick example:




My tutorial better demonstrates how this works. Does this clear up things for ya?


aluseus GOD
18
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 3rd May 2007 23:30
That data map you have there, if used in a map will read the number and figure out which tile number to use.

I will Learn to rule 2d. Someday...
Seannny
18
Years of Service
User Offline
Joined: 21st Apr 2007
Location: California
Posted: 4th May 2007 02:17
Okay Thanks Guys. Phaelax, the if map(1,8) = 0 thing. what is that? 0 would be the grass tile. but the map(1,8) means what? im guessing map is what you would label the data?
once again thanks a bunch guys

hey, im a db noob. Lets all throw pies at me.
Saiochi
18
Years of Service
User Offline
Joined: 17th Sep 2006
Location: Under your bed
Posted: 4th May 2007 04:55
the map(1,8) is a 2 dimensional array. Basically, map(x, y) so if map(1,5) = 0 then the tile at 1, 5 on your screen would be whatever image 0 is in your program (grass, water, a brick wall).

If you have X-ray vision, can you see through your own eyelids?
Seannny
18
Years of Service
User Offline
Joined: 21st Apr 2007
Location: California
Posted: 4th May 2007 06:01
So how do i know what tile 1,5 would be? sorry if im being such a noob =/.
tile 1,5 be like x y coordinates? so if i set xy to 100,100 then it would be places at 100,100 on my screen?

hey, im a db noob. Lets all throw pies at me.
Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 4th May 2007 06:29
or Santa doing the limbo

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 4th May 2007 10:53
indi throws a pie!

good luck in your programming seriously, you made me laugh today.


Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th May 2007 11:39
oh boy, this could take some time.

Quote: "So how do i know what tile 1,5 would be?"

Because you set the value of tile 1,5. In your DATA. Take a look at the code below.


The FOR loop for 'X' will read a 1 row of DATA each time through. Once it's read all the numbers in the first row, the 'Y' FOR loop tells it to move on to the next row below.


Coordinates (3,1) is '5' in the map. (3rd digit in the 1st row)
Coordinates (2,3) is '7' in the map. (2nd digit in the 3rd row)

See how this works?






Seannny
18
Years of Service
User Offline
Joined: 21st Apr 2007
Location: California
Posted: 4th May 2007 17:11
Okay so you set the rows and columns variables, and use dim and make an array. and for 1-10 and 1-5 (or columns and rows) you read map, then end the FOR loop with NEXT.

alright i think im halfway getting it. the next(integer) command ends FOR but im iffy about the integer.
and i dont see where data comes in here. is it the 1-collumn and 1-row? then the read map x,y?
Okay wait wait. you set your variabls columns and rows to 5, and 10 then you make them arrays. then you do for x=1 to collumn which is reading every number from 1 to collumn variable and putting it into x. then it does the same for row. it says to read x,y which is reading 1,1 then when it hits next it takes variable as what is was and moves it back to the start as the same thing, same as y, so it would then read 2,2 next time around right? then 3,3 4,4 5,5 6,5 7,5 8,5 9,5 10,5? because columns are only set to 5 it doesnt go higher than 5? correct? wooh i hope so.

if thats right then im pretty confident with reading it and setting what to read.

NOW so its reading all the data, but its not doing anything with it, so how would i make it put a 32x32 sprite on the screen. or does it already do that? becuase data 1 would symbolize sprite 1...right?
how would i get this on the screen.

man you guys must be worn out by me...=D i promise to try and not annoy you as much once we get this done.

hey, im a db noob. Lets all throw pies at me.

Login to post a reply

Server time is: 2025-05-14 17:08:19
Your offset time is: 2025-05-14 17:08:19