Game architecture

Started by
21 comments, last by Alberth 7 years, 7 months ago
So do i save text or something?

That would work.

Basically, you have to decide how to store each tile of your map in the file. For example you could do


28, 41, green
29, 41, blue

This would be one line for each tile, first the x position, then the y position, then the colour (not idea what you have, maybe you want to store something else there).

Your data does not need to be text, you can also just write binary data, but the big advantage of text is that you can read it, and even write it your self. Another advantage is that there are standard formats that you can use to store your data, like INI, JSON, YAML, or XML. There are readers and writers for many programming languages for such formats, which means you can just use a library instead of having to read and write the data yourself from/to file.

As an example, some YAML data of a game I am writing (but not very fast :P )


name: First scenario
category: Who wins?
description: May the best man win

map:
 - {x: 1, y: 1, tile: path_none}
 - {x: 1, y: 2, tile: path_none}
 - {x: 1, y: 3, tile: path_none}
 - {x: 2, y: 2, tile: path_none}

I am writing this game, using these files to load scenarios etc, and I don't even have a map editor. I just edit these file by hand, which works great for testing.

Note that reading lines like "28, 41, green" is quite doable. Reading data like my YAML file is a lot more work by hand.

Advertisement

Hmm... ill look into them. I would make the maps by hand but each map consists of 710 tiles so by hand its a lot of work + by having a map editor, i would have worked out many things about the game, like the hierarchic structure of a map and pieces and whatever it will consist of.

I would make the maps by hand but each map consists of 710 tiles so by hand its a lot of work
Why do you need a fully filled map at first?

Make a fiile with 710 "flat grass" tiles, or whatever you have as common fill tile. Just change a small part of the map to test your world loading. As I just showed above, my current world is exactly 4 hexagons. big. It's not an interesting world to play, but it's enough to make code for drawing the world, and displaying a list of scenario files.

Later, when I have all the graphics and the code, I can make an editor, and try to make an interesting game world as a level to play.

Making a level editor is a lot of work, I prefer to postpone that until I know my game is going to work.

by having a map editor, i would have worked out many things about the game, like the hierarchic structure of a map and pieces and whatever it will consist of.
True, but why do you write the editor in a different language then?

The game must be able to store and display the world too. That code can be used both for the game and for the editor, if you use the same language for both :)

This topic is closed to new replies.

Advertisement