@g-gine/gamegine-client v1.1.3
Gamegine
Description โก
Modern typescript game engine with focus on type safety and easiness of use. It provides simple and clean API with entity-management and renderign capabilities.
More info on our website.
Documentation ๐
Complete documentation can be found here.
Examples ๐งช
Simple rectangle drawing
import { Gamegine, State, Entity, Drawing, Color, Point } from '@g-gine/gamegine-client';
class Player extends Entity {
private rect = new Drawing(this.position, 60, 60);
public onCreate(game: Gamegine) {
this.rect.setFillColor(Color.BLUE);
this.rect.fillRect(0, 0, 60, 60);
game.renderer.addChild(this.rect);
}
}
class StartState extends State {
public onCreate() {
const position = new Point(100, 100);
this.entities.add(new Player(position));
}
}
window.addEventListener('load', () => {
const game = new Gamegine('#canvas-selector'); // Change selector to your canvas
game.run(new StartState(game));
});
Loading and displaying texture
import { Gamegine, Assets, State, Entity, Sprite } from '@g-gine/gamegine-client';
class GoodLookingPlayer extends Entity {
private sprite: Sprite = new Sprite(this.position, Assets.textures.player);
public onCreate(game: Gamegine) {
game.renderer.addChild(this.sprite);
}
}
class StartState extends State {
public onCreate() {
const position = new Point(100, 100);
this.entities.add(new GoodLookingPlayer(position));
}
}
window.addEventListener('load', () => {
const opts = {
renderer: {
fullscreen: true, // sets fullscreen
pixelated: true // sets pixel-art graphics settings
}
}
const game = new Gamegine('#canvas-selector', opts); // Change selector to your canvas
const assets = {
textures: {
player: 'path/to/player.png'
}
};
// Await assets to load
Assets.load(assets)
.then(() => game.run(new StartState(game)));
});
Graphics ๐จ
Our engine implements graphics objects for basic use, such as: sprites, animation, text displays and so on. You can also easily implement your own renderables.
Entity management ๐งพ
Gamegine manages all entities for you. You simply add/remove entities to EntityManager, which will keep track of added entities and call respective methods in right time.
Traits ๐
Traits are classes that can extend behaviour of entities. This allows you to set same behaviour to different entities withou using complex inheretance.
For more examples and tutorials, visit our official websites.
Bugs and improvements ๐
When you find bug, please, contact me or place issue with complete bug report (way to reproduce bug, stack-trace of error, etc.) I would be aslo glad, if you suggest possible improvements.