Skip to content
Harsh Singh edited this page Jun 28, 2023 · 7 revisions

Installation

We have decided to use Native Javascript modules which are supported by most modern web browsers instead of using a module bundler in order to avoid any build steps. This decision was made in order to lower the barrier of entry so that even beginners to Javascript with little knowledge of ES6 can make games without having to learn a module bundler.

You can simply download the latest release and extract it in your working folder and you are all set to build a game using bottlecap.js

Basic Game Structure

You can use the Base Game class offered by bottlecap to give your game a structure. The Base Game class just offers a simple animation loop and some event hooks like init, update and render.

Example

import * as Bottlecap from 'https://unpkg.com/bottlecap@latest';

export default class MyGame extends Bottlecap.Game {

  init() {
    // it will be called for initializing the game state and preloading loading assets
  }

  update(dt) {
    // called every frame for updating the game state
  }

  render() {
    // called every frame for rendering the game graphics
  }

}