https://github.com/harshdoesdev/sodacan
Hypercasual Game Framework
https://github.com/harshdoesdev/sodacan
Last synced: 11 months ago
JSON representation
Hypercasual Game Framework
- Host: GitHub
- URL: https://github.com/harshdoesdev/sodacan
- Owner: harshdoesdev
- License: mit
- Created: 2022-06-21T07:22:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-22T06:09:38.000Z (over 3 years ago)
- Last Synced: 2024-01-05T05:08:18.312Z (about 2 years ago)
- Language: TypeScript
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sodacan
Hypercasual Game Framework
## Installation
```bash
npm i sodacan
```
## Example
game.js
```javascript
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
```javascript
import { runGame } from 'sodacan';
import Game from './game.js';
const game = new Game();
const config = {
el: '#app',
background: 'black'
};
runGame(game, config);
```