Adding a UndefineCollision

ZGE Source Code discussion. Ask questions, present your changes, propose patches etc.

Moderator: Moderators

Post Reply
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Adding a UndefineCollision

Post 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.
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post 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
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post 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... :)
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
Post Reply