bear.js
v0.1.3
Published
🐻 bear.js - game engine using [pixi.js](http://www.pixijs.com/) to render. Inspired by [ELM](http://elm-lang.org/) and [Phaser](https://phaser.io/).
Readme
bear.js
🐻 bear.js - game engine using pixi.js to render. Inspired by ELM and Phaser.
Install
Add bear.js with npm/yarn or use unpkg
Examples
Counter example, the very basics. Source
Pong built with bear.js. Source
Api
game
Game init function
Parameters
GameArgsObjectGameArgs.stateany Initial state of the gameGameArgs.updatefunction Returns a new state each frameGameArgs.renderfunction Returns an array of sprite/text each frameGameArgs.texturesArray<{name: string, url: string}> List of textures that will be loaded before the game starts (optional, default[])GameArgs.optionsObject Game options (optional, default{})
landingpadNode
Examples
import { game } from "bear.js"Returns Promise<PIXI.Application>
_Point
Point class
Parameters
x
x position
Type: number
y
y position
Type: number
length
The length of the point
Returns number
setX
Returns a copy with its x value changed
Parameters
xnumber
Returns _Point
setY
Returns a copy with its y value changed
Parameters
ynumber
Returns _Point
normalize
Returns a normalized copy
Returns _Point
directionTo
Returns a normalized copy pointing towards the provided point
Parameters
otherPoint_Point
Returns _Point
add
Returns a copy subtracted by the provided point
Parameters
otherPoint_PointotherPoint.xotherPoint.y
Returns _Point
subtract
Returns a copy subtracted by the provided point
Parameters
otherPoint_PointotherPoint.xotherPoint.y
multiply
Returns a copy multiplied by the provided point
Parameters
otherPoint_PointotherPoint.xotherPoint.y
divide
Returns a copy divided by the provided point
Parameters
otherPoint_PointotherPoint.xotherPoint.y
clampX
Returns a copy with x clamped between the provided min and max
Parameters
Returns _Point
clampY
Returns a copy with y clamped between the provided min and max
Parameters
Returns _Point
invertX
Returns a copy with x inverted
Returns _Point
invertY
Returns a copy with y inverted
Returns _Point
invert
Returns a copy with both x and y inverted
Returns _Point
Point
Parameters
Examples
import { Point } from "bear.js"Returns _Point
_Rectangle
Rectangle class
Parameters
$0any$0.position$0.width$0.height
position
Rectangle top left position
Type: _Point
width
Rectangle's width
Type: number
height
Rectangle's height
Type: number
left
x position at the left edge
Returns number
right
x position at the right edge
Returns number
top
y position at the top edge
Returns number
bottom
y position at the bottom edge
Returns number
center
Returns a copy with its x value changed
Returns _Point
intersects
Checks if the rectangle intersect with the provided one
Parameters
otherRectangle_Rectangle
Returns boolean
Rectangle
Parameters
rectangleArgsObject
Examples
import { Rectangle } from "bear.js"Returns _Rectangle
sprite
Used in the render function
Parameters
spriteOptionsObject
Examples
import { sprite } from "bear.js"Returns SpriteObject
text
Used in the render function
Parameters
textOptionsObjecttextOptions.position_PointtextOptions.anchor_Point (optional, defaultPoint(0,0))textOptions.contentstring Text to be displayedtextOptions.stylePIXI.TextStyle http://pixijs.download/release/docs/PIXI.TextStyle.html
Examples
import { text } from "bear.js"Returns TextObject
