Skip to content

Instantly share code, notes, and snippets.

@Slemgrim Slemgrim/minefield.dart
Last active Aug 29, 2015

What would you like to do?
library minefield;
import 'dart:html';
class Minefield {
int _width; // Width of canvas
int _height; // Height of canvas
Element _container;
CanvasElement _canvas;
CanvasRenderingContext2D _ctx;
Minefield(this._container, [this._width = 320, this._height = 320]){
void _setupCanvas(){
_canvas = new CanvasElement(width: _width, height: _height );
_ctx = _canvas.getContext('2d'); = '${_width}px';
body {
margin: 0;
padding: 0;
background: #395D33;
color: #ffffff;
h1 {
text-align: center;
#container {
margin: 0 auto;
position: relative;
canvas {
display: block;
margin: 10px auto;
.game-message {
display: none;
width: 100%;
font-size: 60px;
text-align: center;
position: absolute;
top: 50%;
} {
display: block;
import 'dart:html';
import 'game/minefield.dart';
void main() {
Element container = querySelector('#container');
Minefield minefield = new Minefield(container);
<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="minefield_tutorial.css">
<!-- Game container -->
<div id="container">
<script type="application/dart" src="minefield_tutorial.dart"></script>
<script src="packages/browser/dart.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.