• Welcome to Dark Bit Factory & Gravity.
 

Collisions in Tinyptc?

Started by Hotshot, January 20, 2009

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Hotshot

Hiya all,

I have background, Player, Enemys and Is there is Collisions for Freebasic Tinyptc?

hellfire

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.
Challenge Trophies Won:

Shockwave

How are you getting on with this Hotshot?

Shockwave ^ Codigos
Challenge Trophies Won:

Hotshot

I got my image working. I never have done Manual Collisions before as it all new to me

Shockwave

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.

Shockwave ^ Codigos
Challenge Trophies Won: