gamEZ
A small game engine for 2D games in Flutter.
Installation
gamez: ^0.0.3+1
Game creation
The purpose of this engine is to separate the logical and view/widget parts to give you the freedom to customize them as you wish.
Model creation
First, we have to create a game model which is responsible for the logical part of the game, such as adding/removing entities, managing gestures, etc.
class MyGame extends Game {
// ... Implement override methods ...
}
Then, we create a new character to our game by extending GameEntity
class MyCharacter extends GameEntity {
MyCharacter(Vector position, Size size) : super(position, size);
// ... Implement override methods ...
}
This new entity, can be added to the game using Game::addEntity(MyCharacter)
In order to detect gestures use GameEntity::handleGesture(position, gesture)
, where gesture
can be one of the following:
Gesture.tapDown
Gesture.doubleTapDown
Gesture.longPressMoveUpdate
Gesture.longPressStart
Gesture.longPressEnd
View creation
Second, we have to create a widget that extends from GameWidget
, then add your model to it.
class MyGameWidget extends GameWidget {
MyGameWidget() : super(game: MyGame());
}
You can also add another widget to your game widget by calling GameWidget::addChild(MyWidget)
Concrete example
You can give a look at Pawns game, a 2D game, that uses this game engine.
Features
x
Image renderer
Contributions
All contributions are warmly welcomed.