vEngine Structure Collision

November 13th, 2004

This is an explanation of how vEngine deals with structure collisions. Structures refer to all static objects, like the ground and walls.

Warning!! This document is far from complete.

Vocabulary:
Actor:
A dynamic object, like enemies, the player, and projectiles.

Structures:
Static objects, mostly architecture like, floors and walls. This document is focused on collision between actors and structures.

Grid:
A table of rows and columns. (AKA two dimensional array)

Tick:
The time that it takes for one cycle of the games main loop.

1. Tile Collision 101.
The distance an actor moves is dependent on the tick length and the objects speed. The greater either are the farther the actor will move. Because of this an actor could move over multiple tiles at once.

Full/empty example

The most obvious collision technique would be to test each cell the actor passes through and see if it has a tile in it. The tile that is closest to the actor’s original position is the “collision tile”. This works well enough if all of the graphics are square and fill up the entire tile but what if you want to have slopes in your game where tiles aren’t completely full as shown in the picture below:

half full example

2. New collision technique:
Instead of focusing on each individual tile lets remove the tiles completely for a moment and only focus on the places where a tile can collide with the structure.

Full/empty example

As you can see its just a shape. Broken down farther, the shape is made up of three lines. To find which line the actor collided with, the collision point of where the actor collided with each line must be calculated. The line with the collision point closest to the actors original position is where the actors new position should be.

Now lets add more lines to this problem.
Full/empty example

With this collision method each line would have to be tested to see wether or not the actor has collided with it. This will get very slow very quickly as more lines and actors are added.

To solve this problem we bring back the grid, placing it over our lines.
Full/empty example

Rather than saving tiles in the grids cells a list of every line that passes through each cell is saved.

One Response to “vEngine Structure Collision”

  1. Jeff Minard Said:

    Lookin good.

Leave a Reply