Skip to content

Commit

Permalink
remove setup examples, now in FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel authored Nov 24, 2024
1 parent 60d9f0e commit 6fd7bad
Showing 1 changed file with 0 additions and 70 deletions.
70 changes: 0 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,76 +116,6 @@ To rebuild the engine you must first run ```npm install``` to setup the necessar

The starter example project includes a node js file [build.js](https://github.com/KilledByAPixel/LittleJS/blob/main/examples/starter/build.js) that compresses everything into a tiny zip file using Google Closure, UglifyJS, and ECT Zip.

## LittleJS Setup

To start LittleJS, you need to create these 5 functions and pass them to engineInit.

```javascript
function gameInit()
{
// called once after the engine starts up
// setup the game
}

function gameUpdate()
{
// called every frame at 60 frames per second
// handle input and update the game state
}

function gameUpdatePost()
{
// called after physics and objects are updated
// setup camera and prepare for render
}

function gameRender()
{
// called before objects are rendered
// draw any background effects that appear behind objects
}

function gameRenderPost()
{
// called after objects are rendered
// draw effects or hud that appear above all objects
}

// Startup LittleJS Engine
engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost);
```

## LittleJS Objects

LittleJS can be used as an object oriented system by extending the base class [EngineObject](https://github.com/KilledByAPixel/LittleJS/blob/main/src/engineObject.js) with your own. This lightweight class provides many useful features including physics, collision, parent/child system, and sorted rendering. These objects are added to the global list of objects where they will automatically be updated and rendered until destroyed.

Here is a template you can use to make objects that behave however you want. See the examples for a complete demonstration.

```javascript
class MyObject extends EngineObject
{
constructor(pos, size, tileInfo, angle)
{
super(pos, size, tileInfo, angle);
// setup object
}

update()
{
// update object physics and position
super.update();
}

render()
{
// draw object as a sprite
super.render();
}
}
```

## Debugging

Debug builds of LittleJS have a special menu that can be opened by pressing the Esc key.

## Games Made With LittleJS
Expand Down

0 comments on commit 6fd7bad

Please sign in to comment.