Page 1 of 1

Adding a UndefineCollision

Posted: Sat Sep 20, 2008 12:51 pm
by kattle87
Can we use:
Collisions.pas Line 312

Code: Select all

procedure TCollisionChecks.Add(Cat1, Cat2: integer; Action : TCollisionAction = caCollision);
var
  Check : TCollisionCheck;
begin
  Check := TCollisionCheck.Create;
  Check.Cat1 := Cat1;
  Check.Cat2 := Cat2;
  Check.Action := Action;
  Checks.Add(Check);
  ZApp.Models.RegisterCat(Cat1);
  ZApp.Models.RegisterCat(Cat2);
end;
and modify it to:

Code: Select all

procedure TCollisionChecks.Remove(Cat1, Cat2: integer; Action : TCollisionAction = caCollision);
var
  Check : TCollisionCheck;
begin
  Check := TCollisionCheck.Create;
  Check.Cat1 := Cat1;
  Check.Cat2 := Cat2;
  Check.Action := Action;
  Checks.Remove(Check);
  ZApp.Models.RegisterCat(Cat1);
  ZApp.Models.RegisterCat(Cat2);
end;
to undefine a collision?

In C something like that would generate tons of errors but I don't know what is a TObject and how it is handled by Pascal, so tell me when you have time :D.

Posted: Mon Sep 22, 2008 2:58 pm
by VilleK
Hi,

Sure we can add functionality for undefining a collision, but is it really neccessary? I would use a global variable instead and test it in oncollision if the actions should trigger or not. Please describe a scenario where you would use such a feature.

/V

Posted: Mon Sep 29, 2008 11:19 am
by Kjell
Hey guys,

The most important thing I can think of is performance. When you for example have a large level that you can split up in arena's, you only want to check collision with objects that are in the area you're currently in.

K

Posted: Mon Sep 29, 2008 11:41 am
by kattle87
BTW: I have thought about a smart way to define/undef collisions (dunno if was the same Ville was thinking about). What about a 32x32 2D-Array to be used as a table? 0 would mean "do not call collision" and the other values (1, 2 and so on) can be used as a flag to say what action should be taken.

But yes I do agree Undefining a collision is something not common. The only apply I can find is the same of "CollisionsEnabled" in the App.State component, previded that you want that just some collisions are disabled. And let's say something like "permanent invulnerability" towards something (but I know that can be made using variables as flag, too!)

I was just speculating about it... :)