Fixed formatting issues
+8
-7
@@ -1,4 +1,4 @@
|
||||
Abstract:
|
||||
## Abstract
|
||||
|
||||
The goal of this pseudocode is to create a collision system that brings several
|
||||
colliding bodies to a near-contact state (no space between the bodies, but not
|
||||
@@ -6,7 +6,7 @@ overlapping), while preserving the motion of said bodies. For simplicity, I've
|
||||
decided to use a square box (BoundingBox, or BBox for short) for the collidable
|
||||
bodies.
|
||||
|
||||
Example:
|
||||
## Goal
|
||||
|
||||
My current game has a tiled-map, where the tiles are arranged on a 2D grid. The
|
||||
tiles each have a flag indicating if they are solid (i.e. collidable) or not. I
|
||||
@@ -22,7 +22,9 @@ Obviously, there are many in depth issues that I will need to take into
|
||||
account when writing this logic, that have been glossed over or omitted in this
|
||||
article.
|
||||
|
||||
-------------------------
|
||||
## Design
|
||||
|
||||
### Basic Example
|
||||
|
||||
```
|
||||
velocity = motion + speed
|
||||
@@ -42,7 +44,7 @@ motion, but it still leaves several pixels of space between the bounding boxes.
|
||||
Notably, it also treats "collision" as an abstract concept, rather than as an
|
||||
event that could happen multiple times per frame.
|
||||
|
||||
-------------------------
|
||||
### Better Example
|
||||
|
||||
```
|
||||
velocity = motion + speed
|
||||
@@ -62,7 +64,7 @@ If there are any collisions between the player object and the given box set,
|
||||
then collisionX() and collisionY() are called to calculate the new distance
|
||||
that the character will move.
|
||||
|
||||
-------------------------
|
||||
### Simple Collision Check
|
||||
|
||||
```
|
||||
bool collisionSimple(BOXSET, newPos):
|
||||
@@ -90,7 +92,7 @@ would not have been checked against the removed elements.
|
||||
|
||||
Just something to note.
|
||||
|
||||
-------------------------
|
||||
### Velocity Correction
|
||||
|
||||
```
|
||||
var collisionX(BOXSET, velocityX):
|
||||
@@ -105,7 +107,6 @@ Just something to note.
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user