Module World

The game world.

Functions

constants () A table of constants that describe the game rules and physics.
height () The height of the stage.
inAnyZone (ship) Checks whether a ship is currently in any stage zone.
inZone (ship, tag) Checks whether a ship is currently in a specific stage zone.
numShips () The total number of ships in the game.
teamSize () The number of ships assigned to each user loaded ship program.
time () The current time of the game.
touchedAnyZone (ship) Checks whether a ship's path from last tick to this tick intersects any part of any stage zone.
touchedZone (ship, tag) Checks whether a ship's path from last tick to this tick intersects any part of a specific stage zone.
walls () A table of all the walls on the stage, including the outer walls.
width () The width of the stage.
zones () A table of all the zones on the stage.

Tables

Constants Constants that help define the game rules and physics.
Wall Specifies the position and size of a wall.
Zone Specifies the position, size, and tag of a zone.


Functions

constants ()

A table of constants that describe the game rules and physics.

Return value:

A table of key-value pairs defining constants about the game rules and physics.

See also:

height ()

The height of the stage.

Return value:

The height of the stage.
inAnyZone (ship)

Checks whether a ship is currently in any stage zone.

Parameters

  • ship: The ship to check.

Return value:

true if the ship is in any stage zone, false otherwise.

See also:

inZone (ship, tag)

Checks whether a ship is currently in a specific stage zone.

Parameters

  • ship: The ship to check.
  • tag: The tag of the zone to check.

Return value:

true if the ship is in the stage zone with the given tag, false otherwise.

See also:

numShips ()

The total number of ships in the game.

Return value:

The total number of ships.
teamSize ()

The number of ships assigned to each user loaded ship program.

Return value:

The number of ships assigned to each team.
time ()

The current time of the game. Time increases by one each tick and does not reset between rounds.

Return value:

The current time.
touchedAnyZone (ship)

Checks whether a ship's path from last tick to this tick intersects any part of any stage zone.

Parameters

  • ship: The ship to check.

Return value:

true if the ship touches any stage zone, false otherwise.

See also:

touchedZone (ship, tag)

Checks whether a ship's path from last tick to this tick intersects any part of a specific stage zone.

Parameters

  • ship: The ship to check.
  • tag: The tag of the zone to check.

Return value:

true if the ship touches the stage zone with the given tag, false otherwise.

See also:

walls ()

A table of all the walls on the stage, including the outer walls.

Return value:

A table with details of all the walls on the stage.

See also:

width ()

The width of the stage.

Return value:

The width of the stage.
zones ()

A table of all the zones on the stage.

Return value:

A table with details of all the zones on the stage.

See also:

Tables

Constants

Constants that help define the game rules and physics.

Fields:

  • SHIP_RADIUS: The radius of a ship. (8)
  • LASER_SPEED: The distance a laser travels each tick. (25)
  • LASER_HEAT: The number of ticks it takes for a laser gun to cool down before it can fire again. (5)
  • LASER_DAMAGE: The amount of energy depleted by a laser when it hits. (4)
  • TORPEDO_SPEED: The distance a torpedo travels each tick. (12)
  • TORPEDO_HEAT: The number of ticks it takes for a torpedo gun to cool down before it can fire again. (100)
  • TORPEDO_BLAST_RADIUS: The radius of the blast caused by a torpedo explosion. Any ship closer to the blast center will take damage. (100)
  • TORPEDO_BLAST_FORCE: The magnitude of force from a torpedo blast to a ship located exactly at the center of a blast. (30)
  • TORPEDO_BLAST_DAMAGE: The damage caused by a torpedo blast to a ship located exactly at the center of a blast. (30)
  • DEFAULT_ENERGY: The amount of energy a ship starts with each game and each round. (100)
  • MAX_THRUSTER_FORCE: The maximum force a thruster can emit. (1.0)
  • WALL_BOUNCE: The portion of the colliding force that is reflected back into a ship when it collides with a wall. A value of 1.0 would mean a ship loses no momentum when hitting a wall. (0.5)
Wall

Specifies the position and size of a wall.

Fields:

  • left: The x coordinate of the left side of the wall.
  • bottom: The y coordinate of the bottom side of the wall.
  • width: The width of the wall.
  • height: The height of the wall.
Zone

Specifies the position, size, and tag of a zone.

Fields:

  • left: The x coordinate of the left side of the zone.
  • bottom: The y coordinate of the bottom side of the zone.
  • width: The width of the zone.
  • height: The height of the zone.
  • tag: The tag that identifies the zone. Not necessarily unique, and may be empty.