Archive

Posts Tagged ‘Animation’

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 4: Moving Platforms and Crush Detection

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 3: Scrolling and Parallax Backgrounds. 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.

It’s common for platform games to feature platforms which move from side to side, up and down, or both. While a moving platform is nothing more than a static platform which has its position adjusted each frame, it presents some special problems with respect to handling the player. In this article, we will learn:

  • How to add arbitrary movement to platforms of our choice
  • How to make the player move relative to the platform’s position when standing on it (so that the motion of the player follows the motion of the platform)
  • How to detect whether the player has been squashed or crushed Read more…

Tetris Revisited: Adding 2D Animations and Other Graphical Tweaks

October 12, 2012 1 comment

It’s game coding time with SimpleTetris again and this time we’re going to look at how to add a variety of different animations and useful graphical tweaks which can equally be applied to any game or demo.

We will create a simple animation class in C++ which takes care of tracking the position and timing of basic animations, and learn how to apply this to make changes in an object’s position, colour and alpha (transparency). We will examine how to use this class to animate several objects at different points in the path of a single animation, how to affect two paremeters of an object (eg. position and transparency) with a single animation function, and how to partly randomize the intermediate steps (interpolation) of an animation.

Although we are again using Simple2D here (and as such this article serves a tutorial on how to use it, and how SimpleTetris is evolving), the algorithms and principles can be mostly copy/pasted and are easily adaptable to other graphics libraries. The animation class works independently of Simple2D and does not depend on it.

Download: Source code (.cpp) | Source code (.h) | Executable

Read more…

%d bloggers like this: