(Solved) Need some help with AUM84 - 2dcollision3.c

Posted By: Evo

(Solved) Need some help with AUM84 - 2dcollision3.c - 04/16/17 00:28

George and Community,

I have currently been wanting to start a new 2D game builder that hopefully improves upon my last effort.

But before I start the new project, I have been looking into trying to find a pixel-collision detection that I can start with as a base for a new 2d collision system. I had recently converted a few 2d collision algorithms from HTML5/JS, but they weren't what I really needed.

When AUM84 first came out, I had attempted to update the 2dcollision3.c script that uses the red pixel color for detection, but eventually ran into the problem that I have no idea how to actually "move" the collision. It stayed stationary on the screen at all times and I couldn't find a way to do it. The BMAP called is not set as a panel and is read by the code within the players movement.

My 2D game builder is designed to move the player when their near the edge of a map and when the player walks over and gets center screen, player keeps animating, but then its the world that moves to simulate a 2D camera.

My Question :
Is there a way that this can be set up so that the BMAP image used for collision is set as a movable panel layer during gameplay? If so, would it still be able to detect the red pixels that the player comes into contact with in the same way that it does in the demo?

Solved:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=465319#Post465319

Thank you for your time,
Brian Pressley
Posted By: Ezzett

Re: Need some help with AUM84 - 2dcollision3.c - 04/16/17 05:54

In Aum 84 the level bitmap is already used for a PANEL called level_pan.

Maybe you could try this:
- move the panel when your player reaches the center of the screen
- read out pos_x and pos_y of the panel
- read out the pixel of the bitmap with the help of pos_x and pos_y to include the movement

pixel = pixel_for_bmap(level_tga, coords_x - pos_x, coords_y - pos_y);

Be careful not to read a pixel outside of the bitmaps size.


There should be no speed difference. It would cost time if you check each frame that you're not outside the bitmap when reading a pixel.
Posted By: Evo

Re: Need some help with AUM84 - 2dcollision3.c - 04/16/17 06:21

Thanks. Works great. Now the collision moves as I need it to.

It will take some work to turn AUM84 2D collision into a decent pixel-perfect system, but it's a good simplified foundation to start on.

Thank you very much Ezzett.
Posted By: George

Re: Need some help with AUM84 - 2dcollision3.c - 04/17/17 17:46

It's good to hear that Ezzett's solution works fine.
© 2024 lite-C Forums