https://github.com/decorator-factory/pixijs-example-breakout
Example breakout game made using PIXI.js
https://github.com/decorator-factory/pixijs-example-breakout
Last synced: 9 months ago
JSON representation
Example breakout game made using PIXI.js
- Host: GitHub
- URL: https://github.com/decorator-factory/pixijs-example-breakout
- Owner: decorator-factory
- License: mit
- Created: 2020-10-05T20:30:27.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-07T02:18:48.000Z (about 5 years ago)
- Last Synced: 2025-04-01T17:23:03.596Z (9 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pixijs-example-breakout
Example breakout game made using PIXI.js
Try it out at: https://decorator-factory.github.io/pixijs-example-breakout/
# Game lifecycle
1. Instantiate the application
2. Load static resources using `game/load`
3. Call `game/setup` on the application to get the initial state
4. Run the game loop
## Game loop lifecycle
1. For each actor, `onStep` is called with the appropriate arguments.
2. Each actor scheduled for deletion is removed from `actors`.
3. Actors scheduled for creation are created.
4. Go to step 1.
# Actor interface
Each Actor must have three fields:
- `type : string` -- name of the actor type, must be the same as
the constructor name;
- `onStep : (options) => void` -- the update handler
- `onDestroy : (options) => void` -- the destruction handler
## `onStep` options:
- `delta : number` -- lag between frames, in ms
- `app : PIXI.Application` -- the application instance singleton
- `state : State` -- the game state
- `destroy : (actor?) => void` -- function that schedules an
actor (or self if the actor is not specified) for removal
- `create : (() => Actor) => void` -- function that schedules
an actor for creation
- `ofType : (string) => Array` -- get the array of all the
actors belonging to a certain type. Calls are cached during a single frame.
## `onDestroy` options:
- `app : PIXI.Application`
- `state : State`
## `State` members:
- `actors : Array` -- array of all the actors. Don't add or remove items directly.
- `frame : BigInt` -- current frame number
- `_ofTypeCache` -- cache for the `ofType` function