1.1.31 • Published 5 years ago

alethia-engine v1.1.31

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

Alethia Engine

Example Project

GitHub Page

The Alethia Engine aims to provide a small, simple, and efficient 2 dimensional rendering engine for applications and games. With essentially only two new types (Scene and Asset), developers do not have to worry about having droves of unutilized features while also having a simple starting point to build a product designed for the users needs.

Scenes can be created like so:

import { Scene } from 'alethia-engine'

let overide = {
  id: 'my-new-scene'
}
let scene = new Scene(overide)

Assets can be created like so:

import { Asset } from 'alethia-engine'

let overide = {
  x: 50,
  y: 100
}
let asset = new Asset(overide)

To create a new Asset type, simply extend the class:

import { Asset } from 'alethia-engine'

class Tile extends Asset {
  constructor (sprite, x, y) {
    super({
      sprite: sprite,
      x: x,
      y: y,
      width: 25,
      height: 25,
      solid: false
    })
  }
}

Scene

Methods

  unfollow(): undefined // Stops the camera from following any Asset
  
  follow(asset:Asset): undefined // Makes the scene camera follow an asset on move
  
  addAsset(asset:Asset): undefined // Adds an asset to the scene
  
  scroll(x:Number, y:Number): undefined // Scrolls the scene from relative coordinates
  
  scrollTo(x:Number, y:Number): undefined // Scrolls the scene to fixed coordinates
  
  setScale(z:Number): undefined // Modifies the scale/zoom of the Scene
  
  keyPressed(key:String): Boolean // Returns true if the key is being pressed
  
  unselectAll(): undefined // Unselects all selected assets

Listeners

  oncreation(undefined):Function
  
  tickListeners:Object

Properties

  elem:Element // See Scriptleaf Element API
  
  state:State // See Scriptleaf State API
  
  floor:DOM Element // The background element
  
  background:String // URL to image
  
  fixedBackground:String // URL to image
  
  innerWidth:Number // The x cells in the scene
  
  innerHeight:Number // The y cells in the scene
  
  mouseBox:DOM Element // The mouse drag Element. Will apply object values as default on creation. Can be disabled by making == false
  
  mousePosition:Array // [x, y] of mouse position
  
  mouseDown:Number || false // Will be the value of the mousedown.button event value or false on mouse up

Asset

Methods

  changeSprite(imgURL:String): undefined // Changes DOM Element background to the image

  move(x:Number, y:Number): undefined // Moves Asset to relative position
  
  place(x:Number, y:Number): undefined // Places Asset at specific point
  
  focus(): undefined // Moves scene camera to focus on Asset
  
  destroyInstance(): undefined // Destroys instance of Asset
  
  getScene(): Scene || false // Returns the Scene Object or false if not attached
  
  rotate(deg:Number): undefined // Rotates DOM Element's transform
  
  select(): onselect listener return value
  
  unselect(): onunselect listener return value

Listeners

  oncreation(undefined) // Fired after the Asset's instance is created
  
  ontick(undefined) // Can be a function or an array of functions
  
  ondestroy(undefined) // Fires when the a Asset's instance is destroyed via the destroyInstance method
  
  oncollision(collidedObject:Asset):Boolean // if returns false, overlapping movement will not incur. Default returns false when collision is between two solid Assets.
  
  onselect(undefined) // By default fires whenever the asset is clicked or included in a drag box
  
  onunselect(undefined) // By default fires whenever the background is clicked
  
  onwaypointarrival(undefined) // Fires when arriving at waypoint. If does not return true, the active waypoint will be deleted. If returns array, the waypoint will be updated to that array

Properties

  elem:Element // See Scriptleaf Element API
  
  state:State // See Scriptleaf State API
  
  scene:Scene // The scene to which the Asset belongs
  
  follow:Boolean // Wether the camera will (on creation) or is (if already created) follow the Asset
  
  selectable:Boolean // If falsy, clicking and mouseboxes will not select the Asset
  
  waypoint:Array // [x, y] will travel asset.speed each tick towards waypoint
  
  speed:Number // The default speed when following a waypoint
  
  moveX:Number // Moves relatively on each tick, after the ontick method fires
  
  moveY:Number // Moves relatively on each tick, after the ontick method fires
  
  x:Number // The x grid coordinate in which the Asset is occupying
  
  y:Number // The y grid coordinate in which the Asset is occupying
  
  id:String // Will default to a random string if not expressed on creation
1.1.31

5 years ago

1.1.30

5 years ago

1.1.29

5 years ago

1.1.28

5 years ago

1.1.27

5 years ago

1.1.26

5 years ago

1.1.25

5 years ago

1.1.24

5 years ago

1.1.23

5 years ago

1.1.22

5 years ago

1.1.21

5 years ago

1.1.20

5 years ago

1.1.19

5 years ago

1.1.18

5 years ago

1.1.17

5 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.56

5 years ago

1.0.55

5 years ago

1.0.54

5 years ago

1.0.53

5 years ago

1.0.52

5 years ago

1.0.51

5 years ago

1.0.50

5 years ago

1.0.49

5 years ago

1.0.48

5 years ago

1.0.47

5 years ago

1.0.46

5 years ago

1.0.45

5 years ago

1.0.44

5 years ago

1.0.43

5 years ago

1.0.42

5 years ago

1.0.41

5 years ago

1.0.40

5 years ago

1.0.39

5 years ago

1.0.38

5 years ago

1.0.37

5 years ago

1.0.36

5 years ago

1.0.35

5 years ago

1.0.34

5 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago