Page 1 of 1

Need help with implementing sonic the hedgehog physics

Posted: Mon Oct 29, 2012 12:39 pm
by Megalan
First of all I would like to say what I'm new in love and all this gamedev stuff so there is probably will be a lot of stuff I'm doing wrong or don't understand. (I'm a desktop/web software developer, not a game developer :)) So... ok, let's begin.
I'm working on implementing sonic the hedgehog physics using Sonic Physics Guide and everything was ok (I've made running and jumping physics before doing anything else) until I started implementing solid tiles physics. First of all as I can see I should use per-pixel collisions so I found a library here at forums (collision.lua in .love file) and using it but it's not as good as I wanted (or I just using it wrong) so maybe someone could help me with changing code so it will be more accurate or maybe point me at physics realisation which is better for this project. Next I'm stuck at Slopes And Curves (Solid Tiles article) and everything what is going after it. I just don't understand how to implement all this stuff from this article. (for example I tried to implement gsp constant but it acts very weird, you can enable it by setting gsp_test to true at line 156) So maybe someone will help me with this too.

Here is .love file:
https://dl.dropbox.com/u/1285798/sonic.love

I've commented a code a bit, maybe this will help understand where is what located.

Re: Need help with implementing sonic the hedgehog physics

Posted: Mon Oct 29, 2012 1:44 pm
by ivan
Hi. Looks like you are trying to solve a few difficult problems at the same time.
I would initially advise you to break down the Sonic engine into simpler and non-interdependent parts.
I'm not an 100% sure but per-pixel collision detection might not be the best solution in your case.
It's probably not ideal to base your collision map on the contents of an image - you may want to consider adding separate 'bitmask' images for each tile.
Also, you may run into issues when dealing with moving platforms and so on.
Have you considered using math-based collisions:
http://www.metanetsoftware.com/technique/tutorialA.html

Re: Need help with implementing sonic the hedgehog physics

Posted: Tue Oct 30, 2012 12:09 pm
by Megalan
Yeah, I'm thinking about changing collisions to something more simple because it lags like hell if there is a lot of collision checks per engine update but I still don't have any idea how to handle slopes correctly if I change it to something like SAT. Anyway, thank you for advice.