Post-mortem of Robo-Trix 2041

Theme

I spent all of Friday night trying to come up with a concept I liked. I looked through lists of game genres, lists of good games, lists of best games in a genre. A lot of lists.

Some discarded ideas:

  • Tower Defense + Virtual Pet
  • Side-scrolling shooter + Trivia game
  • Psychedelic western

The main problem was that none of these were fun. They would certainly satisfy the theme, but I don't think I could stay motivated working on something I didn't want to play. So I stopped focusing so much on the "incompatible" part of the theme and that made things a little easier. But by that time, I had wasted all of Friday evening.

On Saturday morning, I settled on Tetris + Robotron 2084. It's not something I had seen before. It doesn't immediately sound compatible, but as you think about it (the blocks are rotating and that can shoot in multiple directions) it makes more sense. Plus, it combines two games that I enjoy, but have never tried to replicate.

inspiration.png

Collisions

When creating the movement system, I wanted to make sure the block always stayed in line with the grid, so the game object can only move in increments of one space at a time. This is easy enough; I just set the position directly.

As a consequence of this though, I could no longer use any of the physics stuff built into Unity, since the game object is not moving to a new space, it is being teleported there. So I had to manually handle collisions with the border of the screen and any blocks already placed on the grid.

This took longer than I would have thought. I had a system that I thought made sense, but I kept running into strange behavior and occasional index out of range errors. I wondered if I had a loop that was off by one somewhere or something. But it turned out to be more insidious.

Floating point math sucks

It turns out that 1 != 1.00001. I knew that this was a thing in Unity, but I guess I never needed anything to be terribly precise before. Once I realized that was the problem, I sprinkled a lot of Mathf.RoundToInt() around and wrote a simple helper function to convert float-based Vector3 to the new int-based Vector3.

Vector3Int FloatVectorToIntVector(Vector3 v)
{
    int x = Mathf.RoundToInt(v.x);
    int y = Mathf.RoundToInt(v.y);
    int z = Mathf.RoundToInt(v.z);
    return new Vector3Int(x, y, z);
}

Two Tetris Grids

Once I got the basics of Tetris functioning, I didn't like how much empty space there was. I thought about expanding the grid to cover more space, but it looks like Tetris has historically had a pretty consistent grid size. Every (official) Tetris game seems to stick with a 10 column x 20 row grid, so I didn't want to break that tradition. My compromise was the use two grids that you could move between.

From there, it made sense to have each of them offer different rewards when you complete a line. This is probably the most clever bit of game design in the project and it was completely unintentional. You can't stay in the health grid and rack up extra lives, because you'd run out of ammo and you can't rack up ammo because you'll run out of lives, so you constantly need to balance those resources.

DualGrid.gif

Look and Sound

I used Paint.net to create all of the art (aside from the borders which are just the Unity line renderer). I'm not really artistically-inclined, so the shapes had to be pretty basic, but that worked well with the game.

I was heavily inspired by the sound design of Robotron. The lack of music is hidden by the constant barrage of sound effects. I don't think I quite made it to that level, but I like most of the sounds I ended up with. I used by sfxr and bfxr to make them.

Enemies

I think I'm gonna write a separate post about the enemies and waves, since I like the way it turned out. It was a bit more flexible than it really needed to be for a game jam, but that flexibility allowed me to easily re-balance the difficulty at the 11th hour.

Known Issues

  • The starting blocks will sometimes contain a complete line. These are just built randomly, so that's gonna happen sometimes. Enjoy the extra life/ammo.
  • I'm pretty certain line clears sometimes happen when the line is complete. Haven't tracked down this bug yet. Seems very intermittent.
  • Getting to the top of the grid might crash the game.

Next steps

If I had more time (or I didn't waste all of Friday), I would have worked on these features next:

  • Score/Stats system
  • Showing the next piece
  • Diagonal shooting