Author Topic: Collisions in Tinyptc?  (Read 2816 times)

0 Members and 1 Guest are viewing this topic.

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Collisions in Tinyptc?
« on: January 20, 2009 »
Hiya all,

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

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Collisions in Tinyptc?
« Reply #1 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.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Collisions in Tinyptc?
« Reply #2 on: January 21, 2009 »
How are you getting on with this Hotshot?

Shockwave ^ Codigos
Challenge Trophies Won:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: Collisions in Tinyptc?
« Reply #3 on: January 22, 2009 »
I got my image working. I never have done Manual Collisions before as it all new to me

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Collisions in Tinyptc?
« Reply #4 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.

Shockwave ^ Codigos
Challenge Trophies Won: