Skip to content

2.1.1 Docs update

Choose a tag to compare

@yetnt yetnt released this 20 Sep 16:28
· 5 commits to main since this release

Finnally documented the new arts of PlaneObject class

PlaneObject Class

The PlaneObject class represents an object that can be placed on the Plane. It emits events for collision detection and can be used to create interactive game elements.

Constructor

Parameters

  • plane: Plane instance.
  • x: The object's origin on the x-axis
  • y: The object's origin on the y-axis
  • id: A unique identifier for the object.
  • value:(optional) The emoji or value to display on the plane for said object. Defaults to the object's ID.
  • detectCollision:(optional) Whether to detect collisions with other objects. Defaults to true
  • ai: (optional) Enable Auto-Movement
const { Plane, PlaneObject } = require('disgamekit');

let plane = new Plane(...)
let hat = new PlaneObject(plane, 0, 0, 'hat', '🧢');

Methods

isAi

Check if current PlaneObject is an AI

const { Plane, PlaneObject } = require('disgamekit');

let plane = new Plane(...)
let hat = new PlaneObject(plane, 0, 0, 'hat', '🧢', false, true);

hat.isAi() // true

start

Start tracking specified target

Parameters
  • target: another PlaneObject to target
let apple = new PlaneObject(plane, 5, 5, 'apple', 'a');

hat.start(apple);

step

Step 1 grid space closer to the target

Parameters
  • target: (optional) Override current target with new target
hat.step(); // since it's tracking apple at (5, 5), hat will go to (1, 1)

stop

Stop running the AI

hat.stop();

hat.step(); // AI has not been started!

Full Changelog: 2.1.0...2.1.1