constants collisionFlags - wxyz-abcd/node-haxball GitHub Wiki

CollisionFlags

These flags are used internally in Haxball's physics engine. They are designed to act like flags and be used in bitwise operations. Most types of stadium objects have collisionMask and collisionGroup properties that directly uses these flags to decide whether collision check should happen or not.

Let's say discA seemingly collided with discB. The physics engine will just skip the collision without doing any further calculation if the below condition is not satisfied:

((discA.collisionMask & discB.collisionGroup)>0) && ((discB.collisionMask & discA.collisionGroup)>0)

Here are the collision flags:

const CollisionFlags = {
  ball: 0,
  red: 1,
  blue: 2,
  redKO: 3,
  blueKO: 4,
  wall: 5,
  kick: 6,
  score: 7,
  free1: 8,
  free2: 9,
  free3: 10,
  free4: 11,
  free5: 12,
  free6: 13,
  free7: 14,
  free8: 15,
  free9: 16,
  free10: 17,
  free11: 18,
  free12: 19,
  free13: 20,
  free14: 21,
  free15: 22,
  free16: 23,
  free17: 24,
  free18: 25,
  free19: 26,
  free20: 27,
  c0: 28,
  c1: 29,
  c2: 30,
  c3: 31
};

Short description for each flag:

ball: If defined, the object will accept collisions with other "ball"s.

red, blue: If defined, the object will accept collisions with other "red"s/"blue"s.

redKO, blueKO: If defined, the object will accept collisions with other "red"s/"blue"s only until the kick off event happens.

wall: If defined, the object will act as a wall.

kick: If defined, the object will become kickable. Haxball makes a player kick some object only if this kick flag exists in the object and the object is near enough to the player. (4 map units, to be precise.)

score: If defined, the object will score a goal for the opposite team if it passes a goal line.

The flags after score are either never(the free ones) or very occasionally(the c ones) used and do not really matter. You might use all these values freely if you want to develop custom game mechanics using the current physics engine, but you will need a custom client, and/or a custom website, and/or a custom backend for the other people to be able to join your rooms.