Author Topic: Collision detection with polyvector  (Read 1288 times)

Offline ketil

  • Mr. Polyvector
  • ***
  • Posts: 117
    • View Profile
Collision detection with polyvector
« on: 2012-Aug-13 »
Hi guys

What would be the best method for pixel perfect collison of the player sprite when using a tilebased scroller with polydraw functionality ?
Would it be to keep track of the player-sprite's screen position and draw all the tiles from the "crashable layer" as sprites too. That is if they are inside the playersprites rectangle.
And then use sprcoll ?

Or are there any other cool functionality for this ?

Btw. I will be using transparent png images for sprites and tiles.
"Sugar makes the world go 'round. Caffeine makes it spin faster."

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4176
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Collision detection with polyvector
« Reply #1 on: 2012-Aug-13 »
Array checking should generally be your first test for collisions in tile based gaming, however this can be very hit and miss if the background needs to have non-squarish tiles (eg. slopes), but even then still use the tile data array and work out positioning  for where the character should be in relation to the image (climbing/descending slope or even to detect if player has collided with ground/object). If it's just walls etc that's the way to go.

I wouldn't advise using sprites as well as Polyvectors for drawing the landscape - stick to polys only and make enemies and pick-ups sprites if you need pixel perfect collision detection.
I came. I saw. I played.