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.

DarkBASIC Professional Discussion / Map Loader Problem

Author
Message
Jacob G
13
Years of Service
User Offline
Joined: 12th Jul 2012
Location:
Posted: 13th Jul 2012 07:01
Hello everyone im not very experienced in DarkBasic even though it's basic. Anyway im having this tilemap problem that i've created with .map file and its working but it skips a tile every time and i dont know what the problem is can someone please help me


I "think" the problem is insize the for loop with id in it.
Im looking forward to your guys answer!


Oh and quik question i heard that TXT files take up alot of memory so is there another file format for maps that's really small.
is .map good ?

Jacob Gardam
Kezzla
17
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 13th Jul 2012 08:11
where does it skip the tile?

maybe try making your loops start from zero and see if that fixes it.
either that or make them go to mapsize + 1

Quote: "Oh and quik question i heard that TXT files take up alot of memory so is there another file format for maps that's really small.
is .map good ?"


dunno, is a .map a text file you have saved as .map?

if it contains text then it should have the same filesize.

there may be some minor bits of information saved in a txt that im not aware of however.

Sometimes I like to use words out of contents
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 13th Jul 2012 09:33 Edited at: 13th Jul 2012 09:34
Yeah mapsize + 1, because your sprite ID is x-1, y-1

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jul 2012 14:34
See my comment plus simple demo on your other thread. This sounds like the same problem.
GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 13th Jul 2012 16:12
Quote: "Oh and quik question i heard that TXT files take up alot of memory so is there another file format for maps that's really small.
is .map good ?
"


I don't know if I would be worried about the size of your file. However, you could pack your data into an image, then each pixel gets expanded into a tile. This has the added benefit, that your level editors would just be a paint program.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 13th Jul 2012 16:25
I did not know DBP supported .map files...

See
Quote: "File Formats Supported"


on this page

http://www.thegamecreators.com/?m=view_product&id=2000&page=features

hope that helps... or what Green Gandalf said

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jul 2012 18:18
Quote: "I did not know DBP supported .map files..."


The DBPro read byte command doesn't know anything about .map files - they are simply files containing data. You could read the bytes from a .exe, .png, .x or anything really in the same way. In this particular case the files were probably text files as produced by Notepad or similar (I used Notepad) and were given the .map extender when saved (which is what I did).

If you check the details of the sample .map file I posted you'll see that it is 120 bytes, i.e. 10 lines of 10 data bytes plus the 10 pairs of end-of-line characters. I'm not sure but in some cases the files might have only one end-of-line character per line. Others will know more about such things than I. Actually with hindsight I should have used visible characters rather than spaces to make the map file layout more obvious - but I'm sure you can all make the substitution yourselves .
RonsWare
15
Years of Service
User Offline
Joined: 5th Sep 2010
Location: Netherlands
Posted: 13th Jul 2012 18:33
If i remember it right.
Every .txt file line ends with 2 codes.
Program used is Notepad.

1 > The Enter code ( 13 ) in hex 0D.
2 > The Line Feed ( 10 ) in hex 0A.

Like this 0D0A.

Cheers Ron.

Programming is learning
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jul 2012 18:53
Sounds about right.
GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 13th Jul 2012 19:30
I still like my idea of using an image as your data storage vehicle for a tile based game best.

You get 32 bits of storage for each cell, I mean how many tiles could you have? more than 8 bits worth? That still gives you 24 bits to store other stuff. Plus, if you use the PNG file format, you have excellent lossless compression built right in. Also you have about a million different options for your level editor.

All you have to do is render... Every other bit of work is done for you...
RonsWare
15
Years of Service
User Offline
Joined: 5th Sep 2010
Location: Netherlands
Posted: 13th Jul 2012 19:30
@Green Gandalf
Your very welcome.

Maybe it's better to just make a binairy file.

Like this.

The function MakeInt16() is made thanks to WLGfx.



Sorry for the dutch commands.
Use google to translate.

Hoop this helps.
Any questions are welcome.

Cheers Ron.

Programming is learning
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jul 2012 19:40
For a simple map as used in the poster's original code a basic text file is a very quick, easy and efficient way to create the map. A good example is the Huge Dungeons demo on this page:

TGC Tutorials
GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 13th Jul 2012 19:42 Edited at: 13th Jul 2012 20:12
Here you go, fixed.

See fixed version below...
GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 13th Jul 2012 19:43
Yeah, I don't mean to flame, but my way is better and faster.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jul 2012 20:01 Edited at: 13th Jul 2012 20:08
Debatable (somewhat). It might be more awkward to create the image than to create the text file but on the other hand your method gets around the end-of-line problems. Also the image idea is better if you want to paint different regions on your map.

Incidentally I've just checked the Huge Dungeons demo and it looks as if Jacob G might have used that demo since the code is similar.

The sample map that comes with Huge Dungeons doesn't have any end-of-line characters which is probably why the tutorial came with a special map making utility - and which is probably why Jacob G had the problem he had since I guess he didn't use it (I've tried to use it and find I can't do anything useful with it ).

I've done something similar and I don't recall having this end-of-line problem. I'll dig it out and see if I can find out how I dealt with it.

Edit Found it. I changed the read byte to read a string for each row. This removed the end-of-line problems.
GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 13th Jul 2012 20:09 Edited at: 13th Jul 2012 20:19
Whoops, I had a typo, should work now

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 14th Jul 2012 07:04
Reminds me of programming in C.

Login to post a reply

Server time is: 2026-07-08 01:55:00
Your offset time is: 2026-07-08 01:55:00