Skip to content

psema4/littlejs-starter-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LittleJS Starter Kit

Status

Minimum Viable Product

Besides this readme and the source files, there are no docs, tests or optimizations yet. Here be Dragons.

About

This starter kit and mini-framework for LittleJS is intended to simplify the architecture for complex games. It supports running multiple LittleJS games simultaneously (if desired) by moving the game logic into runtime modules called GameScopes and iterating through these scopes in the game loop.

GameScope Example

For a minimalist example, see the Blank GameScope.

For a simple menu example, see the MainMenu GameScope.

GameScope Flags

Several flags are available to customize how GameScopes are executed:

Framework Enforced

  • scopedUpdate: If true, a GameScope will only have it's update method called if it is the currently active scope. Set to false to keep a scope running in the background.
  • scopedRender: If true, a GameScope will only have it's render method called if it is the currently active scope. Set to false if you want to keep rendering in the background.

Convention

The following GameScope properties should be checked in your GameScope's gameUpdate() handlers:

  • scopedKeyboard: If true, a GameScope should only process keyboard inputs when it is the active scope
  • scopedMouse: If true, a GameScope should only process mouse inputs when it is the active scope
  • scopedGamepad: If true, a GameScope should only process gamepad inputs when it is the active scope

Initial Setup

Note: Requires Node.js

git clone git@github.com:psema4/littlejs-starter-kit.git
cd littlejs-starter-kit
git checkout develop
npm i

Building & Running

Note: Requires Bash and Node.js

npm run build

Or to build and run the development server:

npm run server

and open a browser to http://localhost:8090/

Future Considerations

  • Multiple tile/sprite sets
  • Global, scoped timers & clocks
  • Common library functions (see also gameEffects.js from the LittleJS platformer example for a nice background generator)

Attributions