Archive

Posts Tagged ‘2D Animation’

2D Platform Games Part 7: Player Character Animation

January 28, 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.

IMPORTANT! From Part 6 onwards, compatibility with Windows Vista in the pre-compiled EXEs has been dropped. To run the pre-compiled EXEs, 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 6: Creating Platforms and Geometry the Player can be Inside (Ladders, Ropes and Water). 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.

Figure 1. A sprite sheet of our player. This is a 160x160 sprite containing 4 rows of 20x40 player sprites at 8 columns each. The first row of sprites represents the player walking left, the second row represents the player walking right, sprites 1-3 on the third row represent the player jumping left, sprites 4-6 on the third row represent the player jumping right, and the fourth row represents the player climbing up or down a ladder.

Figure 1. A sprite sheet of our player. This is a 160×160 sprite containing 4 rows of 20×40 player sprites at 8 columns each. The first row of sprites represents the player walking left, the second row represents the player walking right, sprites 1-3 on the third row represent the player jumping left, sprites 4-6 on the third row represent the player jumping right, and the fourth row represents the player climbing up or down a ladder.

After the trauma of player physics, collision detection and surface dynamics it’s probably a good time to take a little breather and tackle a less vexing subject, that of animating your player. We shall look at how to animate the player as they walk left and right along a normal platform or slope, when they jump, and when they climb or descend a ladder. This covers all the types of animation we need so far in our project, and gives a flavour of the maths involved which should make it easy to adapt to new animations as and when you need them.

Read more…

%d bloggers like this: