Author Topic: MODULE: Pixel-perfect collision detection v1.02  (Read 12209 times)

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: MODULE: Pixel-perfect collision detection v1.02
« Reply #20 on: 20 Jun 2016, 15:40 »
Thanks :)
I  ended up coding the function last night, and even though it's not pixel perfect (I think) it works good enough for what I need it to do.

But thanks anyway, saved and stored for if it turns out I need the PP perfect. :-D
There are those who believe that life here began out there...

Re: MODULE: Pixel-perfect collision detection v1.02
« Reply #21 on: 16 Apr 2019, 11:38 »
I'm trying that when two characters come together, the protagonist moves away.

I script thist:

bool IsCollided = false;


function room_RepExec()
{
if (PPColliding.CWithC(cJuan, cPeter) && IsCollided == false) {
  IsCollided = true;
  Display ("CROQUETA");
  cSofi.Walk (86. 119, eBlock);
  IsCollided = false;
}
}
Code: Adventure Game Studio
  1.  
  2.  

But it does not stop constantly repeating "CROQUETA" and the character does not move away.
I would like that when two characters come together, they repel each other.

Could anyone help me, please?

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • I can help with proof reading
    • I can help with translating
Re: MODULE: Pixel-perfect collision detection v1.02
« Reply #22 on: 16 Apr 2019, 11:49 »
Code: Adventure Game Studio
  1. bool wasColliding = false;
  2.  
  3. function room_RepExec()
  4. {
  5.   bool isColliding = PPColliding.CWithC(cJuan, cPeter);
  6.   if (isColliding && !wasColliding)
  7.   {
  8.       Display ("CROQUETA");
  9.       cSofi.Walk (86, 119, eBlock);
  10.   }
  11.   wasColliding = isColliding;
  12. }
  13.  
« Last Edit: 16 Apr 2019, 12:20 by Snarky »

Re: MODULE: Pixel-perfect collision detection v1.02
« Reply #23 on: 16 Apr 2019, 11:55 »
Thank you so much Snarky, Scavenger help me too with this:

Code: Adventure Game Studio
  1. bool IsCollided = false;
  2.  
  3. function room_RepExec()
  4. {
  5. if (IsCollided == false) {
  6. if (PPColliding.CWithC(cPeter, cJuan))
  7. {
  8.   Display ("CROQUETA");
  9.   cPeter.Walk (86. 119, eBlock);
  10. IsCollided = true;
  11. }
  12. }
  13. else IsCollided = false;
  14. }
  15.  

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • I can help with proof reading
    • I can help with translating
Re: MODULE: Pixel-perfect collision detection v1.02
« Reply #24 on: 16 Apr 2019, 12:18 »
My version is better.  :-D