Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I have been playing around with Kyra a bit and came up a small problem that I can not solve alone. Basically I would like to code a simple platformer like Mario. I was planning to use sprites for different platform and main character and collision detection to keep him from falling through. Grinning Lizard's home page gives suggestion to use following way with collision detections:
1 Move sprites, canvases, etc. Game & logic actions.
2 Call Walk
3 Check collisions. Call deletes as you go, queue up additional move and scaling actions.
4 Apply queued move and scaling actions.
This is mainly because calling Walk (needed to call before collision detections) is resource consuming.
The point that I can not implement is queueing additional move and scaling actions. I was thinking of storing information of moving character back to the original spot in case he is going to fall through a platform, but this prevents him from moving completely. And if I only would move him upwards in case of collision with a platform, he could walk through them from side.
Should I then create different sprites that would actually tell to which way move if player manages to bump into them? Or does anybody has any other ideas?
All feedback is really appreciated.
In general (and this is true of all 2D engines) collision detection is not the best way to keep things from "falling through" one another by returning the amount of pixels you need to back up.
It's usually much easier to create art that follows rules.
One way to look at it:
- The top of the art is the location of the floor (the obvious way to do it)
- The art is at 30, 50
- A sprite collides with the floor art
- The bottom of the sprite is moved so that it ends at pixel 49
That is pretty easy, efficient, and still uses collisions. Depending on what rules you use for the art (fixed size, aligned to a grid) you may not even need the collision system.
That sounds like a good idea. I'll test it and see if I can get that working. Thanks for the quick reply.