Lachlan's misadventures in games programming

Sunday, 29 May 2011

Lachlan's Adventures into C++

5/29/2011 10:53:00 am Posted by Lachlan No comments
So far, I've really finished only two basic things in the Space Invaders clone. Firstly, I can display an arbitrarily long series of images, each for a certain time, each skippable or not. This provides the way to show logos etc. This will be reusable, and is reasonably general so if more complex then it needed to be. Secondly, the menu screen completely works, and plays sounds as you select items with Keyboard or Mouse. Like the first thing, it can show an arbitrary amount of menu items, put anywhere on the screen. This also involved writing a basic sound manager which associates sounds with a string, and can play them using SDL_Mixer. So - it can work thusly:

  1. //Load the sound
  2. Sound::Instance()->AddSound("Shoot", "\\data\\sounds\\shoot.wav");
  3. //Play the sound
  4. Sound::Instance()->PlaySound("Shoot");

Each subsequent reference only needs the PlaySound command. The Sound class manages the WAV files, and deallocates them at the end of the program.

These have, whilst sounding trivial in the scheme of making a playable game, taught me some things I will need to know, and provided code and classes that I will use in the game proper. So far, I have learned to use:

  • Sound in SDL
  • std::map
  • std::vector
  • The singleton pattern
  • Putting types in classes
Now, I'm up to programming some actual gameplay. I sense that the std::map and std::vector containers are going to prove helpful

0 comments:

Post a Comment