Small game made for Ludum Dare 45 in 48h.
Roll your way through 7 levels and collect snow to make a happy snowman.
- left/right: move
- up: jump
- x/c: reset level
The Ludum Dare page is here if you want to vote: https://ldjam.com/events/ludum-dare/45/snowball
@Mot I'm glad you liked the game!
So the collision detection is a bit of a mess but it works just using the sprite tiles, so it's great to make lots of tiles in a small time.
The main idea is to do "raycast" from 32 points along the ball edge in the direction of the motion. Each raycast go pixel per pixel until it finds a collision. So you find the nearest collision and you know you can move you ball at least that much.
The second part is to find a "normal" to the surface at the point of contact so that the ball can bounce. As the game is using pixel art, it's not that easy. I compute the normal by taking the average direction of every solid pixel in a box of 5x5 around the pixel collision.
Then I had to tweak things because it was not working very well, so I use the normal I found to push the ball outside of the surface. This make the ball shake a lot, so I do all those computations 5 times per frame and use the average as the ball position.
As I said, it's full of hacks and only works because there is only one ball and I can afford extra computation. I would like to revisit this code at some point to make it more robust.
[Please log in to post a comment]