Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Hotshot on January 20, 2009

Title: Collisions in Tinyptc?
Post by: Hotshot on January 20, 2009
Hiya all,

I have background, Player, Enemys and Is there is Collisions for Freebasic Tinyptc?
Title: Re: Collisions in Tinyptc?
Post by: hellfire on January 20, 2009
No. You can code your own, though.
It's fairly simple: Just think of "Player" and "Enemy" as two rectangles (each made up from position and size of the bitmap) and check if they overlap.
There are several special cases where this test fails but you can ignore this for the moment.
Title: Re: Collisions in Tinyptc?
Post by: Shockwave on January 21, 2009
How are you getting on with this Hotshot?

Title: Re: Collisions in Tinyptc?
Post by: Hotshot on January 22, 2009
I got my image working. I never have done Manual Collisions before as it all new to me
Title: Re: Collisions in Tinyptc?
Post by: Shockwave on January 22, 2009
As Hellfire says, if you simply think of sprites as rectangles then you can test the points (corners) of one rectangle to see if they lie inside the area of the other one and if any of the corners lie inside then you could say that you have a collision.

This is a pretty fast way of doing things and in a quick paced game nobody would notice it is not 100% perfect.

If you want 100% accurate collisions then you need to use another technique which would involve creating something called bit masks  for your sprites, these are slower, to impliment them quickly is a little bit out of your range at the moment so I'll make a deal with you, if you code the basic collision of rectangles overlapping to show your progress then I will change that code so that it uses image masking.