About

I'm a software engineer who works on game development part time. I teach game development (on gamedev.stackexchange.com and lynda.com). I'm always working on something, and I'll post updates here. Let me know if there's a game development topic you want to know more about, I probably know the answer, or at least where to get one.

Saturday, August 27, 2011

Progress Update


I’ve been spending my time on two areas lately: the engine and unit tasks. 
The engine:
Vertex/fragment shaders mostly. These have helped a lot. Primarily with the slice feature. Age of Goblins does chunking with its terrain. Before the shader, these chunks were 64x1x64. Each chunk was 1 cube tall. That made it really easy to “slice” through them. I’d just not draw chunks above the “slice level”. Additionally I have some code that creates what I call “void caps”. This is a special layer that hides all the cubes the player hasn’t discovered yet, as well as the void that’s left when you start cutting through geometry. Of course this came at a performance cost. I needed considerably more chunks to fill the same volume when they’re only 1 cube tall.
Now the shader comes along. With a little bit of GLSL code in the fragment shader:
if(WorldPos.y > maxY)
    discard;
I can get rid of all the geometry above a specific height. Now I can use whatever chunk height I want! This sped things up quite a bit. Luckily I’ve kept all my code nice enough that I only had to change the y chunk size constant and everything still works. 
Elsewhere in shader land I’ve been tinkering with some lighting effects that should give the landscape a bit more depth. A sort of “lighting rig”. Still needs some more tweaking and testing with different conditions. Finally, I’m in the middle of working out how I’m going to do some vertex displacement to recreate the smoother cubes on the graphics card (as seen here).

Unit tasks:
Building off my previous work of giving units a main goal and sub goals. I’ve implemented a goal stack. This allows me to give units higher level goals, and not have to walk them through each little task along the way. The goal stack works something like this:
while(!CurrentGoal.NeedsToStartAreMet())
    TaskStack.Push(CurrentGoal)
    CurrentGoal = CurrentGoal.GetSecondaryGoal()
In the end, you’re left with a list of tasks, in order, that need to get done before the main goal can be started. To put this into an in game example, the situation could be that I’ve just ordered a goblin to place a rock cube at position xyz. The goblin doesn’t have a cube like that in their backpack, but there is one in a storage bin near by. So before the goblin even moves their goal stack would look like this:
  1. Go to storage bin     <— top of stack
  2. Pickup rock cube
  3. Go to position xyz
  4. Place rock cube
Clearly there’s some more work in creating that list, like finding the nearest available rock cube. But that’s all taken care of by the goblin as well (with a little help from the world item finder).
Pretty neat! To help test this out I implemented in-world objects. So when goblins are clearing away cubes, once their backpacks are full, they’ll just leave the cube (in item form) on the ground. This is similar to Dwarf Fortress (sans the backpacks) and Minecraft (much larger backpacks). Of course (as usual) the in game representation of this is just a little colored dash, since I haven’t gotten around to implementing the pretty graphics for it :). 

Sunday, August 21, 2011

LD21 - Escape Innerspace!


I’ve finished my game for Ludum Dare 21: Escape Innerspace. It’s loosely based on the classic movie “InnerSpace”.  I could be happier with it, but I’m fairly proud that I finished a complete game on my first attempt.
Overall I enjoyed the experience. I’ll probably compete again in future events.
Some things I learned:
  • I write hacky/crummy code when under a time constraint.
  • Drawing out a story board before creating an animation sequence helps a lot.
  • Sound effects are fairly easy to implement using Slick and lwjgl (that should come in handy for Age of Goblins later on)
  • I should have a better overall plan of attack before starting on small projects like this (I had a vague idea for a game, then just started coding, I should have flushed out the idea more, it would have helped picking my underlying data structures)
Working in 2D was fun. I also really liked making maps by hand. The map for Escape InnerSpace used pixels of specific colors to specify spawn points and passable terrain. That made things easy. That being said, I’m excited to get back to working in 3D on Age of Goblins. I’m writing some shaders that hopefully will do some cool things I’ve been wanting. 
Escape Innerspace: Source code: https://bitbucket.org/byte56/ld21

Don’t judge me by that source code :)

Tuesday, August 2, 2011

Few things


This week has been productive so far. Monday night and tonight (Tuesday night) I’ve implemented:
  • Building placement - Detects valid placements for buildings. Buildings can be rotated. Buildings in general still need a lot of work, this is just the placement portion. Since I don’t have 3D models made for the buildings, the space they would take up just gets filled with brick cubes :) Can you tell I’m putting off art related work? 





  • Camera orbit / follow - instead of just “strafing” the camera left and right, it can now “orbit”. The camera just finds the cube that’s in the center of the window and uses that as the pivot point for rotating around. Subsequently the code I wrote for this is reused to look at any point in the world. This could be used for a tutorial or jumping the camera to points of interest, like stinking dwarf attacks.
  • 3D cube selection - Sketch-up style! Select a region of cubes, then you can click and drag that region up, down, left, right, whatever. Pull the selection out into the sky to make a selection for adding cubes, creating a wall or tower. Or pull it into the ground to create selection for removing cubes, creating a tunnel or shaft. This is actually pretty fun to use. I was using it to select some cubes on top of one hill, and dragging that out to create a bridge to another hill top. This feature still needs some work, but it’s off to a great start. (That green blob is the unit, you may recognize it from my first video, usually they’re blue. When doing a task the units change to the color of the task, it’s for debugging, so I know they’re doing their work).

  • And a few other little things that were on my “ever growing, never shrinking” to-do list.
  • Lastly, I updated the blog :p
Feels good to be productive.