Skip to content

Add simple collision response #1

@JoeStrout

Description

@JoeStrout

The current code detects collisions (tinting the sprites red) but does not do anything about it. In particular, the calcCollisions method has a // ToDo comment where the collision response should be.

This is where we need to call a new function that calculates and applies the collision forces on the bodies.

This is a well-known problem; searching for "2d physics collision response" should turn up some algorithms. Books such as Physics for Game Developers are also a great reference.

For this ticket, it's fine if the collision code only works for the simple case of single-Bounds physics bodies. We can generalize it to more complex shapes later.

We'll know the code is working when the test program (test.ms) shows the two small blocks coming to rest on the ground, one probably on top of the other (perhaps at a jaunty angle).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions