background preloader

Algebra

Facebook Twitter

The guide to implementing 2D platformers. Having previously been disappointed by the information available on the topic, this is my attempt at categorizing different ways to implement 2D platform games, list their strengths and weaknesses, and discuss some implementation details.

The guide to implementing 2D platformers

The long-term goal is to make this an exhaustive and comprehensible guide to the implementation of 2D platform games. If you have any sort of feedback, correction, request, or addition – please leave it in the comments! Disclaimer: some of the information presented here comes from reverse engineering the behavior of the game, not from its code or programmers. It’s possible that they are not ACTUALLY implemented in this way, and merely behave in an equivalent way.

Also note that tile sizes are for the game logic, graphical tiles might be of a different size. I can think of four major ways in which a platform game can be implemented. Type #1: Tile-based (pure) Character movement is limited to tiles, so you can never stand halfway between two tiles. Slopes. Higher-Order Fun. This is the long due fifth article in this series.

Higher-Order Fun

If you aren’t comfortable with vectors, you might want to take a look at the first four articles in this series before: Introduction, Vectors 101, Geometrical Representation of Vectors, Operations on Vectors. This cheat sheet will list several common geometrical problems found in games, and how to solve them with vector math. Complete list of basic vector operations But first, a little review. For this, I assume that you have a vector class readily available. Strictly speaking, a point is not a vector – but a vector can be used to represent the distance from the origin (0, 0) to the point, and so, it is perfectly reasonable to just use vectors to represent positions as if they were points. I expect the class to give you access to each of the components, and to the following operations (using C++ style notation, including operator overloading – but it should be easy to translate to any other language of your choice).

Case #02 – Alignment. Linear algebra for game developers ~ part 1. When I posted about decals last week, a number of readers commented that they would be interested in posts about linear algebra as it applies to game development.

Linear algebra for game developers ~ part 1

I decided if I'm going to write about that, I might as well start at the beginning! This will be review to many of you who have written games before or taken classes in kinematic physics, so please bear with me for this introductory post -- I will get to more advanced topics later. Why do we care about linear algebra? Linear algebra is the study of vectors. If your game involves the position of an on-screen button, the direction of a camera, or the velocity of a race car, you will have to use vectors. What is a vector? In games, vectors are used to store positions, directions, and velocities. The position vector indicates that the man is standing two meters east of the origin, and one meter north. As you can see, a vector by itself is just a set of numbers -- it is only given meaning by its context. Vector addition Next time.