๐ป bear.js - game engine using pixi.js to render. Inspired by ELM and Phaser.
Add bear.js with npm/yarn or use unpkg
Counter example, the very basics. Source
Pong built with bear.js. Source
Game init function
Parameters
GameArgs
ObjectGameArgs.state
any Initial state of the gameGameArgs.update
function Returns a new state each frameGameArgs.render
function Returns an array of sprite/text each frameGameArgs.textures
Array<{name: string, url: string}> List of textures that will be loaded before the game starts (optional, default[]
)GameArgs.options
Object Game options (optional, default{}
)
landingpad
Node
Examples
import { game } from "bear.js"
Returns Promise<PIXI.Application>
Point class
Parameters
x position
Type: number
y position
Type: number
The length of the point
Returns number
Returns a copy with its x value changed
Parameters
x
number
Returns _Point
Returns a copy with its y value changed
Parameters
y
number
Returns _Point
Returns a normalized copy
Returns _Point
Returns a normalized copy pointing towards the provided point
Parameters
otherPoint
_Point
Returns _Point
Returns a copy subtracted by the provided point
Parameters
otherPoint
_PointotherPoint.x
otherPoint.y
Returns _Point
Returns a copy subtracted by the provided point
Parameters
otherPoint
_PointotherPoint.x
otherPoint.y
Returns a copy multiplied by the provided point
Parameters
otherPoint
_PointotherPoint.x
otherPoint.y
Returns a copy divided by the provided point
Parameters
otherPoint
_PointotherPoint.x
otherPoint.y
Returns a copy with x clamped between the provided min and max
Parameters
Returns _Point
Returns a copy with y clamped between the provided min and max
Parameters
Returns _Point
Returns a copy with x inverted
Returns _Point
Returns a copy with y inverted
Returns _Point
Returns a copy with both x and y inverted
Returns _Point
Parameters
Examples
import { Point } from "bear.js"
Returns _Point
Rectangle class
Parameters
$0
any$0.position
$0.width
$0.height
Rectangle top left position
Type: _Point
Rectangle's width
Type: number
Rectangle's height
Type: number
x position at the left edge
Returns number
x position at the right edge
Returns number
y position at the top edge
Returns number
y position at the bottom edge
Returns number
Returns a copy with its x value changed
Returns _Point
Checks if the rectangle intersect with the provided one
Parameters
otherRectangle
_Rectangle
Returns boolean
Parameters
rectangleArgs
Object
Examples
import { Rectangle } from "bear.js"
Returns _Rectangle
Used in the render function
Parameters
spriteOptions
Object
Examples
import { sprite } from "bear.js"
Returns SpriteObject
Used in the render function
Parameters
textOptions
ObjecttextOptions.position
_PointtextOptions.anchor
_Point (optional, defaultPoint(0,0)
)textOptions.content
string Text to be displayedtextOptions.style
PIXI.TextStyle http://pixijs.download/release/docs/PIXI.TextStyle.html
Examples
import { text } from "bear.js"
Returns TextObject