Wednesday, March 30, 2011

Some progress

About time I got around to another post.

There's been quite a lot of changes since my last post. I now have a working pathfinding system and several working buildings.


I've left out the menu system as it hasn't changed.

My units are currently called dwarves because that was more fun than humans when I started but I'm sure I'll get around to refactoring that sometime. Currently a building can claim a dwarf from a pool of unemployed dwarves and once that dwarf reaches the building he will be employed. The only jobs at the moment I have are Farmer and Porter though.

Originally I made the farmers sit at their farms and plant crops, harvest etc. Then the porter would slowly make his rounds of all the buildings near the storehouse, collecting as many resources as the farms had. If it was taking too long to get to everyone, another porter would be employed by that storehouse.
This worked well but it was very boring and static, as the farmers would just sit in their farm and only one or two dwarves for every 20 or so would actually move.

So I've changed it to be more in the style of Settlers where workers are responsible for taking their produce to the storehouse and collecting what they need from there. Porters will just move stuff between storehouses.

Also paths from buildings to storehouses are now stored so there's very little expensive pathfinding going on. Dwarves use a different pathfinding method depending whether they are on paths or offroad.

I've implemented regions into my map data so getting building and pathing info is relatively quick no matter how much you add. That was done in the Hexitridecimal? method, similar to Minecraft.
However my various attempts at making the map generation more speedy haven't done very well. Currently whenever the screen shifts it calculates a whole new bitmap data for the entire screen in order to display the correct tiles. Hopefully I'll find a better method than this soon.
My current thoughts are to do some more research into generating consistent Perlin data in smaller amounts. Also thinking of storing several screen worth of data, as the user is likely to stay in one place only shifting slightly every now and then.

I've also started the port over to XNA/C# which isn't proving very difficult. Eventually I know I'll need the greater power of C# but for now I'm quite happy prototyping in flash. Hopefully no matter how complicated the game gets I'll atleast be able to have some version working online in flash.

I'm also using my own tileset now for buildings etc. My girlfriend has also started creating tiles to help. Current issues in that area are doing tile transitions to hide the square corners and having consistent, efficient rotations so that the hills look better. For that to work I need to get the same "random" rotation everytime I load that tile, which is either proving costly or difficult.
As for the artwork itself, I've started posting on Pixelation for advice, hopefully they have some great advice/examples for me to learn off.

The farms just look like normal buildings in this version as I'm in the process of adding fields.

As always, post if you read or want some specific information about anything. Or if you have advice/thoughts!

Thursday, March 17, 2011

Wasn't in the plan I had

Well, things reallllly didn't go to plan. The day after my last post we had a 6.3 quake down here in Christchurch. Luckily myself and all those I know got out OK. Others weren't so lucky.

All my notes are still in our work building, which has been red stickered so we can't access, but my PC fell over next to me when I was cowering under the desk, so I unplugged my harddrive and shoved it in my pocket, so I still have all my personal projects. At the time I would rather have grabbed my cellphone, as contacting anyone afterwords was very difficult, but as we may never get access to our building I'm glad I have my harddrive.

Then I was umemployed until the government brought out a support package, now I'm back at work again, although working from home.

Because of all this I haven't really been in the mood to code until recently, so not much to report in that area. I did some work on a flash tile-based system similar to most roguelikes, finishing up the underlying layout. So now comes the fun part where I actually get to add interesting things like working buildings and people that make decisions rather than randomly pathing around.

I learnt a lot about how to do this from code posted by Nolithius relating to his world generation for Dance of Death. Very impressive what he's done using flash.

Linky to his site: http://www.nolithius.com/

The main feature I wanted working was infinite terrain generation in all directions, seeded so you always get the same terrain. This means I only have to save the changes I make. It also has background and foreground layers for tiles versus sprites. With a very basic menu system.


Terrain generation is done using Perlin Noise, with offsets passed in based on where in the map you want to look. This was actually quite simple. Just have to remember that you need to use offsets for each octave you're using. What I need to implement next is a region/chunk system like Minecraft. At the moment all modified tiles are stored in an array which is iterated through when checking what the tile is in an area. This is horrible and sounds even worse now I write it. That was I can also update based upon how far away a region is.

The hardest part about the whole system was getting transparency to work. My sprite tiles were overwriting my background tiles. In the end I used BitmapData.getVector to pull that data from the sprite sheet then, based upon the parameters handed in, could look for all pixels of a certain colour and replace them with  transparent pixels using the aRGB format.

If anyone is interested in a more detailed explanation I'm more than happy to post regarding specific
things. 

Here's a screeny using some Minecraft textures because I haven't finished replacing them with my own:

Monday, February 21, 2011

Things don't always go as planned

Well it's been a while longer than I'd hoped. I fell sick and then my computer died, so have a new computer now but don't have all my development environments installed yet.

I had a lot more that I was going to post about what I've been working on, but I'm struggling to sort through my notes and bring out something coherrent, if anyone is particularily interested please ask.

I was doing some googling and found a minecraftian XNA engine, called Techcraft.

Here's a linky: http://techcraft.codeplex.com/

It was very informative and I learnt a lot just looking through the code, often nodding and pretending to understand. I set to work changing textures and lighting to get them similar to Minecraft. And of course made some amazing failures along the way. If I still had it installed this would probably be where I'd place some pictures showing how nice the lighting was etc etc. However I don't. So just think of Minecraft and that's pretty much what it looks like.

I then set to work revamping the Terrain Generation, which was a lot of fun, testing the various things, setting up Perlin noise using the libnoise port from: http://www.big-black-block.com/tools/libnoisexna

 If anyone is curious I can add more details about how I went about it, but it was fairly rudimentary. I have done some more recent work in terrain generation that I will post about in more detail.
Here's some screenshots from when I was tweaking the cave generation, I set a hard floor at depth 0 then rendererd the caves as brick, and didn't render everything else:

















Sadly I don't have an image of the final setup. And I have no idea what is with the bazooka.

With a reasonable setup to now begin taking this in my own direction I stalled...
I just didn't know quite what I was trying to do with it, and I didn't have the know-how to just mess around adding stuff. I decided to go back to 2D and figure out the saving structure, gameplay etc and then move that to 3D.

More on that will come soon, I've been making some nice progress and now I'm healthy again I might be in the right mental state to post.

Friday, January 28, 2011

No plan like an old plan

You know how all beginning programmers immediately set out to model the entire world with their first program?

Well I am no different.

This dream of mine is to create the ultimate city builder (in my mind!).

Over time I'll detail all the little bits and pieces I want to put together to make the whole, but for now it can be summarised as this:

SettlerCraftFortressCitylisation!

The main ingredient is the resource management from Settlers (Although my first introduction to the concept is from Knights and Merchants from years ago). Combining Minecraft and Dwarf Fortress is hardly a new concept, in fact the two games are already similar in many respects, something that seems to cause flame wars anywhere the two collide.

In Settlers you gather basic ingredients and slowly convert them into the next level. To get clothes you need sheep from wool using shepherds, turn it into fabric using a weaver, then into the final product using a tailor. One you thing you don't see in Settlers is getting multiple things from one source, like in K&M. For example a cow should give you leather and meat.


From Minecraft I want the elegantly simple portrayal of changeable worlds, with a massive level of customisation available. Also the procedurally generated world is a passion of mine, matched with my utter lack of artistic ability.
From Dwarf Fortress comes the characterisation and emergent storylines of the world, where the inhabitants drive you as much as you drive then. You can hear this in stories about DF where they talk more about responding to the game, as opposed to "Then I went here and did this...".

Apparently I've been coding too much, I keep ending sentences with;

Moving forward, the mention of Simcity/Civilisation gives you some idea of the scope I'm hoping this game will reach. With technology trees combined with moments of inspiration for the NPCS, each city/area should develop along slightly different lines, laying out their cities accordingly. Until they meet and can trade what they've learnt.


More than just a game this is going to be my simulation program, you see I love variables, they are my main barrier to creating games. As games evolve they tend to replace earlier concepts with newer, normally better ones. However it's not a straight upgrade and sometimes little things are lost, quirks that you may have come to love. Whenever one of my games reaches a certain 'Saturation Point' where there are enough variables, it goes no further.
I just sit there changing variables and playing my game, and inevitably stop adding new stuff or polishing it.

So I will try and allow large amounts of customisation, especially if anyone comments here about.


I am however going to start small. My current goal is to get a floor plane and a cube going in XNA, I've done it in the past but my memory is faulty.

Saturday, January 8, 2011

And on the first day...

Alright, let's get this narcissistic pursuit underway.

This blog is going to be where I collect my thoughts on various aspects of my life, mainly the areas of Game Design, Programming, Gaming, uh... That pretty much sums up most of my life.

Also likely to end up as a massive link fest archive of all the interesting things I find, so I don't lose them.

In the same vein this will be where I store little titbits about programming, how-to guides for things I can't find online, or find myself repeating all too frequently. You see I have a memory like a sieve, so unless I am repeating things daily I tend to forget them. This can be a problem in my career as most of programming is just a series of little tricks, the more tricks you know the better off you are.

However, if you only need a certain 'trick' once a month, or once a year it's very easy to forget. This blog is ideally going to be my defence against this.