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! / best way to read in a text database for game content?

Author
Message
method321
15
Years of Service
User Offline
Joined: 28th Jan 2009
Location:
Posted: 28th Jan 2009 21:54
Here is what i wan to do, but i am not sure of the best way.

I am working on a game that is 800x600 and that screen is broken down into a play field of 512x512, which is broken down into a matrix of 32x32 pixel squares, basically something like this:

----------------------------------------
-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-
-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-
-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-
-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-
-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-
----------------------------------------

pretty much a 2-d array.

what i want to be able to do is have different jpeg images and i want to load them at particular array coords. So lets say, a candle is image01.jpg and a sword is image02.jpg,
i want to (at the start of each game level) read a text file, similar to below:

level-1
i1,00,00,00,00,i2,00,00,00,00,00,00,00,00,00,00
etc

so the entire array gets populated and there is a correlation that if the field=i1, then load image01.jpg in that location..

I know a level can be generated this way.. i am just having a hard time trying to find examples. any suggestions? The reason i want to do it in a text file, is so that i can easily modify, manipulate and add levels, without having them hard-coded into the source.
Zergei
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 30th Jan 2009 02:20
I've got some old code for a map maker. Interested?

Further on my stuff at...
TurboSquid.com
The3dStudio.com
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th Jan 2009 12:39
Yeah, there's no way I'd try to do that through text editing, an editor would make the project about a thousand times more fun to use.

I would strongly suggest using a 16x16 block of your images, so each image would have 256 32x32 images, so the actual size would be 512x512. Instead of using strings, you could use bytes to store the map layout - maybe make image 0 a blank, but having your images laid out on a grid is a great way to expand. Saving and loading a map based simply on bytes is easy, just have your 2D array save and load with the built in commands if the map size stays a standard. Even if you don't need 256 tiles per level, you could use a compressed file format like PNG and the extra space would cost practically nothing while allowing easy expansion.

For example, if you went for this method, your engine could cut out each image and paste it to generate the level - but then it would also lend itself well to using a simple matrix, memblock matrix, or even individual sprites. If you used sprites, a matrix, or meshes you wouldn't need to cut out each image - that 1 image with the 256 tiles could encompass a whole level and would make adjustments really easy. You could have 1 copy of the tileset for daylight, 1 for night, 1 for snow - it depends on how your engine works.

The reason I mention these 3D techniques in a 2D game is that by going 2.5D, in other words sticking to 2D principles but using 3D technology - you can avoid a lot of issues, like Z depth sorting, but the main benefit is speed. The speed difference in displaying a mesh instead of pasting the images is huge. You also avoid resolution problems this way - instead of having to force the program into a set resolution you can just display it all as 3D and there's no need to worry about unsupported resolutions.

Personally I'd only go for pure 2D if I was making an exact remake of an old 2D game, 3D engines hold far too many benefits to ignore.


Health, Ammo, and bacon and eggs!
method321
15
Years of Service
User Offline
Joined: 28th Jan 2009
Location:
Posted: 30th Jan 2009 13:57
well thanks for the input.

I will do some more research and see what i can come up with, the 2.5d sounds like the better approach, although there may be a signifigant learning curve for me in that space.

Login to post a reply

Server time is: 2024-04-19 09:27:18
Your offset time is: 2024-04-19 09:27:18