!Collision detection!Redo-ing the inner workings of the player.
*There's a gif here, wait for it to load!*
I've finished with the player's collision detection, which is even better than the collision detection on my entities.
I'll eventually alter the entities to work on this same system.
I can scale things to a ridiculous degree and still maintain perfect accuracy, up to a point of ~1/10000th of a pixel (due to floating point inaccuracy)
If I make objects huge the game will slow down a bit, due to a huge amount of array checks, but nothing will ever come close to being big enough for that, so I think I'm good.
I'm very happy with this. The math for this almost broke my brain, but I somehow managed to do it.
The player checks with the level data array before moving to see if there's a collision. If there is a collision, it'll move to that collision point.
It goes like this:
For Y axis:
1.apply gravity/other forces
2.check for collision at where the player will be at
3a.if collision, set velocity to the difference of the player's y minus the collision point y
3b.otherwise, just apply velocity as normal
4.move player by the final y velocity
5.repeat for X axis
This makes it very efficient and work perfectly. It also prevents the bullet through paper effect, where if the player is moving fast enough, you can go through a wall. This method checks every tile you'll cover in one frame, so that'll never happen. It also works with any timescale. So if I set the game to run 10 times as fast (which is insane), everything will still work just fine.
http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/^is very helpful (check type #2)
I'm gonna be putting titles on my updates now cause this devlog will be very long by the time the game is done. It'd be nice to quickly scan through and see the important features get added.
Thanks for reading! I've got lots of work to do with platforming physics/lighting. Next update may not be for a while.