Category: Game Programming

Game Coding Complete, Third Edition

After I mentioned Mike McShaffry’s Game Coding Complete in an earlier post, a lot of people were complaining that the only copies they could get were used ones for $100 or more.

Well, despair no longer! Not only is the book available again, it’s in a spiffy new edition. This time, Mr. Mike has collaborated with other programmer/writers on various subjects. It’s almost like an edition of Game Programming Gems, but it covers game engine creation from the ground up.

And Amazon currently has it for less than $40.

If only I weren’t completely broke…


iNaria

Because two people demanded it!

Yes, it’s true. My new current project is Inaria for the iPhone. I was greatly encouraged to do this by my good friend Ryan Clark, who has just been incredibly supportive during my entire time of trouble. He even lent me the Mac that I’ll be doing the development on. (And that I’m currently posting from.)

Porting it to the iPhone probably won’t take long; the hardest part will be making sure the new interface works well (and finding some music and sound effects I can use with the game). I will be adding some extra content – new maps and a much better leveling system. I hope to have the project done by the end of May.

And now I finally have something to blog about on this blog again!


Embracing the Bottom

I recently read two very different and excellent articles on independent game development.

The first was from Owen Goss of Streaming Color Studios, in which he detailed the sales figures (so far) of his iPhone game Dapple.  He expressed frustration with the fact that although Dapple cost $32,000 to make, it has only made $535.19 in its first available month.

The second was from Jeff Vogel of Spiderweb Software in which he detailed the sales figures (so far) of his PC/Mac game Geneforge 4.  Geneforge 4 cost $120,000 to make and after six months has only made back $111,412.

Neither of those sound very good, but Jeff is actually pretty happy with how Geneforge 4 is selling (although he admits that these sales are unexceptional).  Within another month or two at most, Geneforge 4 will have made back its costs and everything it makes from then on will be sweet, sweet, gravy.

So what’s the difference?  I think the difference is that (despite his protests to the contrary) Owen was hoping to strike it rich in the iPhone gold rush.  As soon as his app fell off the front page of the Apple Store his sales dropped to near zero, and getting articles about his game on Kotaku and Slashdot generated exactly 21 new sales.

Owen’s claim in his follow-up post that he desires to build a software company slowly over time doesn’t really match up with the type of game he made.  While Dapple is a clever little game (especially the two-player mode) it looks very generic – because it is.  It’s a color-matching game.  There are tons of color-matching games available for every conceivable platform.  The gaming industry is awash in them.  You simply cannot stand out in that genre, especially if you’re an indie.

Jeff has chosen a different route.  He makes turn-based, single-player RPGs.  This is a market that the big game companies aren’t serving sufficiently.  The lack of cutting-edge graphics has never hurt his sales – indeed, it makes his games very older-hardware/laptop friendly.  He has found an underserved market and intends to keep serving it until it goes away…which, since Jeff’s been in business for fifteen years now, it doesn’t look like it’s ever going to do.

Jeff also understood that when he chose to take this path, he would have to be in it for the long haul.  It’s taken six months for Geneforge 4 to make its costs back, but now every time it sells (and it will sell, for years) it’s gravy for Jeff.  And since he now has fifteen games out there, each one selling away, his overall income is high enough that he can make a living.  In his inimitably cynical style, he calls this “bottom feeding”.

Now, Jeff got lucky, true.  He found a market that he loved but wasn’t being served.  He finished his first game and started selling it just as the internet was getting started.  His development cycle (make a game in eight months, then spend two porting it to the PC) allows him to make a ton of games – at least one new one every year.  And the games outsell their costs, leading to profit.

But it can still be done nowadays – indeed, it can probably be done easier, because when Jeff started he was having to advertise his games on bulletin boards and over AOL.  There are plenty of underserved markets out there.  You can still stand out, make your mark, and make your money.

You just can’t do it with a color-matching game, which is what Owen found out.  I truly do wish him better luck next time.


Badonkadonk.

I must travel to Sweden and drink of the water there, because there is obviously something in it. After finishing up HouseGlobe the OxEye guys had a couple days left, so they whipped out a demake of Fallout called Fillauth.

Here’s a video of their map editor in action:

At this point, I’m betting on demonic powers. It’s demonic powers, right guys? Come on, spill it, your secret is safe with me.

On a similar topic, I’d like to thank Jeb from the OxEye Games Forums for taking the time to answer some of my multiplayer programming questions.

And, you know, now that I think about it, it might be a good idea to link to all the submissions for the Demake Competition, since I’ve talked so much about it. Jeez, you’d think I didn’t know how to run a website.


I Hate the Internet

Why? Because it keeps showing me stuff like this…

If that game looks oddly familiar, it should. It was made for the TIGSource Demake Competition, which is all about taking a game and “demaking” it for an earlier platform. Thus, Silent Hill 2 for the PS2 becomes Soundless Mountain II for the NES…

Portal for the PC becomes SUPER 3D PORTALS 6 for the Atari 2600…

And Homeworld for the PC becomes HouseGlobe, for 256 color VGA…

HouseGlobe in particular is very impressive. It’s got silk-smooth two-player multiplayer over the internet or a LAN, and despite a small tech tree and number of units supports several different strategies of play. It’s a great little 2D RTS, and the guys who made it pumped it out…in ten days.

That’s why I hate the internet. It keeps showing me how much I suck. At some point, you know, I thought I’d become a developer who could make pretty cool stuff pretty quickly. But that somehow has never happened. Frankly I wonder why I’m still employed.

(EDIT: The Demake competition was hosted at TIGSource, not Retro Remakes. Oops.)


You Should Call Me Mario

Because I just got one-upped. I thought writing a game in one page of source was good, but the last time I tried to write an RPG in one page of source, I concluded that it probably wasn’t possible.

But now the Temple of the Roguelike is having an ongoing competition for people to write Roguelikes in one kilobyte of source; that’s less than one-fourth the size of a one-page game. Most of the entries so far have been pretty simplistic, but now a true challenger has emerged, called A Journey to Hell.

Here’s the complete source code (compiled on Linux using GCC and curses):


#include <curses.h>
#define W(c)while(c)
#define F(v,h)for(v=0;v<h;v++)
#define D(i)F(y,S)F(x,T){i;}
#define G d[x][y]
#define M d[x+f][y+g]
#define Z(n)n<0?-1:(n>0?1:0)
#define r rand()
int x,y,S=24,T=60,c,d[90][90],L=1,b,k[]=L"$`*$.@?$?>",f,g,z,h,i,l=9,p=20,e=46,
v,u=96;m(f,g){G-64?M-64||(l-=G-u)>0||(M=e):(M^62||L++&&(L^7?N():(G=e)),M^u||(p
+=L,M=e),M^42||(l=p,M=e),M^36||(v+=x%9*L+L,M=e),M^63||(M=r%6?k[r&1]:97+L),M>u&
&--M);M-e?M-35||(g&&m(f,0),f&&m(0,g)):(M=G|256,G=e);}E(t){W(d[x=r%T][y=r%S]-e)
;G=t;}N(){D(G=35)x=y=9;F(b,S){f=r%58+1;g=r%22+1;W(f^x||g^y){G=e,r&1?(x+=Z(f-x)
):(y+=Z(g-y));}}F(b,10)E(k[b]);F(b,L*2)E(98+r%L);}main(){srand(initscr());
raw();start_color();F(c,8)init_pair(c,c,0);N();W(c-81){D(G-64||(f=x,g=y))
clear();D(b=1;W(G^k[b]&&b<7)b++;h=x;i=y;c=0;W(c++<u)(d[f+(z=(h-f)*c*.01)][g+(z
=(i-g)*c*.01)]-35)||(b=0);b&&mvaddch(y,x,G|COLOR_PAIR(b)))mvprintw(S,0,"HP:%d/
%d L:%d $%d %s",l,p,L,v,L^7?"":"WIN");c=getch();D(G>u&&G<123&&m(Z(f-x),Z(g-y))
)D(c<49||c>57||G-64||m((c-1)%3-1,1-(c-49)/3))D(G&=255)}endwin();}

Here’s a screenshot.

In this screenshot, the purple ‘@’ is the player (of course). The yellow ‘$’ represents money on the ground. The blue-green ‘?’ represents a chest. The white ‘b’ is a monster; the letter of the monster represents how hard it is to kill, from a (weakest) to z (flee in terror). The red quote mark represents a soul left behind by a monster I just killed; picking this up raises my maximum hit points.

Here’s what that 1K of source gets you:

* Guaranteed traversable levels
* Line-of-sight on the player
* Colored graphics
* Combat with monsters
* Ability to pick up gold and souls (dropped by defeated monsters; powers player up)
* Chests (which can contain gold, a monster or a soul)
* Ability to go down the stairs (generates a new level with tougher monsters)
* Win condition (beat the seventh level to win the game)

Of course his platform gives him a couple of advantages. My library to write colored graphics to the screen and poll the keyboard and mouse under Windows takes up almost 1K of code by itself; the curses library is much more space efficient. Also, GCC supports “default int” on both functions and parameters, meaning that Jakub can declare a function as “m(f,g)” and GCC will assume that ‘m’ is a function that takes two integer parameters, f and g, and returns an int itself. Visual C++ 2005 will not allow such shenanigans (though 2003 was not as strict).

Still, it’s an incredible amount of stuff for less code than it takes to initialize DirectX. I can only imagine what the author, Jakub Wasilewski, could do with the unending expanse a full page of source would provide him.


Planitia Update 30: MULTIPLAYER GET!

That’s right. After weeks of work and a near-full engine rewrite I have multiplayer working in Planitia. Now, right now everything has to be hardcoded – number of clients, the IP addresses, everything. So I can’t release a demo yet. I’ll need to at least bang in some code so that clients and servers can find each other on a LAN before I do.

I’m just terribly, terribly excited. I did a ton of research for this (and of course I’ll be Writing An Article) and it paid off tremendously – everything is working exactly like I expected it would once the system was implemented.

Now, that’s not to say it’s perfect. The system is updating an average of six times a second, which means that right now units jump across the map and there’s a bit of lag between clicking a button and having something happen in the world. Both of these can be made to look better with interpolation and prediction, though they don’t actually change how the game plays.

If you guys want to get a leg up on finding out how I did the multiplayer, you can read the following articles:

For making your engine multiplayer ready:
Instant Replay: Building a Game Engine with Reproducible Behavior

For implementing network multiplayer in an RTS:

1500 Archers on a 28.8: Network Programming in Age of Empires and Beyond
“Real-Time Strategy Network Protocol”, Game Programming Gems 3 page 496 or Best of Game Programming Gems page 459, by Jan Svarovsky

Teehee! I’m so excited!

Oh, and the next installment of Let’s Play Starflight will be delayed a day. For some reason.


“Ben There, Dan That!” and the Supremacy of Community

So two froody dudes, Dan “Gibbage” Marshall and Ben Ward, decide to stop piddling about with their own pathetic projects and team up, creating Size Five Games (previously Zombie Cow Studios) in the process.

And to celebrate, they decided to give away a game for free – an adventure game called Ben There, Dan That!, which stars…um, them. That’s right, you control Ben and Dan as they bumble through a loving homage to the classic Lucasarts Adventure games, doing things like smacking priests with bibles, visiting alternate dimensions, and…um…climbing out of a cow’s rear end. Hey, they’re British.

Now, even given the fact that they used Adventure Game Studio to create the game, that’s a heck of a lot of work to just give away. But I heartily, heartily approve of the process, and not just because I’m cheap. I think it’s the right thing to do because it helps them grow their community, and I believe that community is the solution to all of gaming’s problems.

Does your game stink? Get people interested in the potential your game might have and they can help you fix it. And you don’t have to do it all before you ship. Feedback after you ship is just as vital – but those lines of communication must be open.

Are you having trouble marketing your game? Again, community can help. Bungie‘s testers sang the praises of Myth: The Fallen Lords to all their friends once their NDAs were lifted, which helped Bungie as they took their first steps into the PC market.

Are you having trouble keeping people interested in your game? Once again, community to the rescue. The most popular online first-person shooter in the world is still Counter-Strike, which kept copies of the original Half-Life on store shelves for years. The incredible response of the Korean community means that you can still walk into a Wal-Mart and buy a copy of StarCraft – a game that was released in 1998! Caravel Games goes even farther with their Deadly Rooms of Death series. The DRoD games consist of a layout of rooms, each containing a puzzle. The DRoD website gives you an overall map of the game – and clicking any room on the map takes you to a forum thread discussing that room. It’s an excellent way to provide player-based support, in addition to player-created content.

Are you having trouble funding your game? Yes, this is the iffiest one, but it’s been done. Lots of people have started by creating a small, well-supported game and then rolling the profits from that into something much larger. I think my favorite story of this nature is that of Jeff Minter, who was saved from having to get a real job by the incredible response to Llamatron, which Minter released for free along with a README.TXT file that included this paragraph:

Here’s the deal. You play Llamatron and check out the hook. If it gets you (and I reckon it will if you like mayhem), then send us a fiver and, as a reward for being so honest, we will send you an ace poster of our gun-toting llama, a newsletter, and a complete copy of Andes Attack, originally released in 1988 to considerable critical acclaim. Two games for a fiver – can’t be bad. And if the response is good, there will be more Shareware. And better.

This is the kind of thing Jeff Vogel is talking about when he says, “Shareware is a force for good.”

And finally, the big one.

Are you having trouble with people pirating your game?

Well, of course you are. People pirate stuff. They’re going to do it. You can’t do much about it.

If you want to come to terms with piracy, you need to come to understand that you’re not trying to eliminate it. You’re trying to reduce its impact to the point where you can still make the money you need to make on your game to stay in business. I wish I could tell you to just ignore piracy but I can’t – you should be going onto those download sites and demanding that they remove your game, because you do want pirating your game to be more complicated than just doing a Google search.

How can community help here?

Well, it’s harder to steal from somebody when you feel like you know them personally. It’s also harder to steal from somebody when they are trying to be the good guys.

The seminal example of using community to beat piracy is Stardock’s Galactic Civilizations 2. Absolutely no anti-piracy stuff on the disc. No CD key. No CD check. No phoning home. No refusing to run if there’s a compiler on the same system. No installing low-level drivers that monitor all data traffic without the user’s knowledge. Nothing. The only thing it uses is a unique account key that allows you to create a support account on Stardock’s digital distribution network, so that you can redownload the game if you lose your discs.

And yet it sold a bazillion copies and was a huge moneymaker for Stardock. And as I’ve mentioned before, one of those copies was sold to me. Even though I’ll never have time to play such an involved game. Why did I buy it? Because they were doing it right.

I have said that game design is a conversation between the developer and the player. But now I’ve come to realize that the metagame of game development is the same thing.

If you want to succeed in game development, don’t just make games. Help people have fun. And that means getting personally involved, with all the risks that carries.


What My Friends Are Doing

Yes, it’s another “while you are waiting” post. Deal.

I’ve got a couple friends here at work whose websites are definitely worth checking out.

First, Patrick Rogers. He’s an avid Go player who recently hit traffic gold on his site by being the first person to post the complete lyrics to all three episodes of Dr. Horrible.

Second, Brandon “Rusty” Parks. Rusty’s a real character, as you’ll be able to tell when he starts talking about how the universe has a discrete pixel size and a discrete frame rate.

Third, Bobby Thurman…who I actually don’t work with any more and probably should keep in better contact with.

And finally, you know those people who keep coming into game development forums or IRC channels and ask how to program an MMORPG? Yeah, laugh at them. Go ahead. Because everybody knows that nobody can possibly write an indie MMORPG. And oddly enough, it’s being worked on by all three of the gentlemen I detailed above! What are the odds?!


Powermonger Map File Format

This post is mostly for Arkiruthis/Mrthingy, but if the rest of you want to read it, feel free!

All of the map data for Powermonger is contained in the MAPDATA.DAT file. This file is 65,268 bytes long and contains 196 Powermonger maps. It’s broken down into:

* One header that is 196 bytes long. It’s possible this header was going to flag certain maps as being certain types, but since all of the entries are zeroes it probably wasn’t used.

* One hundred and ninety-six map files that are each 332 bytes long.

While I have not figured out everything each byte in a map file represents, I’ve figured out a lot. Here’s the map file for the third level (I picked this one because it’s more interesting than the first two). I’ve grouped the bytes into groups of four because…well, you’ll see.

First off, here’s a cleaned-up version of how the minimap for the third level looks:

The first 40 lines (160 bytes) contain data I haven’t identified yet, but I can say that most of these lines are exactly the same in all files.

   0    10   0  32
   0   250   0   0
   0    10   0  15
   0     7   0   2
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0    21   0  48
   0   250   0   4
   0    10   0  20
   0     7   0   2
   0     0   0   0
   0     6   0   0
   0     0   0   0
   0     0   0   0
   0    15   0  32
   0   250   0   8
   0    10   0  20
   0     7   0   2
   3     0 208   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0    10   0  32
   1    14   0   1
   0    10   0  15
   0     7   0   2
   3   212   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0    10   0  32
   1    24   0   2
   0    10   0  10
   0     7   0   2
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0

Now things get interesting. The first three bytes of line 41 contain the values that are passed into the terrain generation algorithm. Altering them alters the terrain of the map. The last byte is apparently passed into the forest-creating algorithm, since changing it changes the forests without changing the underlying terrain.

   2    97  18   0

The first byte on line 42 (in this case, 0) is also apparently fed into the forest algorithm.

The second byte on line 42 (in this case, 6) appears to set the upper Z limit – raising and lowering this value makes the terrain hillier or flatter without altering the shape of the terrain on the map.

The fourth byte (32) is an X-coordinate offset. It won’t change the shape of the terrain, but it will move the entire terrain mass left or right on the map. The terrain mass will wrap around if necessary.

   0     6   0  32

The second byte on line 43 (48) is, you guessed it, the Y offset. It will move the entire terrain mass up or down on the map, wrapping around as necessary.

The fourth byte on line 43 (3) is apparently a terrain smoothing factor. Setting this value low causes the terrain to get very jagged; setting it high causes the terrain to smooth out until there’s nothing left.

   0    48   0   3

Now we can FINALLY stop guessing, because from line 44 until the end of the file, each four-byte group encodes one “object” that is dropped on top of the terrain after generation. The four bytes represent the X-coordinate, Y-coordinate, team of the object and finally the object type. The X and Y coordinates correspond perfectly to what pixel that object is in on the minimap (which is why I was able to figure these out).

The player’s team is team 1; all higher numbers refer to computer-controlled teams. Unfortunately I do not know what all the codes mean yet because I haven’t been able to access maps that use those objects. Here are the object codes I do know:

1 – Road Endpoint
2 – Tiny Village
3 – Medium Village
5 – Large Village
16 – Tower
17 – Road Segment

You will always see a “1 16” pair (a tower belonging to Player 1) in the list. This designates where the player starts.

  52    24   1  16  - Tower belonging to Team 1 at 52, 24
  14    65   2  16  - Tower belonging to Team 2 at 14, 65
  17    41   3   3  - Medium village belonging to Team 3 at 17, 41
  41    66   3   3  - Medium village belonging to Team 3 at 41, 66
  44    99   2   5  - Large village belonging to Team 2 at 44, 99
  35    78   3   3  - Medium village belonging to Team 3 at 35, 78
  54    77   3   3  - Medium village belonging to Team 3 at 54, 77
   8    77   3   3  - Medium village belonging to Team 3 at 8, 77
  41    66   1  17  - Road segment belonging to Team 1
  54    77   1  17  - Road segment belonging to Team 1
  55    91   1  17  - Road segment belonging to Team 1
  44    95   1  17  - Road segment belonging to Team 1
  37    90   1  17  - Road segment belonging to Team 1
  35    78   1   1  - Road segment belonging to Team 1
  35    85   1  17  - Road segment belonging to Team 1
  26    94   1  17  - Road segment belonging to Team 1
  22    94   1  17  - Road segment belonging to Team 1
  19    86   1  17  - Road segment belonging to Team 1
  16    75   1  17  - Road segment belonging to Team 1
  11    72   1  17  - Road segment belonging to Team 1
   8    77   1   1  - Road segment belonging to Team 1
  48    40   3   3  - Medium village belonging to Team 3 at 48, 40
  26    52   3   3  - Medium village belonging to Team 3 at 26, 52
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0
   0     0   0   0

Notes:

Yes, the road segments belong to team 1 (the players’ team). I’m not sure why.

You can easily beat any Powermonger map by finding the data for that map in MAPDATA.DAT and changing all the villages to belong to team 1. Next time you load that map you’ll be instantly declared the winner.

When the terrain generator drops these objects on the map, it creates terrain underneath them if there isn’t already some.

And finally, here is the source for the program that can scan the original MAPDATA.DAT and split out the map files.

And now as a special bonus! These are some notes I took about how the village simulation in Powermonger works. They are kind of rough, so I present them as-is 🙂

Notes on Powermonger:

Powermonger allows the two triangles in a cell to be different terrain types. Thus, you can have half be beach and the other water, half be farmland and the other mountain, etc.

Speaking of farmland, it’s not marked on the map, but all the clear, flat tiles (or half-tiles) around a village is considered farmland.

By the same token, all the water that is at least one square from a beach is considered “fishable”.

While there are only two official “jobs” (farmer and fisher) there appear to be five things a walker can do in Powermonger:

Gather food from a farm (this REQUIRES the job “Farmer”).

Gather food from the ocean (this REQUIRES the job “Fisher”).

Gather wood (no specific job required).

Bring a sheep back to the village center (no specific job required).

Defend themselves when attacked (no specific job required).

(Units also make things, but since that is all handled internally there is absolutely no way to tell what unit made what and why or how they chose to make that particular thing.)

Farming and fishing cannot happen during the winter. Walkers usually gather wood or make things in the winter. If a walker has no supported job, he simply stands in the center of the town.

Hard to tell how often units “eat”, but it appears they consume 2 food every time they do.

When walkers encounter sheep (which is pretty random, since the sheep walk around randomly and the walker must get near the sheep in the course of doing another job), they bring the sheep back to the center of town. It APPEARS that as long as the sheep is near the center of town, the village gets a constant low food income. But the sheep will continue to wander off, and thus will have to be brought back again.

Towns cannot die off. Ever. If you take all the walkers from a village and the last walker is about to starve, then five men from your army will leave your army, become walkers, and rejoin the village.