0.1.3 ā€¢ Published 6 years ago

bear.js v0.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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

  • GameArgs Object
    • GameArgs.state any Initial state of the game
    • GameArgs.update function Returns a new state each frame
    • GameArgs.render function Returns an array of sprite/text each frame
    • GameArgs.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 {})
      • GameArgs.options.width number Game width (optional, default 500)
      • GameArgs.options.height number Game height (optional, default 500)
      • GameArgs.options.backgroundColor number Game background color (optional, default 0x111111)
  • landingpad Node

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

Returns _Point

setY

Returns a copy with its y value changed

Parameters

Returns _Point

normalize

Returns a normalized copy

Returns _Point

directionTo

Returns a normalized copy pointing towards the provided point

Parameters

Returns _Point

add

Returns a copy subtracted by the provided point

Parameters

  • otherPoint _Point
    • otherPoint.x
    • otherPoint.y

Returns _Point

subtract

Returns a copy subtracted by the provided point

Parameters

  • otherPoint _Point
    • otherPoint.x
    • otherPoint.y

multiply

Returns a copy multiplied by the provided point

Parameters

  • otherPoint _Point
    • otherPoint.x
    • otherPoint.y

divide

Returns a copy divided by the provided point

Parameters

  • otherPoint _Point
    • otherPoint.x
    • otherPoint.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

  • $0 any
    • $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

Returns boolean

Rectangle

Parameters

  • rectangleArgs Object
    • rectangleArgs.position _Point Upper left position of the rectangle
    • rectangleArgs.width number Width of the rectangle
    • rectangleArgs.height number Height of the rectangle

Examples

import { Rectangle } from "bear.js"

Returns _Rectangle

sprite

Used in the render function

Parameters

  • spriteOptions Object
    • spriteOptions.position _Point
    • spriteOptions.anchor _Point (optional, default Point(0,0))
    • spriteOptions.texture string name of loaded texture

Examples

import { sprite } from "bear.js"

Returns SpriteObject

text

Used in the render function

Parameters

Examples

import { text } from "bear.js"

Returns TextObject

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago