Game programming essentials like the maths for graphics and AI
Collision detection: Irregular polygons (Asteroids) using the crossing number algorithm
Testing for collision with an irregular polygon is the exact same problem as if you were doing collision detection for an Asteroids game clone. If you don’t know what Asteroids is you can learn about it here. As this helps us visualize the problem I will present this whole tutorial in those terms. This collision […]
Collision detection: Neighbour checking
This method allows us to only check objects that are in the approximate same area as each other. It can be achieved by checking which neighbourhood of our game a given two objects are in, and then only performing the more CPU intensive collision detection if there is a realistic chance that a collision could […]
Collision detection: Radius overlap method
This method is also checking to see if two shapes intersect with each other, but as the title suggests, it does so using circles. There are advantages and disadvantages compared to other methods.
The radius overlap method works well with shapes more circular in nature and less well with elongated shapes as shown in the image […]
Collision detection: Rectangle intersect method
Rectangle intersection detection collision detection is really straightforward. We draw an imaginary rectangle; we can call it a hitbox or bounding rectangle, around the objects we want to test for collision. Then, test to see if they intersect on each and every frame of the game. If they do, we have a collision.
Where the hitboxes […]
Rotating graphics in 2d games: Using trigonometric functions part 2
In this second part of the series on trigonometric functions we will use the sine and cosine of an angle to rotateĀ a point around a specific central point. We will then see that by drawing multiple points around the central point and using the same calculation on each we can create the effect of an […]
Calculating heading in 2d games: Using trigonometric functions part 1
This article takes a high-level but hopefully useful look and some common trigonometric functions with the aim of clarifying how they can be used as solutions in our game coding to create some cool movement and drawing effects. As this article is aimed at beginners in game coding it makes no assumptions about the readers […]