sreich/ore-chasm — pull request #2 by DaGamesta (2012-12-29 03:33:19+00:00)
Title: First attempt at adding checking collision with blocks.

All right, so this should work in theory.

In order to use it, though, you still need to provide the texture width and height to the function. As such I commented out the new code in the update function of the entity class, and left your first collision detection there. When you are ready to supply the width and height of the texture, just comment out your collision detection and uncomment mine with your changes.

Hopefully I followed all the rules I was supposed to; I could not run astyle.sh in windows and haven't set up an alternative yet. I made sure to read the conventions you linked to in the README, and change all tabs to 4 spaces.

A quick description of the code for moving with collision in mind:

First check to see if there is a collision at the position that you will be moving to based on velocity. If there is no collision, move there. Elsewise, check for collisions with tiles horizontally moving the width of one tile at a time; once a collision is reached, move the player one tile to the left/right of the tile in question. Setting the temporary starting position to that point, then do the same check vertically. Return the position for the player to be moved to.

Sincerely,
DaGamesta