项目作者: gejmko

项目描述 :
The TypeScript Micro 2D Game Engine: Small and lightweight 2D framework for creating browser based games.
高级语言: TypeScript
项目地址: git://github.com/gejmko/framework.git
创建时间: 2020-10-11T18:45:47Z
项目社区:https://github.com/gejmko/framework

开源协议:MIT License

下载


Gejmko — The TypeScript Micro 2D Game Engine

Gejmko-main Actions Status

The aim of this project is to provide a fast, micro and lightweight 2D framework for creating browser based games.
It’s fast and really simple.

Setup

Gejmko can be installed with npm.

NPM Install

  1. npm install gejmko

There is no default export. The correct way to import Gejmko is:

  1. import * as Gejmko from 'gejmko'

Contribute

Want to be part of the Gejmko project? Perfect! All are welcome!
Whether you find a bug, have a great feature request feel free to get in touch.

Make sure to read the Contributing Guide
before submitting changes.

Current features

  • Canvas renderer
  • Sprites
  • Styles

Basic Usage Example

  1. import * as Gejmko from '@gejmko/framework';
  2. const viewport = new Gejmko.Viewport('game-id-element');
  3. viewport.init();
  4. viewport.changeSize(300, 300);
  5. viewport.changeBorder(new Gejmko.Border(1, 'black', 'solid'));
  6. const game = new Gejmko.Game(viewport);
  7. game.start();
  8. class Circle extends Gejmko.AbstractEntity {
  9. x = 100;
  10. y = 75;
  11. render(): void {
  12. this.context.beginPath();
  13. this.context.arc(this.x, this.y, 50, 0, 2 * Math.PI);
  14. this.context.stroke();
  15. }
  16. update(): void {
  17. if (this.x - 50 >= 305) {
  18. this.x = -55;
  19. return;
  20. }
  21. this.x += 1;
  22. }
  23. }
  24. class MarioSprite extends Gejmko.Sprite {
  25. constructor() {
  26. super('assets/mario-sprite.png', 2, 16, 18, 3, 0, 0, 1);
  27. }
  28. update(): void {
  29. if (this.currentFrameNumber % 20 !== 0) {
  30. return;
  31. }
  32. super.update();
  33. }
  34. }
  35. game.addEntity(new MarioSprite());
  36. game.addEntity(new Circle());

How to build

Build the source, run:

  1. npm run build

License

This content is released under the (http://opensource.org/licenses/MIT) MIT License.