It was a long holiday weekend, so I got the coding bug again and started playing around:
Mario http://gfilter.net/junk/tileengine.jpg
I wrote a basic tile engine, but having never attempted this before, I am really struggling with handling sprite collision detection and implementing realistic physics for gravity.
For any other game hobby writers, can you point me towards some walkthroughs on the best way to approach this?
Update:
I thought I'd share a progress report:
http://www.youtube.com/watch?v=-RKNQ2UiiLY <-- Game in Action
Its still really buggy, but collision detection is mostly working, I've started working on some other features (such as bumping the blocks (notice the bug) and interacting with the enemies).
Mario still walks like he is on the moon, I'm using these constants, any advice for tweaking them for more realism?
const float AirDrag = 1.00f;
const float GroundFriction = .97f;
const float Gravity = 0.8f;
Download the FarseerPhysics engine, have a look at how it works http://www.codeplex.com/FarseerPhysics I think it's the best thing available for XNA/Silverlight!
Gravity is easy:
const gravity = ... ; // pixels per timestep (eg. video frame) squared
// while in freefall, each timestep:
y_velocity += gravity;
y_pos += y_velocity;
Mind you, most 2d platform games I've played don't have realistic gravity. Just do whatever makes the game fun!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With