2D Platform template + full collision and collision generator

Posted By: Evo

2D Platform template + full collision and collision generator - 04/22/17 03:51

2D Platform template + full collision and collision generator

After looking for different methods of creating 2D collision, I was scrolling through the AUM and came across a simple jump n run 2d platformer template created by MasterQ32. Its original features included smooth player movement, jumping and it used line based positions for collision detection with a ground line platform.

I really liked its simplicity and I seen this as a good chance to experiment with pixel_for_bmap a little more and see what new ideas I could create.

After testing some things, I have updated its design and included the following features :
* Added extra collision for players left side, right side, and head. Full collision is now included for all sides.
* The line based positions used for collision detection are now automatically created from a collision image and detect four colors that decide which type of collision it is.

How does it work?
Draw colored lines on a collision image (Like what is shown in the image below) to allow the code to auto generate the collision lines. The side of collision it creates is based on the color of the line.
(Red colored lines = ground) - RED(255).
(blue colored lines = ceiling) - BLUE(255).
(Green colored lines = leftwall) - GREEN(255).
(Dark Green colored lines = rightwall) - GREEN(100).

The collision layer itself is invisible. this example uses the collision layer image for the visual image so you can see your collision lines. Five collision images are included. Just change the Level image bmap and the collision bmap to a new collision image to see how it auto generates the collision points based off the pixel data.

BUG REPORT :
Update#1-5 : Fixed Known Issues...


NOTES :
* When drawing your collision layer, make sure the side collision lines stay in between the ground and ceiling lines. Look at the example images that are included for a better understanding of how to position your collision so that player does not fall or jump through corners.

DOWNLOAD :
platformer_Collision_System.zip





Posted By: 3run

Re: 2D Platform template + full collision and collision generator - 04/26/17 10:47

It looks great! Thank you for sharing!
Posted By: MasterQ32

Re: 2D Platform template + full collision and collision generator - 04/26/17 19:58

Nice to see you making use of my code, can't test it right now, but still: cool!
© 2024 lite-C Forums