instance - hpgDesigns/hpgdesigns-dev.io GitHub Wiki

In ENIGMA, an instance refers to an actual instance, or representation, or copy, if you will, of an object. An instance is to an object as you are to the human species. An object can have any number of instances, each functioning independently of one another with their own set of local variables.

Uses

When an object is created and its behavior programmed (e.g. a bullet), then when it is created in the game that is an instance of that object. So when a player shoots, then every bullet is its own instance.

Built-in variables

Every instance have built in variables that are local to the instance itself. They are updated automatically or can be set.

  • x - x position of the instance.
  • y - y position of the instance.
  • xprevious - x position the instance was in the previous step.
  • yprevious - y position the instance was in the previous step.
  • direction - This is the direction of the instance. Its position is updated every step according to the speed and direction.
  • speed - The amount of pixels the instance will move every step in the set direction.
  • hspeed - Horizontal speed component. It changes automatically according to the speed and direction.
  • vspeed - Vertical speed component. It also changes according to the speed and direction.
  • friction - Amount of speed the instance will lose every step.
  • gravity - Amount of gravity in pixels per second.
  • gravity_direction - The direction gravity will pull.
  • solid - Whether the instance is solid or not.
  • persistent - Whether the instance is persistent.
  • object_index***** - Index of the object this is an instance of.
  • id***** - The unique identifier for the instance (>= 100000).

*****These variables are constant and cannot be changed.

Functions

  • - Create an instance of the specified object at the position (x,y).

  • - Destroys the calling instance.

  • - Returns whether an instance of type obj exists. obj can be an object, an instance id, or the keyword all.

  • - Returns the id of the (n+1)'th instance of type obj. obj can be an object or the keyword all.

  • - Returns the number of instances of type obj. obj can be an object or the keyword all.

  • - Returns the id of the instance of type obj furthest away from (x,y). obj can be an object or the keyword all.

  • - Returns the id of the instance of type obj nearest to (x,y). obj can be an object or the keyword all.

  • - Returns the id of the instance of type obj at position (x,y). When multiple instances are at that position the first is returned. obj can be an object or the keyword all.

  • - Returns the id of the instance of type obj met when the current instance is placed at position (x,y). obj can be an object or the keyword all.

⚠️ **GitHub.com Fallback** ⚠️