gamecore 1.0.1 gamecore: ^1.0.1 copied to clipboard
A starting point for Dart libraries or applications.
Core #
Dart library for HTML5 Canvas 2D web game development. Super lean framework with essential utilities.
Usage #
A simple usage example:
import 'package:gamecore/main.dart';
import 'dart:html';
Keyboard keyboard = Keyboard(); // Core is listening for keystrokes from now.
Canvas canvas = Canvas(
backgroundColor: '#FFFFFF', // Default value: '#000000'
canvasSelector: '#my-game-canvas', // Default value: '#canvas'
);
main() {
// Keyboard API: Check if CTRL is pressed
bool isCtrlPressed = keyboard.isPressed(KeyCode.CTRL);
// Canvas API: Let's a 50 x 50 red rectangle in the center of the screen
canvas.ctx.fillStyle = 'red';
canvas.ctx.fillRect(
canvas.element.width / 2 - 25,
canvas.element.height / 2 - 25,
50, 50
);
// Loop API: Example
int x;
void gameLoop() {
canvas.ctx.fillStyle = isCtrlPressed ? 'green' : 'red';
canvas.ctx.fillRect(x, canvas.element.height / 2 - 5, 10, 10);
x += 1;
}
// Let's play
Loop(gameLoop, 60)..start();
}
Features and bugs #
Please file feature requests and bugs at the [issue tracker][tracker]. [tracker]: http://example.com/issues/replaceme