Author Topic: Not wanting pixel perfect collision  (Read 504 times)

Offline Widget101

  • Mc. Print
  • *
  • Posts: 22
    • View Profile
Not wanting pixel perfect collision
« on: 2021-May-08 »
Hi,

I've drafted out a retro platformer (basically manic miner) and have an animated player but I'm finding that the pixel perfect collision is causing problems when my character walks off a wall. As he gets to the end of the wall he falls down as expected. However, as his arm extends back beyond his feet, the arm collides with the wall and the character sticks.

If I place a rectangular box under the sprite and use that for the collision then I don't get this problem as the edges of the collision check are always uniform (i.e. nothing sticking out past the edge to catch the wall).

Is there a way to replace the pixel perfect collision with a bounding collision instead? Or to make my rectangular box invisible so that it can't be seen but still detects collision.

Hopefully I've explained this clearly!! :S

Many thanks,

Steve.

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 339
  • to program what I have todo how should I program?
    • View Profile
Re: Not wanting pixel perfect collision
« Reply #1 on: 2021-May-08 »
if I didn't get it wrong, I'd do this:
I would place the rectangle on the player without DRAWRECT and check the collision with BOXCOLL
Ad maiora

Offline Widget101

  • Mc. Print
  • *
  • Posts: 22
    • View Profile
Re: Not wanting pixel perfect collision
« Reply #2 on: 2021-May-08 »
Thanks for the reply Qedo,

I was thinking about BOXCOLL but didn't think I'd be able to check its collision with a sprite or anim.

I think I've sorted it! Keep using the box sprite for the collision, but not actually drawing it to the screen seems to work!



« Last Edit: 2021-May-08 by Widget101 »

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1791
    • View Profile
    • Homepage
Re: Not wanting pixel perfect collision
« Reply #3 on: 2021-May-17 »
You could also use the array for the map data instead of the sprite/box collision. Just convert the screen coordinates of your player and compare to the map data to decide of there is a collision or not. This should also have the added benefit of being pretty fast compared to sprite collision tests.

Example of what I mean:

https://www.gamedev.net/forums/topic/592791-index-to-2d-coordinates/

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1757
    • View Profile
Re: Not wanting pixel perfect collision
« Reply #4 on: 2021-May-17 »
That manic miner looks really nice btw :)
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline StevetS

  • Mc. Print
  • *
  • Posts: 9
    • View Profile
Re: Not wanting pixel perfect collision
« Reply #5 on: 2021-May-23 »
You could also use the array for the map data instead of the sprite/box collision. Just convert the screen coordinates of your player and compare to the map data to decide of there is a collision or not. This should also have the added benefit of being pretty fast compared to sprite collision tests.

Example of what I mean:

https://www.gamedev.net/forums/topic/592791-index-to-2d-coordinates/

Ah! Never thought of that!  Checking against the object type in the array would be a really simple check as all objects of a certain type are grouped together ranges.   :booze:
PLOT 50,50:DRAW 50,50,45454545

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4371
    • View Profile
    • FUED
Re: Not wanting pixel perfect collision
« Reply #6 on: 2021-May-24 »
On Burger Lord I check a single player coordinate against the platform array, just like MORU said.
In fact it is very similar to boxcoll but I prefer doing it by hand and in my case it is actually a "line" collision as I donĀ“t need the height of box to collide.

Here is the game I have this system running:
https://sites.google.com/view/fuedhq/burger-lord?authuser=0