Showing posts with label Bulldog. Show all posts
Showing posts with label Bulldog. Show all posts

Jul 5, 2015

Progress Update July 2015

In the last couple of months I've continued integrating the fruits of my new terrain generator side-project into the main project. Progress has been good, and I should be up and running with the new terrain any day now.

I took a brief detour to explore network connectivity as I've always imagined that Bulldog would eventually support multiplayer functionality. Since I started the project with singleplayer in mind, there's a great deal of work to do to make the game client/server capable. I decided to kick things off by getting the new terrain generator to run on the server thread, and have the client request it via a network call, as it will eventually function that way for multiplayer.

Before I could get going on that I needed to decide on a network stack. I started rolling my own and got a little ways into it with a brief proof of concept that achieved listening and connecting before I decided to look around for pre-built network solutions for .net.  The first one I came across was RakNet, it's been around for quite some time, is used by a lot of people and supports C#.

I grabbed the source and I've spent 4 hours trying to get the examples compiling. I followed the c# tutorial and ran into issues, such as the build failing due to missing folders. So I fixed that by creating the folders. Then there were files missing from the project. I found them and added them to the project. None of the generated files have any standard "using" clauses, so I add the required "using" clauses to the generated code. Now I'm stuck with build errors such as "Cannot implicitly convert type 'RakNet.Row' to 'RakNet.TableRow'" or "Cannot apply indexing with [] to an expression of type 'RakNet.SWIGTYPE_p_DataStructures__ListT_DataStructures__Table__Cell_p_t'"... the list goes on...

The above paragraph is actually from a gamedev.net post I wrote in desperation after having no success with RakNet. Luckily, my friend, axefrog, saw my post and put me onto lidgren, which I'd also seen during my searches before I settled on RakNet.

I took his advice and checked it out and the difference was like night and day. It required one tiny tweak to get it working (Bulldog is built on .net 4 and the latest lidgren assumes .net 4.5 or higher). I hit the internet for tutorials to write some test code. Unfortunately most lidgren tutorials are slightly out of date, leading to a weird corruption issue with status messages, but I sorted that out quickly. In an hour or so I was up and running with a decent message-based network system.

This represents a big change. It's very unlike me to rely on 3rd party components. I much prefer to write everything myself as I can fix bugs in my own code or add functionality I need. I felt vindicated by the difficulties I experienced with RakNet and was itching to go back to the roll your own method. The subtext of my gamedev.net post was that if I didn't get some decent suggestions I was going back to my own implementation.

In the end I'm glad I didn't, and I'm indebted to axefrog for putting me on the right path.  Cheers, mate!

Apr 14, 2015

Progress Update April 2015

This morning I fired up Mercurial and noted that my last check-in was 6 weeks ago. I'm kind of surprised, I expected it to be much longer. The last couple of months has seen my day job almost completely take over my life. Working on the weekends and out of hours meant there's been little time to even say "hi" to my family, let alone work on this side project. Fortunately, the crunch is now over, and I can go back to a more manageable schedule.

What has happened in the last 5 months? Early on I decided to completely rewrite my terrain generator to incorporate a long list of improvements, as well as finally get around to producing correct biomes.  The main project is currently using my 2nd generation Terrain generator from a few years ago, and this new one will be version 5. What happened to version 3 & 4? They were experiments that failed but ended up teaching me the techniques I've now honed in version 5. The new terrain generator is faster and produces much more interesting terrain than before, but so far I've failed to achieve the full objective of producing biomes.

An example of the terrain I'm currently creating. 

The rainfall map generated for the same terrain.

Part of the reason is due to the intrusion of my day job into my spare time as outlined at the beginning of the post. The second is that I'm in uncharted territory and there has been a great deal of trial and error. One of the key factors involved in biome assignment is rainfall, which is a fairly complex phenomenon. In the real world, it involves temperature, pressure, moisture, wind and is affected by the topography of the land itself.

However, I'm not trying to simulate a full on climate system, so I've taken a bunch of shortcuts. Like others, I've tried to seed the world with moisture, then introduce winds, and let them move the mositure around generating rainfall. Since this is a gross abstraction of what is really happening, the results are quite unpredictable, and its taken alot of tweaking and fine-tuning of the overall algorithm to achieve useful results. That said, its still not right. Some areas are completely bone dry, and others receive the equivalent of an olympic swimming pool of water every hour.

To add to the complexity, I decided to take into account seasons. In the real world, average wind patterns change with the seasons, leading to vastly varying rainfall. I wanted to achieve something akin to realistic conditions on earth. Eg, some places have about the same rainfall all year, others have a distinct wet season where the rains are torrential, whilst others receive very little rainfall all year round.

I said earlier that I failed at my objective to produce biomes. I decided to have a go at the terrain generation rewrite because I'd made good progress in the previous months re: updates and thought I needed to work on something a bit more experimental for a few weeks. That ballooned into several months, and its not even finished yet, so tangible progress on the main project is non-existent, because the new terrain generator isn't finished enough to make use of.

Time to knuckle down and finish.

Nov 23, 2014

Progress Update November 2014

Earlier this month I finally released my first development snapshot in over 14 months. It's kind of depressing that it took so long, and when objectively comparing the difference between the old snapshot and the new one, it almost seems like a step backwards, not forwards. The last 14 months has seen some extensive refatoring going on behind the scenes. I completely ripped out my old inheritance-based creature/item/etc classes and replaced it with an Entity Component System, which has taken a little bit to get used to it, but now it seems like its always been there!

In addition to that, I started switching the entire game project to Unity for a few months before deciding it was not for me. I also found it hard to dedicate any time to the project for many months, and time just slipped away so fast. I've remedied this in recent months and finally decided to polish what I had and show it off to my friends and work colleagues to get some feedback. I managed to get quite a few people involved who'd never seen it before, so the pressure to have progressed from the last snapshot wasn't really there. I got some great feedback that re-energised me and I've made great progress on the new snapshot, which has seen some exciting new features implemented, and some UX/UI improvements.

All in all, the experience was positive, and I'm keen to produce snapshots more often. By next post I hope to have some exciting news to share about the project as a whole. We'll see how that pans out.

Jul 24, 2014

Progress Update July 2014


I began work on Snapshot 10 at the start of June, and initially made some good progress. Once again I've come back to the issue of crafting. Crafting in some form or another has been in Bulldog for over a year now, but it has never really gotten past the proof-of-concept stage. One of June's tasks was to address the crafting situation once and for all.

I've made some pretty good progress and answered some of the lingering questions I wasn't sure about previously. As with most of my game design, I looked at other RPG user interfaces to see what they did, and try to come up with something that is intuitive, but suits my specific needs.

One of the inspirations for Bulldog is Minecraft, so the Minecraft crafting system was high on the list of candidates to examine. While I think the shape-based crafting is a really clever idea, it doesn't suit the style of play I have planned in Bulldog. Instead, I've opted for a 5-slot shapeless system. The choice of slot count is actually a fairly tricky one. If you have too few, then crafting recipes become a bit boring. If you have too many, then crafting becomes cumbersome, since you need to have access to all the different items at once, which takes up inventory space. Five is a happy medium between the two extremes I feel, but I'll see how it goes when I get to playtesting.

"Crafting" is actually made up of 4 sub-types. Assembly, Construction, Salvage and Processing. The line between the various types is actually blurred considerably in practice, so the player need not pay attention to the individual types when playing, but from the code point of view, they represent very different things.

Assembly

This is your typical crafting most players would be familiar with. You take a number of ingredients and create a single output. Eg, you might take a tree branch, a stone and some duct tape, and craft a stone axe with it.

Construction

This is similar to assembly, but it is for crafting larger items that are built directly in the world. For example, you might take a bunch of wooden logs, and a lot of stone, nails etc, and construct a small cabin. This also has the distinction that you would initially prepare the building site, as well as having the opportunity for others to contribute labour as well.

Salvage

Since Bulldog is a modern, semi-realistic post apocalyptic world, the player won't be mining ore, smelting it in a home made furnace and making iron ingots. However, the ruins of civilisation are everywhere, so Salvage is going to be a VERY important skill. This is the process of taking something and breaking it down it useful raw materials. Eg, taking a wooden pallet and breaking it apart with an axe (or sledgehammer) to produce some useful wooden planks (as well as some scrap). Later down the track this will also include careful disassembly of electronics and other technology.

Processing

Finally, we come to processing, which is basically anything that a machine, device or similar entity does to convert something into something else. For example, cooking a raw piece of meat on a campfire or stove, and producing a cooked piece of meat. These are generally passive tasks that the player can set and forget, whereas the other 3 are all active tasks, that require a direct investment of time and labour from the player.


As is usually the case with any expansions I need to make to the game engine, there was an unexpected hiccough. I planned to add a new type of slot control, which only allows references to entities in other slots. This sounds complicated, but is actually quite common in other games. Wherever you have a "HotBar" or "ActionBar" onto which you can drag items. The actual item is somewhere else, maybe the players inventory, or a spellbook etc, and the slot only stores a reference to the real entity.

A short time into attempting to implement that control I realised that half the drag and drop functionality that is specific to the existing slot control is hardcoded into my WindowManager class! This is *terrible* design. I don't know what I was thinking when I did that. It will be next to impossible to implement the new control without making things even worse. So, I had to take a step back and tidy up the existing implementation first.

The end result of this unexpected work (and a sudden loss of free time for several weeks) is that Snapshot 10 has gone way over time.  As of this writing, it isn't complete, and will require some serious effort to bring it in before the end of August, which is kind of piss poor, but I soldier on...

In non-coding news, I've been doing alot of design work on random parts of the game, and coming up with some interesting ideas for the backstory of the gameworld, which I hope to share as time goes by.

Now, if you'll excuse me I have to get back to coding...

May 26, 2014

Progress Update May 2014

The Entity/Component/System refactoring is officially over, and the new codebase is much better than the old one. I won't elaborate on the advantages here as I've already talked about that in previous posts.

The one remaining task I have on the ECS front is to overhaul the rendering system to make use of the new components. Currently the renderer is using a hybrid of the old and new and is pretty messy. I've had a task on my todo list to redesign part of the renderer to allow better control of the shaders, (which I'll need for graphical enhancements I have planned for the future), so it seemed easier to roll the two tasks into one.

The immediate future will feature more testing, and then preparation for Snapshot 10, which is due to kick off on June 1st. Snapshot 10's major new features will be allowing the player to rest/sleep, introduction of some proper crafting, and a bunch of content additions to round out the items a bit. It's exciting because it will finally be some forward progress again after almost a year of stagnation.

As part of my renewed commitment to the project, I'm going to try (once again) to be more forthcoming with updates, and try to coincide them with each snapshot I build. So, I'll be aiming for a once a month posting schedule, and try to include some screenshots of what's going on. We'll see I guess. :)

Apr 28, 2014

Recent developments.

There hasn't really been much to report in the time since my last blog post. I've been doing a long overdue major refactoring of the entire architecture of the game.

I'd originally developed Bulldog from an Object-Oriented approach, but ended up running into the Diamond Problem, where different classes needed common functionality but didn't have a common base type. I worked around the issue for many months and then stumbled onto the solution; the Entity/Component/System (ECS) pattern. I did alot of reading into how it works and realised that it was the perfect solution for all my issues.

I started converting the codebase to make use of ECS around a year ago, but only a short way into the work I had to put Bulldog on hold due to a reshuffling of my business interests (as mentioned in my previous post). At my new role I was put onto a fairly large project with a tight deadline, so finding spare time for Bulldog was difficult. Now that the project has matured, I'm finding I have more free time again, so in the last couple of months I've resumed the ECS conversion in earnest.

By my reckoning I'm about 75% of the way through the conversion, so there's a few weeks to go. The most frustrating thing about this type of work is that the end result is all under the hood, and not visible to anyone. If you were to compare the latest build to the build I did 12 months ago you'd be hard pressed to tell them apart. Such is the nature of architectural changes.

That said, I have some big things planned for the development of Bulldog in the second half of this year. None of which would have been possible without this architectural groundwork being re-established now. So yeah, stick with me on this... :)

Oct 8, 2013

The continuation of the project? Aka: Why so quiet?

It's been quite a few months since my last post. The last 7 months have been pretty busy times from a personal and business perspective. Though I haven't spoken much about my day job in my posts before, I feel it deserves a mention now.

For over three years myself and two other guys ran a software development business specialising in database-driven desktop applications. Running my own business allowed me to take half or whole days off each week to dedicate some quality time to Bulldog.  My take home pay suffered a little as a result, but the bills were getting paid, so it wasn't all that bad.

Not long after my last post in March, through a complicated series of circumstances, our biggest customer suggested we shut down the business and become permanent employees for them. After considering the situation we agreed and set about shutting down the business.

Let me tell you, it's pretty stressful and takes a lot longer than you'd think, especially since we still had to meet our previously agreed development deadlines. We started with them officially on the first of July, and have been pretty busy in our new roles ever since.

A welcome side-effect of the change is a much higher salary and not having to worry about all the busywork you have to do as a small business owner. An unwelcome side-effect of the change is that my work is very full on now and there's no room for work on Bulldog during work hours. Additionally, the work is more draining mentally than before and so when I get home the last thing I feel like doing is firing up Visual Studio again and coding for a few hours.

Despite these setbacks I don't regret my decision at all. My wife and I have another child on the way, so a higher paying job couldn't come at a better time.

So what's happening with Bulldog? Well, the good news is that I've managed some sporadic bursts of coding in the last few months, so the project is not dead. I'm determined to make something of this, so I'm going to continue chipping away where I can.

I've started to write another post which I'll clean up and submit sometime soon hopefully. It details some of the coding I've been doing recently which should take care of one of the most important aspects of the game, terrain generation.

Mar 9, 2013

Development milestone - 2 year mark

Byte Wrangler and the Bulldog project itself are now over 2 years old, hurrah!

So, where is the project? Is it playable yet? No. Why not? Because these things take time. No, that's not a good enough answer. Because I haven't prioritised the right development, and my original estimates for how long it would take were woefully naive. That said, looking back at the codebase from a year ago, the project has advanced a lot further than it seemed a few weeks ago. When you spend so much time so close to the code, you lose sight of all the changes that have built up in the system over the year. And over the last year, a lot of the changes have had a visual impact.

Compare the two screenshots below:

Bulldog Build 1863 - 37,557 lines of code (Jan 2012)

Bulldog Build 11020 - 62,894 lines of code (Feb 2013)

(Note: I added automated build number incrementing in late 2011, so the build number isn't a good indicator of the relative changes in the early days.)

For the statistically minded, the codebase is now 62,894 lines of code, compared to 37,557 a year ago. During the past year, I've done a great deal of refactoring, so large chunks of code have been removed, so the amount of code written is easily more.

A year ago there were no 3d models in the game, aside from the "monolith", which for a long time was the player character's temporary avatar. Now we have a more human shaped temporary avatar, and around 5 in-game 3d models. "Graphics month" failed to live up to its name, and really only introduced a few new graphics, but I did gain a working knowledge of Blender and UV unwrapping, so future modelling will now take much less time.

A year ago there were 13 different items in the game, none of which were usable. The player could walk around, but not interact with anything in the flat, featureless, sandbox world.

Now there are 43 different items in the world, 90% of which fully interact how you'd expect. i.e. you can pick up an empty water bottle and click on a pool of water to fill the bottle. Then you can click the filled bottle on yourself to take a drink.

The most visible graphical change (to me at least), is that I finally managed to get object silhouettes working. This is a feature I've had planned from the very beginning, and is important to the graphical look I want to achieve. I've struggled on and off to make this work, but I eventually had a breakthrough, and while not yet perfect, I'm very happy with the results. I may elaborate more on the specifics in a separate blog post.

Future Development

So, onwards to the future... I've found that it's easier to stay focussed on the tasks for a development snapshot if I give the snapshot a theme. The current snapshot's theme is food & crafting. I've already added 8 new food items to the game and implemented a food spoiling and food poisoning system. The crafting system is in place but needs to be properly tested and the crafting screen needs to be built, as well as adding crafting recipes.

The following build's theme is going to be sounds, shelter and improved terrain generation. Currently there is only one sound in the game, so the sound effects side of things needs a lot of love. I've also been experimenting with some new terrain generation techniques as a proof of concept, and initial work seems really good.

Closing Thoughts

It's easy to become disheartened about progress when your expectations are high and the project is large. I've come to realise that at the outset, my impression of how long it should take was quite naive, mostly due to inexperience. My current estimates suggest it'll be another 2-3 years before its ready for release, which sounds like a long time, but looking at the progress in the last year, I'm optimistic about how good it will look.

Oct 2, 2012

Terrain Features : Pools of Water


For most of August I was working on modifications to the terrain generator. Previously I had to generate the entire world at once, and it had to be square and a power of 2 in size. There also wasn't much leeway for modifying the output data. With the new changes I've made it can generate what I call a "world region", which is a n x m sized region of the world and it has the ability to run feature placement over the output before it gets turned into the final heightmap/tilemap. This also brings it closer to the eventual goal of being able to specify biomes and make use of temperature/moisture maps based on the surrounding sea and mountains.

Feature Placement


The first feature placement algorithm I've been working on is for pools of water. Since fresh water is second only to oxygen in urgency of need for survival, I need to give the player access to water in some fashion otherwise the game will be rather short.

When it comes to terrain generation there's two different approaches you can use. Teleological or ontogenetic. Those sound complicated, but it comes down to asking the question, is the terrain generated as the result of simulating real world processes or is it faked to look like it was?

An example of simulating using real world processes would be to generate a height map using a plate tectonics simulation, then apply many passes of thermal and water erosion algorithms over the result. Next, add water to the world and if sufficient water flows into a local minimum, you have a pool of water.  That's not even the whole story, to be realistic you should also model the permeability of the surrounding rock, the level of the water table, the rainfall for the surrounding area, and so on...

As you can imagine this is pretty complex, as the forces that shape terrain in the real world come about as a result of processes involving physics, chemistry, biology  and geology. The other thing to note is that the terrain all around us was generated over approximately 4.5 billion years, so creating realistic looking terrain through simulation typically takes a lot of iterations even if you take shortcuts.

Faking it


The alternative is to fake the terrain. The general approach is that you use algorithms that have nothing to do with simulating how real terrain is formed. For example, generating some perlin noise, applying a mask to shape the noise to give it the right shape and then smoothing the result using a gaussian blur etc.

I decided to take this approach, since I'm trying to write a game, not a geological simulation of the Earth.  Following the "fake it" approach, my pool placement algorithm looks something like this:


  1. Pick a random spot in the world.
  2. Determine if the area is suitable for a pool of water, ie not too steep. If not, jump back to 1.
  3. Generate a pool shaped terrain depth mask.
  4. Blend the depth mask with the existing heightmap to introduce a depression to the terrain.
  5. Calculate a suitable water level for the pool.
  6. Loop over the lowered terrain adding water where the depth is below the calculated water level.


There are complications will this approach which I won't delve into here at this time as I'm still refining the algorithm. I ran into quite a few problems that I didn't anticipate, such as how to blend the depth mask with the surrounding terrain so that it looks like it's supposed to be there, not just splatted over the top. My initial approach was to smooth the terrain then apply the mask as is, but it tended to produce a flat area that looked out of place.  In the end I came up with a blending approach that uses the distance from the pool as a blending coefficient such that terrain 5 tiles away from the pool uses the local height map and anything closer uses a blend of the two.

Selecting a suitable candidate site was also very important, as some terrain is completely unsuited to forming a pool, for example, if the site has too much of a slope.  Pools placed here tended to look absolutely terrible and often leaked their water out into the rest of the world as the pool edges were too thin.

The part which gave me the most trouble was designating which tiles should be water. The pool placement affects the height map directly, but the game tiles take their height from the surrounding 4 height map values, so I needed a way to determine which tiles are affected by the height map changes and should now be water. I tried a few different "smart" approaches that took advantage of knowledge of the original water mask but found the best solution was actually "dumb", using a flood fill to find the lowest point and then use a recursive fill to process neighbouring height map values. (Thanks to my colleague Ben for suggesting that one). It works like a charm, and has the added benefit of being able to called on the original height map to generate seas or oceans.


Figure 1: The player character enjoys a little swim.

As you can see in the above image, the water renderer is pretty much as basic as you can get. In the future I'd like to add reflections, ripples, specular highlights, waves and a bunch of other effects that help to sell the idea that its actually water, not a flat alpha blended plane. For now though, it will have to do.


Jul 18, 2012

July Progress Report

What's the latest happenings in the world of Bulldog? Well, lately I've been thinking alot about the big picture, such as all the cool features and mechanics I want to have in the end-game. Unfortunately these are likely to years away realistically, but I can't help dreaming.

In a more down to earth sense, I think it's way past time that I start posting screenshots and perhaps even short videos showing how things look. I've been loathe to show anything as I didn't consider it good enough to show, but I've resolved to at least try to put up some screenshots, so here goes:

The player character (placeholder model) standing amongst sand.

Zoomed out view of my test sandbox.

In the past few months I've been continuing work on fleshing out the mechanics of the game. Recently I overhauled my lighting system to handle the dynamic range from full noon sun to middle of the night, but still have appropriate detail visible in either. I also added in the ability to have local sources of light, such as that emitted from torches or explosions. Visibility at night is going to be an important mechanic, so the lighting model is really key to having that be believable.

This month I've been working on the ability to build structures in the game, such as campfires, which has taken alot longer than I expected given how I already had a job queuing system in place. A good deal of the work has been in making the system robust so the player doesn't randomly lose items if he cancels halfway through, or preventing the player from duplicating items through an exploit. I'm also working on a new font that looks a lot better than the previous one I showcased in my article on signed distance fields. I'm excited to see how it turns out in game.

May 10, 2012

Progress Report


In my last post I mentioned that February was going to be "Graphics Month". That turned out to be a bit of failure overall. ZBrush really wasn't the right tool for the job, but to cut a long story short, I once again looked at Blender and persevered with it long enough to get somewhere. I also found a few tutorials that really helped get me up to speed. I also found that making a cheat-sheet with all the common keyboard shortcuts was very handy, especially when coming back to it after a few days/weeks.

Most of the time I spent with Blender involved getting my head around UV-unwrapping, which isn't a trivial task, but absolutely necessary to have anything able to be textured. So far I've created only 2 small models, a rock (for terrain dressing purposes) and a campfire, but its a start.

In the past few months I've been tidying up the project quite a bit, disabling functionality that is only half finished, in an attempt to create a solid build so I can start passing it on to friends for feedback. My development schedule thus far has been fast and loose, whereby I'm not really developing towards a set of known goals, I just work on whatever interests me at the time. Unfortunately this has led to a the majority of features being only half finished, which is going to have to stop. So from here on I've started making feature lists for the next few monthly sprints, which has really helped focus my efforts in recent weeks. I've tentatively planned the next few months of development work, which I'd never really managed to do in advance.

One of the advantages of starting to show it around is obviously feedback, but also its forced me to care about the completeness of features. It's fine to leave something unfinished for development purposes, like say not handling some unusual edge case (with the idea of coming back to it and finishing it later), but once you start giving it out to people there's an expectation that everything works. 

Pre-Alpha 1 was a reasonable success, though I had some teething issues getting the deployment correct due to not really understanding SlimDX's installation requirements properly. So far the feedback has largely been related to the camera system which is one of the first things I coded, and suffered from a situation where the controls made perfect sense to me, but didn't necessarily reflect what others might try to do. Fortunately one of my alpha testers works in user interface / graphic design, so he'll hopefully point out all my mistakes before they become too deeply ingrained. :)

Jan 21, 2012

The next step


I wrote about missing my target date in my last post, but what recent development have I done in Bulldog?

Last week I developed a sound playing engine for the game, to finally give the world of Bulldog some sound. Currently the only sound it plays is when you click on Button Controls in the user interface, but it's a start.  In the future there will be ambience, such as wind or rain, or waves crashing on the shore, as well as creature sounds such as bird calls and eventually, music and perhaps even some voices.

In the past 3 months I've been spending alot of time trying to get the core mechanics of the game working. These are boring things like moving to a particular grid square, picking up an item, dropping an item etc. There's quite a bit of complexity in the interactions between the world and the user interface that caused a few nasty edge cases. I hadn't considered these when I originally coded the command/dispatch engine, which is responsible for executing creature's commands in the game.

For example, since there's a half second delay between issuing a drop command and the item leaving your inventory, in the initial, naive version, it was possible to queue up two drop commands on the same item, and cause the item to be duplicated, which is obviously a bad thing. Thinking in the manner of someone trying to exploit the system exposed a few other situations where this type of thing can occur, so I had to revise the way commands are executed in order to prevent problems like that, but I'm pretty sure I've got all my bases covered now.

Plans for the future?

February will officially be "graphics month", where I dedicate my development time to purely working on the graphics of the game. The key focus of this month will be drawing additional in-game art, such as icons for the items in game, but more importantly, 3D models for all the creatures and items. I've been putting off creating 3D models since I started the project, because it's not really my forte. I dabbled with 3d modelling way back when 3DS Max 1 was the latest thing, and haven't done anything since, so I pretty much have to learn 3D modelling from scratch using new software, so it's not something Ive been looking forward to.

I'm doing everything for this project legit, so I can't simply pirate the latest 3DS Max and just go for it. That said, 3DS max is far too expensive for me to afford for this project. While I've managed to use some of the tools and resources my company already owns, (such as Adobe Illustrator and Photoshop), 3D modelling is something my business has no need for, so justifying the $3,500 outlay to my business partners (and myself) is impossible. Similarly, from a personal perspective I can't afford it either.

I've looked at free alternatives, but haven't found one that doesn't have an enormous learning curve and weird esoteric commands. It annoys me that Autodesk don't sell a cut down (and cheaper) version of 3Ds Max that just has features like 3d modelling and UV unwrapping, and no fancy stuff like caustics, cloth simulations or fluid dynamics. Hell, the app doesn't even need a proper renderer. They did provide a version that was designed for games people specifically, called Gmax, but that was discontinued in 2005 and only saves the models into a proprietary format that is useless to me.

All that said, I recently looked at ZBrush, which is held in high esteem by a lot of people, and was shocked to discover it costs only $700, which is well within my price range. So I've got the 30-day trial sitting on my laptop and plan to evaluate it shortly.

Beyond February?

In the short term I want to get something demo-able to friends and family, and the graphics is the only thing holding me back at the moment. If all goes well, I hope to iterate a few times on the demo, adding more complete features and making changes based on feedback, and then start working on Phase 2 and the eventual proper release, which I'm VERY excited about. My plan is for everything up until the proper release to be available for free, and then charge something like $15 for the commercial release, which will entitle you to all additional content and features added from then on for free (and there will be a lot of them).

While it seems pretty popular with indy developers at the moment to fund development with preorders, I don't think I could justify this. In terms of what the customer would actually get, and the fact that I have a full time job so don't need the preorder money to survive, so at this stage that's not part of my plans.

Jan 8, 2012

Byte Wrangler is 1 year old!


I started this programming blog a year ago and its time to look back at what I've accomplished over the last year, and see if I'm on track.

The first thing to note is that there isn't anything available for download. In my second post on this blog I suggested I wanted to have something available for download at the end of 2011. That was my plan throughout the year and it seemed achievable until about August when I re-assessed where I was up to and realised I was well short of where I needed to be.  Rather than lament the slippage of the deadline it's worthwhile looking at what went wrong and learning from the experience.

As far as I can tell I made 3 main mistakes, which I'll discuss in more detail below:

Mistake 1: Underestimating how long it would take to get certain parts of the system working.

This is the big one, and probably caused nearly 6 months of slippage.  Since I decided I would use SlimDX and develop everything from scratch and not use an existing games engine, I started with nothing. I accepted this, but overlooked the fact that meant I had no user interface system to work with at all. That means no buttons, no textboxes, no labels, no scrollbars etc. Even designing a simple settings screen requires many different interface controls, and if you want to implement something more complex like an inventory screen with drag and drop etc, you're talking quite a bit of coding to develop the whole lot.

And just when I thought I'd implemented every control I'd need, I would think of another major one I'd forgotten. As if developing the user input side wassn't enough, I also needed a skinning/texturing system that allowed the controls to size dynamically as required and not have visual artifacts or ugly stretching when resizing.

On the plus side, over the past year I've implemented a windowing system and the following interface controls:

  • Window
  • Button
  • Checkbox
  • Context Menu 
  • Label
  • Image
  • Message Box
  • Progress Bar
  • Scroll Bar
  • Text Box
  • Tool Tip

There are a few additional controls on the wishlist, but they won't be needed until later and shouldn't take as long as getting this framework up and running.

Mistake 2: Overestimating how much free time I had over the entire year.

This one is hard to judge, as 2011 turned out to be fairly tumultous from a family standpoint, and since I'm developing this game in my spare time, work, family and sleep pretty much come first, and Bulldog lost out more times than I would have liked. Not much can be done about this moving forward as life is unpredictable, but I should adjust my estimates in the future to assume I have less free time.

Mistake 3: Spending too much time researching and developing unnecessary features.

This one was avoidable, and was caused by becoming sick of coding "boring" features and wanting to implement some cool stuff. Like for example, I spent a good 6 weeks developing the signed distance field font system, when I had an ok (albeit ugly) font system already in place. The end result is about 10x better in terms of flexibility and visual look, but that time might have been better spent working on essential features. At the same time though, the distance field stuff was a lot of fun to work on, and was very rewarding at the end of the day.

It's hard to stay focussed on the boring stuff, when there's so much unnecessary fun stuff. But since the fun stuff keeps you motivated, you have to deviate from the schedule sometimes.

Where to from here?

So I guess the question is, how much has actually been done, and what's the current plan / deadline? Since that will be a reasonably large post in itself, I'll leave that to my next post. Stay tuned.


Aug 5, 2011

Quick Update

I haven't posted anything in a while, but progress on Bulldog continues (albeit slowly). My day job has been pretty intense over the last month in terms of workload, so I've not had much time of late to actually code anything significant. I've been focussing on higher level concepts like fleshing out the way character creation will integrate with the initial origin scenario, which at this stage I think is coming together nicely.

Jun 1, 2011

Bitmap Fonts

While I haven't written anything about Bulldog in the last 6 weeks. I definitely haven't been idle in the coding/design department.

Following on from my last post about the icon graphics, I've drawn about 15 additional icons for in-game objects. I've also started to put together the user interface, with displays for the player's Health, Energy, Water and Morale stats. I've written alot of additional behind the scenes systems that help hold everything together, but aren't really that interesting in terms of function, so haven't bothered to talk about them in the blog.

However, this past weekend I tackled a feature I've had on the TODO list for quite some time : creating a better font rendering engine. The standard font routines available in SlimDX (or DirectX for that matter) are terrible in both performance and functionality.

The usual way of overcoming this is to produce a bitmap representation of a font at a specific size and then create a system that generates quads for every letter in the text you want to render and apply the individual letter bitmaps to the quads for rendering. I've seen this approach go wrong in some commercial AAA games and produce horrible artifacts at the edge of letters where they've partially overlapped without proper blending, so I decided to try a slightly different approach.

Rather than have a quad for every letter, I create a single big quad for the entire text, and then generate a bitmap of the text to be displayed in memory by placing the letter bitmaps in the appropriate positions, then slap that bitmap onto the quad for rendering. There's some overhead to constructing the text bitmap, but it only needs to be generated once (unless the text changes), and from then on its a single large quad with a texture, which should be much faster than 100's of small quads.

To test the font engine, I created a bitmap font with a hand-drawn appearance, so that it has a comic-like quality to it, but still is quite readable and the letter forms are consistent. The font itself was drawn in Illustrator, then output as a high resolution bitmap, which I then downsampled in Photoshop.

A screenshot from Adobe Illustrator showing the curves used to create the letter shapes.

Creating my own font means it should match in better with the overall graphic style of the game, than if I used a very clean font like Arial. The image below shows the completed font at 22 pixel resolution, which I've called "Olivia22".

The finished "Olivia22" font.

Throwing together the bitmap font engine and drawing the font didn't actually take as long as I thought. The font took about 8 hours to do all 95 glyphs, and the font engine was about the same. The part I was surprised about was how long it took to setup the kerning information for the font.


Kerning

Kerning is the process of adjusting the space between letters in a word to make the characters sit together in an aesthetically pleasing manner. Unless you're involved in graphic design it may not be apparent that a process like kerning is even required. Kerning is typically done with pairs of letters. A "kerning pair" defines the gap between two particular letters, and at render time each letter pair is checked against the list of kerning pairs and the second letter is offset left or right by the appropriate amount.

For overhanging letters such as "W" or "V", kerning is particularly important, especially when paired with letters like "A", or any of the curvy lower case letters, such as "o", "c" or "a". So for my font to "read well" I had to create kerning pairs for problem combinations of letters. The process took many hours of adjusting values, running the program against a reference text and inspecting each word individually. Over the course of 6 hours I put together close to 500 kerning pairs and just about had my eyeballs fall out of their sockets.

The image below is part of the rendered reference text, showing the kerned version of the font. (This is actually from a work in progress, so I've since tweaked some of the pairs to be better).

A crop of part of the rendered reference text


Even after so much work the result is far from perfect. The biggest limitation with the way I've implemented the font renderer is that the smallest distance a letter can be moved left or right is an entire pixel. In many situations, the "correct kerning" is a movement of less than a pixel, so the space can never be correct for that particularly instance. This is less of a problem with larger font sizes, but with the 22 pixel high font I've created, the kerning values are within the range of +3 to -3, which is pretty small, and leads to some compromise.

In an ideal world the font renderer would use the original vector graphics as the source for the letters, and create its own anti-aliased versions at whatever size is required, however I can't be bothered creating such a thing at this stage, especially when I'm trying to hit an end of year deadline. Perhaps in the future?

Another thing which has become apparent is that my process of kerning is time consuming and fiddly. My plan is to create another 3 or so variations on the current font, (ie different sizes and normal/bold versions). If its going to be 6 hours of kerning for every one of those I'll go insane. So I've come up with an improved workflow for kerning that should shave hours off the time.

The current workflow involves setting the kerning values in the font's data file, running the test code that takes the reference text and produces an output png of the rendered text, loading the png in photoshop and looking over the entire text to spot problems and then repeating the entire process.

The improved workflow relies on me getting the TextBox control working, and adding the ability to tweak the kerning per character pair directly in the text using the cursor keys. This should greatly speed up the process, as the kerning changes will be visible immediately, and without having to load the output in an external application.

Apr 14, 2011

Progress Report - Some graphics!

I've been doing a lot of behind the scenes work in the last few weeks, but progress has been a bit slow due to my time being taken up by other factors. The windowing system is good enough now that I shouldn't need to mess with it for quite some time, which is good as I need to concentrate on gameplay related features.

Recently I've been looking at the inventory screen and how the player interacts with items and objects in the world. To this end, I spent some time putting together some better graphics for the inventory screen, (previously I had dodgy placeholders). The visual style of Bulldog is something I've been thinking about for quite some time, and I think I've settled on a look that I'm happy with:


The 2D images above are intended for use in the inventory screen. In the game world itself the plan is to use 3d models shaded in such a way that they take on a similar appearance.

The visual look is heavily based on the style I developed for my web comic, Asleep at the wheel. I haven't posted a new comic in almost two years due to becoming a first-time father. Before the baby came along it was taking me several days to put together a weekly comic and pretty much any random event would disrupt the process enough that the comic would be late, so it simply wasn't going to happen with a newborn added to the mix.

I'm keen to get Bulldog to a good enough state to be able to show off some screenshots some time soon, but there's still a lot that needs to be done before I can do anything like that. These simple in-game icons are a step in the right direction though.

Mar 14, 2011

The Bigger Picture

It's overdue for me to talk about the "bigger picture" of what Bulldog is supposed to be, so in this post I'll hopefully begin to shed light on what I have in store.

Ambition
Bulldog is a very ambitious project. It may not seem that way based on what I've discussed so far in the blog, but my long term plan for Bulldog is grand in scope. It may take 5 years for me to fully realise what I have in mind, but the project is somewhat modular, and can be broken down into more manageable milestones.

As mentioned in previous posts I plan to have a release out by the end of the year. Beyond that I plan to release new content and upgrade the game at regular intervals, slowly building Bulldog to where I want it to be. This strategy is pretty much essential to have any chance of success, as I am doing this project in my spare time and if I decided to not release anything until its "perfect", there would never be a release. Something (albeit flawed) is better than nothing.

In terms of what genre Bulldog falls into, the best I can come up with is open world survival RPG. Open world is perhaps not the exactly right definition, it's more akin to how Minecraft or Dwarf Fortress generate new worlds and don't force a specific storyline on the player. Perhaps "open-ended" is more accurate, but I haven't really heard that term used when describing this sort of game. The key thing here is that the player drives the story through their actions (or inactions) rather than by completing a series of quests or puzzles in sequence and then getting a nice ending cut-scene.

Survival is the ultimate goal. There will be many variations to achieving this goal. To some players survival will mean exploring the gameworld, scavenging supplies, fighting off threats, amassing wealth and levelling up.

To others it will mean building up a thriving community, rebuilding civilisation and having to content with "the greater good", rather than just yourself.

Origin Scenarios
A key feature I'm planning for Bulldog is the ability to select a specific survival scenario when you start a new game which will define and shape the generated game world. This will hopefully allow more re-playability, as well as allow more options for the player to customise their survival experience.

The different origin scenarios will have a impact the game quite differently. For example, in a zombie outbreak scenario, you'll be fighting off hordes of the undead in a messed up but relatively intact world. There will be plenty of stuff to scavenge, but there will also be danger lurking around every corner, and you don't even want to contemplate what will happen if you don't get back to camp before dark.

In contrast, consider a post nuclear war scenario where most major cities will have been completely obliterated and entire areas will be uninhabitable due to radiation. Nuclear winter may have set in and food and drinkable water will be scarce, weather effects such as dust storms and intense thunderstorms will batter your settlements and destroy anything the nukes left standing.

The origin scenario I'm planning to include in the end of year release is a Desert Island, similar to the situation in the movie "Castaway", starring Tom Hanks. You've washed up on a desert island with a bunch of random stuff and have to survive. I chose that scenario for the simple reason that the player can be contained within a finite space as opposed to the practically infinite dynamic world generation I have planned for the final version. Getting that sort of terrain generation working correctly is going to be a major challenge, and I'd rather start with something simpler, such as a desert island.

An interesting point that people may not realise is that "desert island" doesn't actually imply the archetypal small  pile of sand with a single palm tree. The "desert" part of the phrase doesn't even imply an arid, desert-like climate. It actually comes from the word "deserted", literally meaning there isn't anyone else around.

Feb 15, 2011

Development Schedule and Bad Lists.

As I mentioned in a previous post I hope to have something releasable by the end of the year. In order for that to happen I've had to cut features.

These features aren't lost forever, they have simply been moved from the "essential list" to the "wish list". As the name suggests, the essential items are absolutely required for Bulldog to be playable, whereas the wishlist items are all the cool and interesting features that I want to include to make Bulldog stand out and be fun to play, but will delay the first releaseable version.

My plan from day one has been to release as early as possible and then release updates as time goes by, rather than work in isolation for 5 years and try to suddenly release something amazing. I'm hoping that the first release will show enough promise and get people sufficiently interested in what I'm trying to achieve in the long term, that I can build up a community around Bulldog, which will help guide the development and let me know what works and doesn't. Well, that's the plan at least. :)

Since the wishlist items are a long way off, I'll ignore them for now and focus on the "essential" list, which looks as follows:

//TODO: Inventory Screen / Management
//TODO: Food & Water
//TODO: Danger.. ie Mobs
//TODO: Title Screen
//TODO: Save/Load World & Zones - partially implemented.
//TODO: Character Models
//TODO: items spawning + management
//TODO: Item Models/graphics
//TODO: Windowing System
//TODO: Picking System
//TODO: Ability to move character
//TODO: Ability to issue orders
//TODO: Ability to attack stuff
//TODO: Ability to loot stuff
//TODO: Mobs models
//TODO: Mobs AI

It doesn't look like many items, but each of those items actually has many subitems that need to happen before they can be completed. For example, the first entry about the inventory screen will require that I complete the windowing system, then design and build the inventory screen, implement the ability to drag and drop items into containers, come up with and design in-game items, and design the graphics for the icons being used.

Interestingly, I just noticed that since I wrote that list over two months ago I haven't been able to cross any items off the list. I've actually made progress on Bulldog, but on supporting tasks, which aren't captured in that list.

I've been told that you're more likely to be motivated to complete a list of tasks if you can see some tangible progress on the list. The idea is that you take a big task and break it down into more manageable sub tasks, which you can tick off and feel good about your progress.  So for example, you're more likely to finish cleaning your house if the task list has items such as "vaccuum the floor", "wash the windows", "do the dishes", etc.. than just "clean the entire house".

So its pretty obvious to me now that the list above is a bad list. Not just bad for motivation, but also bad for tracking progress on the project overall. If I wanted to estimate my overall progress and come up with percentage complete figure, I pretty much have to take a guess based on what I've done. I can't actually use any of what is still left to be done to help guide my estimate, as the list is woefully vague in the actual details. The end result is likely to be a false impression of how much work is left and may lead to schedule slip.

So I think my next task is to go away and break down the list into more manageable tasks, which will also serve the purpose of forcing me to think about and define what each of those tasks actually entails.

Feb 1, 2011

Procedural Texture Generation

As I mentioned in the introductory post, Bulldog is going to feature procedural content. This will cover things like terrain, random encounters and even textures.

At present, the only procedural content I've built for Bulldog is a texture generator class which generates textures from pre-defined templates. These templates specify a series of operations performed sequentially to produce the desired output. At present it is fairly naive and produces rudimentary results, but I hope to improve the texture generator's capabilities over time with more advanced synthesis techniques.

I've found that RGB is not a particularly good colour system for texture modelling, as you rarely want to adjust the redness, blueness or greenness of a particular pixel. You're more likely to want to adjust the brightness or other parameters. So I use the HSL colour system, which consists of Hue, Saturation and Luminance. This allows me to adjust the texture in a much more "natural" way. 

As an example of how the texture generation process works, consider a sand texture. Sand is a granular solid made up of tiny bits of rock. The grains are vaguely uniform in size, but vary in colour. I've modelled this in my texture generator by taking a sand-like base colour, then applying random noise to each pixel to adjust the hue, saturation and brightness accordingly. The image below shows the different parts that are generated by the texture generator class and combined to form the final texture.


Uniform vs Gaussian noise

The random noise function I used in the examples above is called Gaussian Noise. This is noise where the probability distribution follows the "normal" distribution. To generate Gaussian Noise, you need a random number generator that will produce random numbers that are biased in such a way that they follow the normal distribution, rather than a uniform distribution.

The random number generator in .net (found in System.Random), is typical of most random number functions found in modern languages in that it returns random numbers with a uniform probability distribution. This means that each value in the output range chosen has equal probability of being output. If you were to graph the probability of each value in the range appearing, the result would pretty much be a horizontal line.

The "normal" probability distribution on the other hand, has a symmetric, bell-shaped curve. Values around the mean have a higher probability of being output, and values at the very edges of the range have a much lower probability. I won't go into any more depth on the topic, for further reading look at something like
this wikipedia article.

Below are two examples of noise generated using Uniform and Gaussian Noise:

Uniform NoiseGaussian Noise

At first glance it appears as though the uniform noise has a wider range, as it has significantly darker and lighter pixels than the gaussian noise. However, if you look closely at the Gaussian noise you can see that there are some pixels that are quite dark, and some that are quite light, however the majority are somewhere in between, ie, clustered around the mean value. Gaussian noise is a closer match for real-world applications, as the normal distribution appears very frequently in the real world.

For those that are interested, to generate the Gaussian random numbers I wrote a random number generator based on the Box-Muller Transform. It uses a standard uniform probability distribution random number generator and then remaps the values so the output has the normal distribution. The actual implementation I chose uses the Marsaglia Polar Method, which eliminates the need for the sin() and cos() functions.

An interesting quirk with this algorithm is that it needs 2 independent uniform random numbers to actually work, but the output is 2 independent normally distributed random numbers, so in my implementation I actually cache the second value and return that without the need for computation on the second call.

Jan 24, 2011

Bulldog

"Bulldog" is the codename I've given to the game project I'll be discussing in this blog.

My policy is to use codenames for software projects. Not to obfuscate the intention behind the project, but to provide a name other than "unnamed game project" when talking to other people about it. I frequently have many ideas on the go at once, so I use codenames. For games, I use breeds of dog. For other applications I use suburbs of Adelaide.

I won't go into heavy details of what Bulldog is meant to be at this stage, as some of the elements will change over time, However I can say:

  • The main concept behind the game will be survival in a post-disaster setting. 
  • The game world and content will be procedurally generated, and the gameplay will be 3rd Person, with a tile-based isometric view. 
  • Currently thinking it will be single player only, but depending on interest I may make it multiplayer at a later date.
  • It is being coded in C# using the SlimDX framework, targetting DirectX 9 and Shader Model 2.0.

I'll reveal more of the details as I get further through the development.

My current plan is to have a working version available for download by the end of 2011. I'm hoping it will happen sooner than that, but I'm taking the pessimistic approach with regard to my available time.