top of page

3D Touhou

  • Nicky Flello
  • Oct 4, 2015
  • 2 min read

This is a 2D bullet hell game that is based off the Touhou series. The player must dodge the countless bullets that appear on the screen. The purpose of the project was to explore polymorphism and to play with three-dimensional patterns in two-dimensional space.

Polymorphism

One goal I had with project was to make as many things polymorphic as I could so that the main code could be very generic. I know that polymorphic function calls are slower and too many can lead to cache misses, but that wasn't the point. I wanted to make everything polymorphic, and this was a great learning experience. Things that were polymorphic included bullets, spells, items, stages, and characters (players, enemies, and bosses). My main update loop ended up just looking like this:

mStage->Update(); mPlayer->Update(); mStage->CheckCollision();

// Then check for game state transition

Interestingly, I used the template method design pattern without knowing what it was. My spell class had two different functions for activating. One was public, and one was private. The public function is the one that is called on a spell, and in that function the private version is called. The public function is not virtual, whereas each spell implements its own method of activation. The public function is just a way to initialize some variables that would be the same for all spells. This is one way to reduce duplicate code.

Optimizations

Looking back, there are a lot of things I could have done to optimize this game. At the time I was still learning basic C++ concepts, so I didn't know a lot about optimizations. The first optimization I would add is a collision grid. With so many bullets and possible collisions, a collision grid would greatly improve performance. This is when, every update, all bullets are set to one of the possible square of the screen. Afterwards, bullets are grabbed from the grid tiles around the player, and only those are checked for collision.

Another optimization I would add is support for loading a texture atlas. This way all sprites could be loaded from a single file, and then sprite batching would be much more efficient. This is something I've implemented into my Midi Game.


Comments


Featured Posts
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
  • White Facebook Icon
  • White LinkedIn Icon
bottom of page