Excerpt from tile save file
1|grass|a|(25, 25)
2|stone|a|(75, 25)
3|grass|a|(125, 25)
4|grass|a|(175, 25)
5|grass|b|(225, 25)
6|grass|a|(275, 25)
7|grass|a|(325, 25)
8|grass|a|(375, 25)
9|grass|a|(425, 25)
10|grass|b|(475, 25)
11|grass|b|(525, 25)
12|grass|a|(575, 25)
13|wood|a|(625, 25)
14|grass|a|(675, 25)
15|grass|a|(725, 25)
16|grass|b|(775, 25)
17|grass|a|(825, 25)
18|wood|b|(875, 25)
19|wood|a|(925, 25)
20|grass|a|(975, 25)
21|grass|b|(1025, 25)
22|wood|a|(1075, 25)
23|grass|a|(1125, 25)
24|grass|a|(1175, 25)
25|grass|a|(1225, 25)
26|grass|a|(1275, 25)
The tiles are stored in this format for now, so if you ever want to change the type of a certain tile (you big cheater) then just edit the wood/grass/stone entry in the save file (/township-pre-alpha/saves/1/tiles.twn). Never change the tuple of numbers though, or you will run the risk of messing your map up.
The code for saving this is really simple...
# Save tiles
tileFile = open('./saves/' + str(mapnumber) + '/tiles.twn', 'w')
for tile in tiles:
tosave = str(tile.id) + '|' + str(tile.type) + '|' + str(tile.variation) + '|' + str(tile.center) + '\n'
tileFile.write(tosave)
Other things like buildings, creeps and villagers are stored in a similar format.
Sorry for not yet updating the .zip, its exam time atm so I was revising instead of having free time.
Also, the creeps only work slightly better, in that they tend to move rather than jitter now, but they still aren't reliable. I'm going to totally recode them sometime. Probably after saving/loading is working and I update the zip.
Making my code neater == Rewriting most of the program. Main menu code doesn't make me cry anymore. Also, I intend to use a fully object oriented approach this time, rather than the mess I made at first. For example, now there is a class MainMenu() which handles the whole of the main menu via methods, rather than the horrible method I was using before of trying to attach a main menu to the game I had made. Also you can use a text file to change button texts :D .
It is also now easy for me to add new buildings, creeps, etc. since they are also stored in text files whereas before they were hardcoded (creeps will still be pretty much hardcoded since I have plans for more complex behaviours than just wandering).
Speaking of buildings, here is some outline for how I plan to implement them:
## Name:<Building name>
## Type:<Building type>
## <Type specific fields>
## CostFood:<Food cost of building>
## CostWood:<Wood cost of building>
## CostStone:<Stone cost of building>
## <Other resource costs (for future)>
## Vars:<possible variations of the building image, eg abcde>
## BaseImage:<Path of the sprite, without variation suffix>
## ImageType:<Image format of the sprite, eg .png, .jpg>
## Icon:<Path of building icon>
## Descr:<Short description of the building's use>
I'll write some stuff (copy/paste from the buildings file since I've written lots this time so my brain knows how I want to implement things) about how types and stuff will work if anyone is marginally interested. I intend for this release to take a while before I actually release it, but have a far better game for it. One of the things I want to add is a greater variety of buildings, which is another thing I always intended.
Additionally, I intend to add more types of 'creeps' such as a Builder Creep of some kind that builds lairs for its friends. This in turn could lead to less of a focus on waves and move in a more RTS-y direction with the need to destroy said lairs or fight off many many creeps. I will also try and make the old herding creep work better, as it was a fun idea that I broke when moving from creeps on a white screen to an actual game (when I couldn't think of what to do for coursework).
A lot of this writing is just me braindumping though rather than definite future features, seeing as how I am developing a tendency to walk home from uni thinking of ideas, then forget all about them until I'm next walking home from uni...
As an idea, I currently have a fully functional main menu which looks nice and elegant in code, and is about as customisable without changing code as I can make it. Next up is writing the Map class (and by necessity the Tile class I guess) which will generate a map to a set size, rather than just to the screen size as before.
Yes my cleanup has turned into a rewrite. But its worth it!
Making buildings placeable! They snap to the tile grid, to make pathfinding around/to them work properly. Sadly, this means no more free rotation of buildings. Walls will be built tile by tile now, rather than with preset lengths of wall, allowing for greater customisation of layout.
(http://www.sotk.co.uk/township/buildings8-7-12.png)
Next is the battle of making all the buildings do what they're supposed to based on a few lines in a text file ;D . Then some basic enemies to make it a game, along with smoothing out the menus somewhat and adding in the load/save screens. Followed by a release. The map settings screen I showed will wait until further down the line to be released, since linking in all the options I want to have would result in me never getting anything released at this rate :P . My aim at the moment is to make everything as customisable as possible, hopefully eventually (read once the game is enjoyable) allowing the player to 'design' their own soldiers by equipping them with different loadouts, and being able to save these as unit types that are trainable.
(http://sphotos-h.ak.fbcdn.net/hphotos-ak-snc7/336300_10152360357590078_2034862983_o.jpg)
You could say that xD .
Horrible maths has beautiful results.
(http://sphotos-d.ak.fbcdn.net/hphotos-ak-ash4/466766_10152363518820078_142078849_o.jpg)
Even more beautiful is the result of another maths-y day :D
(http://sphotos-d.ak.fbcdn.net/hphotos-ak-snc7/327260_10152365776055078_1348934554_o.jpg)
Frustum culling implemented, framerate += infinity. Also cubehouse.
(http://sphotos-f.ak.fbcdn.net/hphotos-ak-ash4/333477_10152369814285078_1626635045_o.jpg)
Sure is :D
(http://sphotos-h.ak.fbcdn.net/hphotos-ak-ash4/291631_10152370471530078_126756997_o.jpg)
Let there be light!
(http://sphotos-c.ak.fbcdn.net/hphotos-ak-snc7/471404_10152373693560078_135834269_o.jpg)
Not very impressive at the moment, but here are some screens of the hex grid that is used as the 'continent map'. The next step is to turn this into a square grid at a much higher resolution, which will eventually become the actual terrain. Maybe preliminary screens of that tomorrow or the next day. Then once I have a basic implementation of the map working in this form, I think I will work on getting the game part of Township back to where it was in the original Python release. After that I will work on making the map generation more interesting and improving the gameplay somewhat.
(http://www.sotk.co.uk/twn01.png)
(http://www.sotk.co.uk/twn02.png)
(http://www.sotk.co.uk/twn03.png)
Ok, some progress has been made. Big maps now take forever and a day to generate, but I'll work on speeding that up soon. Here is an example of a hex map, which is then turned into a square tile based approximation of it at a huge scale.
(http://www.sotk.co.uk/township/twn04.png)
(http://www.sotk.co.uk/township/twn06.png)
And for scale:
(http://www.sotk.co.uk/township/twn05.png)
I agree wholeheartedly. I was talking to Lady Grey about it a couple of weeks ago and decided I had to give it another, better, go. That's what caused me to start actually implementing yamlui after a similar but less strong bout of motivation struck last year and gave me that idea (sadly that inspiration ran out after trying to write an example ui definition).
(http://sotk.co.uk/township/mapgen01.png)
That's what I've got so far with this map generator, trees could use some work to render them less uniformly, and stop them being cut off by chunks below and to the right. This map is 256x256 tiles, but it can be infinite if I just figure out a neat way to generate chunks on the fly. That 181 is the fps I'm getting, which compared with about 30 fps on the old unfinished python version with a 200x200 map is quite an improvement...
I'm also still not happy with the rocks, maybe I'll switch back to tiles that are 32x32 pixels instead of 16x16.
I decided to make them less bright, and more smooth. I think they look much better now!
(http://sotk.co.uk/township/mapgen02.png)
Adding that graphical variation is the only improvement I've made so far sadly, but I do now have a clear picture in my head of how the infinite map will be implemented, I just have to get time to do it.
Infinite map screenshots!
(http://i.imgur.com/2a1jpqB.png)
(http://i.imgur.com/BaS6oxr.png)
Today's progress has mostly been the tile information panel thing, which is only there as a means to the end of me working out what tiles need and playing with yamlui's text labels really.
If you want to play with it and have Python (>=2.7) + Pygame (something recent-ish, idk) installed, you can get the code from GitHub (https://github.com/ColdrickSotK/township). You'll need to get yamlui (https://github.com/ColdrickSotK/yamlui) too and place it alongside mapgen.py though. There isn't much in the way of actual functionality yet though, its still pretty much just a map generator.