Author Topic: Township - Development Thread  (Read 103507 times)

Jubal

  • Megadux
    Executive Officer
  • Posts: 35447
  • Karma: 140
  • Awards Awarded for oustanding services to Exilian!
    • View Profile
    • Awards
Re: Township - Development Thread
« Reply #15 on: January 16, 2011, 05:00:09 PM »
You were using djikstra's? Owch... that would be why it's taking so long, since you must be working out how to get to every single point on the map...
The duke, the wanderer, the philosopher, the mariner, the warrior, the strategist, the storyteller, the wizard, the wayfarer...

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #16 on: January 16, 2011, 05:07:17 PM »
Indeed I was, since it is pretty simple and I had never done anything like that before. It was slightly streamlined in that it only took the centre of each 50x50 tile and stopped if it inspected the target tile, which is why trying to move from one corner to the other causes a pause before movement starts, since that is when pretty much every tile is examined.

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #17 on: January 17, 2011, 02:35:55 AM »
Quote from: "Jubal"
OK, worked out how to train villagers; now I'm doing well enough to outnumber the creeps two to one,  :P
What Jubal said. Also make sure that you have the latest python build, and that you have pygame installed.

I added a save function and will soon have a load function. I also seem to have improved the pathfinding somewhat (in that it tends to take a fairly sensible path now) and know the main thing causing collisions the unit to have collisions with the environment along its path. The problem is that I hadn't taken into account that the last tile does not connect to the tile with id immediately next to it, which was a massive oversight (I even thought of it before I wrote the algorithm, but then forgot). Creeps also actually move now. Sometimes.

I'll update the .zip file once I've written the load function, most likely early tomorrow.

Saving/'Loading:

To save a map, press Ctrl + S .

To load your saved map, press Ctrl + L after clicking start new game.

It will become more user friendly and sensible once I get round to user interface improvement, which will likely be after I have the creeps actually moving, and before I work on expendable resources, a bigger map and also look at making the map be procedurally generated rather than a random scattering of stuff, allowing water and forests and 'cliffs' and cool stuff like that.
« Last Edit: January 17, 2011, 02:48:28 AM by Son of the King »

Jubal

  • Megadux
    Executive Officer
  • Posts: 35447
  • Karma: 140
  • Awards Awarded for oustanding services to Exilian!
    • View Profile
    • Awards
Re: Township - Development Thread
« Reply #18 on: January 18, 2011, 11:09:57 PM »
Looking forward to actually having some creeps attack me. :P
The duke, the wanderer, the philosopher, the mariner, the warrior, the strategist, the storyteller, the wizard, the wayfarer...

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #19 on: January 19, 2011, 01:23:25 AM »
Excerpt from tile save file

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...


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.

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #20 on: January 23, 2011, 03:03:44 AM »
Aaaand double post. I've updated the .zip file at long last. Creeps are still not working as intended (they stop 50px into the screen from each edge, and can only move about in the same region. I'll try to sort it out later.

Scratch that, I've just realised what the problem is. Since I changed the way map tiles work to allow pathfinding to be easier for me to code, the list of tiles the creeps are using to check for collisions with trees etc. includes every tile on the map. You now actually have time to build a decent base before the first creeps arrive (since iirc they tear buildings down quite quickly). Soldiers are the best way to defend yourself for now by the way, walls were useless last I remember since creeps could jump over them due to my inaccurate coding.

Saving/loading doesn't work yet (well it does but loading doesn't do anything, and saving is not complete).

Pathfinding should be better now. It might still be slow though. If you run Windows and its incredibly slow, then I blame your operating system. When I tried the old version on Windows the other day the pathfinding was slower than I ever remember it being on my Linux virtual machine (which has 1/4 of the memory and shares the same processor (obviously)). It should be faster than before though, since I streamlined the algorithm somewhat.

Enjoy your angry creeps guys.

http://www.sotk.co.uk/township.html

Marcus

  • Devourer of Souls
  • Megas Domestikos
    Voting Member
  • Posts: 1667
  • Karma: 10
  • I think, therefore I am.
    • View Profile
    • http://exilian.co.uk/
    • Awards
Re: Township - Development Thread
« Reply #21 on: January 23, 2011, 11:37:28 AM »
When you talk about the latest python, are you referring to Python 2 or 3?
"So if you meet me, have some courtesy, have some sympathy, and some taste. Use all your well learned politesse, or I'll lay your soul to waste."

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #22 on: January 23, 2011, 02:03:55 PM »
Python 3 and pygame 1.9.1 for python 3.

Jubal

  • Megadux
    Executive Officer
  • Posts: 35447
  • Karma: 140
  • Awards Awarded for oustanding services to Exilian!
    • View Profile
    • Awards
Re: Township - Development Thread
« Reply #23 on: January 23, 2011, 09:08:01 PM »
I'll try and take another look at this soon: this will be a fairly busy week though as I have to get ahead of myself before going away next weekend.
The duke, the wanderer, the philosopher, the mariner, the warrior, the strategist, the storyteller, the wizard, the wayfarer...

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #24 on: January 26, 2011, 01:41:10 PM »
Thanks :) . If anyone has looked at my code yet, then you'll have seen it's all kinds of untidy... I am mainly tidying it up at the moment. Putting off writing the load routine...

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #25 on: February 12, 2011, 11:12:38 PM »
YAY DOUBLEPOST

Sorry for lack of anything recently, I'm in the first mass coursework giving of this semester. Someone here seems to like the idea of every module handing coursework at the same time, leading to masses of work half the time, and far less the rest of the time...

Jubal

  • Megadux
    Executive Officer
  • Posts: 35447
  • Karma: 140
  • Awards Awarded for oustanding services to Exilian!
    • View Profile
    • Awards
Re: Township - Development Thread
« Reply #26 on: February 12, 2011, 11:20:26 PM »
There's upsides and downsides to that.

Hope to see a new version someday anyhow.  :)
« Last Edit: February 12, 2011, 11:28:29 PM by Jubal »
The duke, the wanderer, the philosopher, the mariner, the warrior, the strategist, the storyteller, the wizard, the wayfarer...

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #27 on: February 13, 2011, 02:01:13 AM »
That is indeed true.

And there will be another version sometime. I will probably update once I have implemented saving/loading and when there is actually a user interface for building.

Edit: Since I got bored of coding a basic system to handle user accounts with a dvd shop for my latest coursework, I decided to take a look at township. I still couldn't bring myself to make the load function, and instead looked at ways to improve the map generator. I began to create a python version of the old map generator I mentioned in thee first post of this topic. At the moment all it does is generate an expanse of grass dotted with dirt patches, but I will eventually expand it so that forests and water can be generated.

Once it makes a nice map, I will use this to generate the maps in Township, meaning maps bigger than the screen, maps which aren't just trees and stone randomly placed, and more gameplay features (water will be an obstacle for both creeps and your villagers for example, maybe boats).

Now tomorrow (as well as solving many ODEs) I will finally make the load function, then I can forget about that for a time.
« Last Edit: February 13, 2011, 04:53:21 AM by Son of the King »

Son of the King

  • Megas Domestikos
    Voting Member
  • Posts: 3368
  • Karma: 29
  • Awards Awarded for outstanding services to Exilian!
    • View Profile
    • SotK
    • Awards
Re: Township - Development Thread
« Reply #28 on: March 02, 2011, 03:08:44 AM »
Version pre-alpha-0.3 (probably released before the end of the week) will include:
  • Ability to save your game.
  • Ability to load a previously saved game.
  • A less buggy in-game message system. Currently some messages only flash briefly onto the screen, in 0.3 it will work properly.
  • Easy-to-use interface for building and recruiting (hotkeys will remain the same as they previously were).
  • A slightly less bizarre scoring system.
  • Perhaps expendable resources, although I am unsure about this until bigger maps are included.
  • Perhaps faster pathfinding, although that may have to wait for a later release.
  • Installer and executable for Windows users, so that python and pygame don't need to be installed for the game to run (if I can get py2exe to work properly, which apparently could be a problem...).
And then further in the future there will be:
  • Multiple save games, and a nice interface for loading them.
  • Larger maps that are procedurally generated, rather than being totally random.
  • Buildings that allow the training of your soldiers to increase their stats.
  • Experience implemented for all unit types (i.e. soldiers and villagers), rather than just gatherers.
Along with other stuff that I won't list here.

Also, if anyone has any suggestions on how to improve the game or any new features I could potentially add, don't hesitate to tell me.

lordryan756

  • Citizens
    Voting Member
  • Posts: 255
  • Karma: 2
    • View Profile
    • Awards
Re: Township - Development Thread
« Reply #29 on: April 10, 2011, 05:04:35 PM »
Interesting stuff :D. I read in one of your earlier posts that they jump over walls, but I think that it may be solved by having the creep/monster thing check the up-down-left-right tiles for a "Wall"? I haven't played the game yet, so I don't have an idea beyond the posts, and don't know how easy/hard the check would be for Python.

Also, to make pathfinding easier, have them only move in the 4 cardinal directions (If they don't already), Up, Down, Left and Right, because this is supposed to be easier then having them move in 8 different directions (Diagonal).

Again, I haven't played this yet, so if these are implemented, then just ignore this post :P.