gamecore 1.0.1

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

1.0.0 #

  • Initial version, bootstraped with Stagehand as 'package-simple'
  • Featuring Keyboard and Canvas classes

example/example.dart

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();

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  gamecore: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:gamecore/main.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
92
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Aug 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: web

Primary library: package:gamecore/main.dart with components: html.

Health issues and suggestions

Document public APIs. (-1 points)

21 out of 21 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/main.dart.

Run dartfmt to format lib/main.dart.

Format lib/src/Canvas.dart.

Run dartfmt to format lib/src/Canvas.dart.

Format lib/src/Keyboard.dart.

Run dartfmt to format lib/src/Keyboard.dart.

Format lib/src/Loop.dart.

Run dartfmt to format lib/src/Loop.dart.

Maintenance suggestions

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
pedantic ^1.0.0
test ^1.0.0