Archive

Posts Tagged ‘Game Development Walkthroughs’

Tetris: Adding gamepad support

August 30, 2013 7 comments

In this article, we will look at how to add gamepad support to a game using our Tetris clone as an example.

Simple2D 1.11 includes gamepad support using XInput – the new replacement for DirectInput in DirectX 11 – and makes it ridiculously easy to add support to existing games as we shall see here. If you would rather code everything yourself and want the nitty gritty, check out my 2-part mini-series XInput Tutorial: Adding gamepad support to your Windows game for the low-level details.

Download (SimpleTetris 1.5): Source code | Executable

Read more…

Tetris: Adding polish with music, sound effects, backgrounds, game options, an intro sequence and other tweaks

March 15, 2013 2 comments

Our previous version of SimpleTetris is working quite well as a single-player game, but lacks the professional touch. In this article, we’ll look at:

  • how to make pausing and unpausing the game also pause and unpause all of its subsystems
  • how to add music and sound effects and tie them into game events with SimpleFMOD (a library developed in another series on this web site which uses the well-known FMOD SoundSystem to produce audio – see the first part of the FMOD series for more information on how to use FMOD)
  • how to make an event-triggered throw-away animation using Simple2D
  • how to use bitmap images (sprites) as animated backgrounds
  • how to add game options which can be loaded and saved
  • how to add an intro sequence and a credits page

Most of these changes can be slotted in without any changes to the game logic, but there are a few gotchas and some little tweaks we can apply to make things better. I’ll note these below.

Download (SimpleTetris 1.41): Source code | Executable

For comparison, also have on hand the executable for the previous version of the game (SimpleTetris 1.31).

I strongly recommend that you run both versions and do a side-by-side comparison of the behaviour while working through the sections below, then hopefully the changes described will make sense more easily. Read more…

2D Platform Games Part 10: Improved Level Management and Storage

February 6, 2013 4 comments

IMPORTANT! To run the pre-compiled EXEs in this article, you must have Windows 7 Service Pack 1 with Platform Update for Windows 7 installed, or Windows 8.

This article builds upon the demo project created in 2D Platform Games Part 9: Storing Levels in Files / Level Editors. Start with 2D Platform Games Part 1: Collision Detection for Dummies if you just stumbled upon this page at random!

Download source code and compiled EXE for the code in this article as well as the complete source code and compiled EXE for the level editor.

In Part 9 we looked at how to store and retrieve game levels from files in a format that could be used both by the game itself and by an auxiliary level editor application. In this article we will make things a little more robust and usable with some improvements:

  1. Allow the game to load the specified level as a command-line argument
  2. Re-factor all of the level data into a single class so it can be version-controlled and remove duplicate variable declarations in the game and level editor
  3. Add functions to the Platform class to create platforms from the GeometryDefinitions stored in the level files, neatening things up by making them more object-oriented and removing duplicate code from the game and level editor

Let’s get cracking!
Read more…

2D Platform Games Part 5: Surface Dynamics (slippery and sticky platforms)

January 21, 2013 4 comments

IMPORTANT! All of the articles in this series require you to have either Visual Studio 2010 or the Visual C++ 2010 Redistributable Package (4.8MB) installed in order to be able to try the pre-compiled EXEs provided with the examples. The Redistributable Package can be freely bundled with your own applications.

This article builds upon the demo project created in 2D Platform Games Part 4: Moving Platforms and Crush Detection. Start with 2D Platform Games Part 1: Collision Detection for Dummies if you just stumbled upon this page at random!

Download source code and compiled EXE for the code in this article.

So far we’ve covered static platforms and moving platforms and provided accurate collision detection for each. We’ve also started to create a framework which lets us configure the behavioral properties of individual platforms. This puts us in a good position to introduce new types of platforms, like the classic ‘slippery ice’ and ‘sticky’ platforms which are the examples I shall show below. These types of platforms which merely change the movement physics of the player don’t require any changes to the collision detection system, whereas ladders and pass-through platforms (where you can jump onto them from below but are solid on top) do, so we defer these to subsequent articles. Read more…

2D Platform Games Part 1: Collision Detection for Dummies

January 18, 2013 44 comments

IMPORTANT! All of the articles in this series require you to have either Visual Studio 2010 or the Visual C++ 2010 Redistributable Package (4.8MB) installed in order to be able to try the pre-compiled EXEs provided with the examples. The Redistributable Package can be freely bundled with your own applications.

Try the demo! This article will teach you how to write the following sample project from start to finish: 2D collision detection demo (use the left and right arrow keys to move and the space bar to jump)

Since the one-day game coding challenges of SimpleTetris and SimpleAsteroids, several people asked me if I could do a timed challenge to make a Mario or Donkey Kong-style platform game. For shame, I haven’t had chance to do this yet, but while I’ve been thinking about that I thought it might be nice to look at how collision detection works, as this is surely the trickiest part of coding a 2D platform game.

Now, let’s not beat about the bush: collision detection is a nightmare when done right. There are many types of 2D platform game, from strictly grid-based to Mario-style platformers where collision detection is simplified by limiting the game world to using certain specific types of platform at certain specific slope angles, all the way to modern games like LittleBigPlanet where the world is completely free-form with arbitrary platform geometry.

There are some brilliant articles on 2D collision detection on the net and I have linked to my favourites at the end of this article. The important thing that they have in common is they are either quite theoretical, use a certain degree of non-trivial math to get the job done or do not have complete source code available for free (and the best ones are written in Flash / ActionScript or Java anyway, not C++). Here I would like to present a practical, hands-on approach to 2D collision detection, developing a complete example in C++ from start to finish. We will look at the various problems that crop up and how to solve them. Read more…

Cutting Your Teeth on FMOD Part 4: Frequency Analysis, Graphic Equalizer, Beat Detection and BPM Estimation

January 16, 2013 36 comments

In this article, we shall look at how to do a frequency analysis of a playing song in FMOD and learn how to use this as the basis for a variety of useful applications.

What is frequency analysis?

Note: The SimpleFMOD library contains all of the source code and pre-compiled executables for the examples in this series.

Frequency analysis is where we take some playing audio and identify the volume level of each range of frequencies being played. In a simple example, this lets us identify the current volume of the bass, mid-range and treble in a song individually, or any other desired range of frequencies. Read more…

Cutting Your Teeth on FMOD Part 3: Embedding Sounds In Your Application as Resources

January 15, 2013 13 comments

Having all of your sounds and music as separate files in your application is messy, and makes abuse by mischievous souls slightly easier. To tidy things up, we can embed audio files directly into the compiled EXE file. FMOD provides the ability to load audio directly from memory, so the problem has two main steps: 1. embed the audio resources in your application, 2. modify the application code to load resources from memory (your application process) instead of from files.

Note: The SimpleFMOD library contains all of the source code and pre-compiled executables for the examples in this series.
Read more…

Cutting Your Teeth on FMOD Part 2: Channel Groups

January 15, 2013 9 comments

If you’ve been following Part 1 of this series you should now be able to play music and sound effects with FMOD in your applications, pause and unpause them and change their volumes. But what about when you have many sounds whose parameters – like volume and pause state – you want to be able to control universally via a single change without iterating over them all? This is where channel groups come in.

Note: The SimpleFMOD library contains all of the source code and pre-compiled executables for the examples in this series.
Read more…

%d bloggers like this: