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! / Reading 2d tilemap data

Author
Message
Tym
20
Years of Service
User Offline
Joined: 31st Oct 2005
Location:
Posted: 1st Nov 2005 04:57
I'm new to doing 2d stuff in DarkBASIC Pro. I while back I was able to display a tilemap but I since lost my source code for it. But I remember I didn't use the Data and Read statements to do it, but that's what I want to do this time bcause I'm going to have external files that contain the map data (eventually). I've looked at the 2d concept thread that is pinned at the top and although I get the concept, I'm having problem with the actual READ statement.

Here is a piece of my code. There is something wrong when it tries to populate the array with the DATA. I got the example from another thread.



I'm trying to print the array out so I can tell if it's populated with the correct data, but it says it can't determine the parameter type of my "read values." To be honest I just left it as it was in the example. The documentation doesn't really help me to determine what it is I'm actually supposed to "read" I'm assuming since values is not a declared variable that is the problem. But I don't know what I should put there instead.

Any help would be apprciated.
Oraculaca
23
Years of Service
User Offline
Joined: 6th Jan 2003
Location: Scotland
Posted: 1st Nov 2005 10:52
change 'tilenum = read values'

to

'read tilenum'


Oraculaca
23
Years of Service
User Offline
Joined: 6th Jan 2003
Location: Scotland
Posted: 1st Nov 2005 11:01 Edited at: 1st Nov 2005 11:14
Here it is in a more readable form



And once more in colour:




Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Nov 2005 23:58
Quote: "I'm new to doing 2d stuff in DarkBASIC Pro. I while back I was able to display a tilemap but I since lost my source code for it. But I remember I didn't use the Data and Read statements to do it, but that's what I want to do this time bcause I'm going to have external files that contain the map data (eventually). "


Actually if you want to use data statements you have to have the data in the code... you can't have it in an external file. The data has to be in the code so it can be read. I would use your first method and read/write files rather than use data statements. You did it once... you can do it again.
Tym
20
Years of Service
User Offline
Joined: 31st Oct 2005
Location:
Posted: 2nd Nov 2005 19:33
JOHN: Thanks! That helped a lot.

Grog: I'm working from the manual the referance manual that came with DBPro and trying to pick stuff up as I go since there aren't that many 2D tutorials. If I have a file (let's call it map.txt) that looked like this:
0,0,0,0,0
1,0,0,1,1
0,0,1,0,0
0,0,0,0,0
1,1,1,1,1

and I did a read file, I assume it would look something like this:

What I don't understand is how to display the data from this point. How would I read mapData into an array to be displayed? Or is there some other approach that I'm missing?
mr joe
21
Years of Service
User Offline
Joined: 12th Aug 2004
Location: Edinburger, Scotland. DBC
Posted: 11th Nov 2005 15:29
I've just been trying to do the same thing as you I think. I have DBC, so I'm not sure if there is an easier way to do it in Pro, but you can use something like this to read your data into an array.

First you have to format it correctly in the .txt file, thats what I put my data in. So create a .txt (say map.txt) file, something like:
11111
10001
10001
10001
11111

Then the program might look like:


Hope that helps and isn't too confusing.

Joe

[href=http://www.mrexplode.tk]Huzzah![href]
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Nov 2005 19:33
Quote: "Grog: I'm working from the manual the referance manual that came with DBPro and trying to pick stuff up as I go since there aren't that many 2D tutorials. If I have a file (let's call it map.txt) that looked like this:
0,0,0,0,0
1,0,0,1,1
0,0,1,0,0
0,0,0,0,0
1,1,1,1,1
"


I'm sorry I didn't reply sooner... I somehow missed your message as being new. The easiest way to save and load map data is by the commands "save array" and "load array". Those commands take all the guesswork from reading/writing information. And "save array" doesn't require deleting the file before it can save. I really love those commands because they only use one line to put the entire file into the array.

Login to post a reply

Server time is: 2026-07-06 15:44:05
Your offset time is: 2026-07-06 15:44:05