Skip to content

Instantly share code, notes, and snippets.

@maryrosecook
Created January 18, 2011 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maryrosecook/784756 to your computer and use it in GitHub Desktop.
Save maryrosecook/784756 to your computer and use it in GitHub Desktop.
If dustbin is colliding with a girl
If she is moving through the left side of the dustbin
Move the dustbin horizontally so its left side is touching the girl's right
If she is moving through the right side of the dustbin
Move the dustbin horizontally so its right side is touching the girl's left
If girl colliding with a dustbin
If she is falling through the dustbin
Move her vertically so the soles of her feet are on the top of the dustbin
Set her vertical velocity to 0
If she is rising up through the dustbin
Move her vertically so the top of her head touching the bottom of the dustbin
Set her vertical velocity to 0
If she is moving through the right side of the dustbin
Move her horizontally so her right side is touching the left of the dustbin
If she is moving through the left side of the dustbin
Move her horizontally so her left side is touching the right of the dustbin
If girl is falling
If her feet are lower than the top of the bin
If her feet are higher than the top of the bin + maximum speed
The girl is falling through the bin
If the girl is rising
If her head is higher than the bottom of the bin
If her head is lower than the bottom of the bin - maximum speed
The girl is bumping against the bottom of the bin
If the girl's right side is past the bin's left side
If her left side is not past the bin's left side
If she is not on top of the bin
She is bumping against the left side of the bin
If the girl's left side is past the bin's right side
If her right side is not past the bin's right side
If she is not on top of the bin
She is bumping against the right side of the bin
x: p1.x
y: p1.y
width: p2.x - p1.x
height: p2.y - p1.y
If this grenade is colliding with an object
If grenade bounding box overlapping line defining left side of object
Run reverseAngle() function, passing "left" for sideHit
If grenade bounding box overlapping line defining right side of object
Run reverseAngle() function, passing "right" for sideHit
If grenade bounding box overlapping line defining bottom side of object
Run reverseAngle() function, passing "bottom" for sideHit
If grenade bounding box overlapping line defining top side of object
Run reverseAngle() function, passing "top" for sideHit
No overlaps, so sweep the object:
Reverse velocity
Divide velocity by some number, like 5, so we don't jump over a side
Move grenade by divided and reversed velocity
Test for collision again (return to the top)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment