sodacan
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

Sodacan

Hypercasual Game Framework

Installation

npm i sodacan

Example

game.js

export default class Game {

    // called once for initialization
    init() {
        this.player = {
        x: 0,
        y: 0,
        width: 50,
        height: 50
        };

        console.log('Game Initialized');
    }

    // called everytime when a key is pressed
    keyDown(key) {
        console.log(`Key Pressed: ${key}`);
    }

    // called everytime when a key is released
    keyUp(key) {
        console.log(`Key Released: ${key}`);
    }

    // called every frame to update the game
    update(dt) {
        this.player.x += 50 * dt;
        this.player.y += 50 * dt;
    }

    // called every frame to draw the game
    draw(ctx) {
        ctx.fillStyle = 'white';
        ctx.fillRect(this.player.x, this.player.y, this.player.width, this.player.height);
    }

}

main.js

import { runGame } from 'sodacan';
import Game from './game.js';

const game = new Game();

const config = {
  el: '#app',
  background: 'black'
};

runGame(game, config);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.93latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.93
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i sodacan

Weekly Downloads

3

Version

0.0.9

License

MIT

Unpacked Size

28.7 kB

Total Files

35

Last publish

Collaborators

  • rwbeast