GLBasic forum

Main forum => GLBasic - en => Topic started by: ketil on 2012-Aug-13

Title: Collision detection with polyvector
Post by: ketil 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.
Title: Re: Collision detection with polyvector
Post by: Ian Price 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.