Last active
August 29, 2015 13:56
-
-
Save mrowdy/9077493 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]){ | |
_setupCanvas(); | |
} | |
void _setupCanvas(){ | |
_canvas = new CanvasElement(width: _width, height: _height ); | |
_ctx = _canvas.getContext('2d'); | |
_container.style.width = '${_width}px'; | |
_container.append(_canvas); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%; | |
} | |
.game-message.show { | |
display: block; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html'; | |
import 'game/minefield.dart'; | |
void main() { | |
Element container = querySelector('#container'); | |
Minefield minefield = new Minefield(container); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Minefield</title> | |
<link rel="stylesheet" type="text/css" href="minefield_tutorial.css"> | |
</head> | |
<body> | |
<!-- Game container --> | |
<div id="container"> | |
<h1>Minefield</h1> | |
</div> | |
<script type="application/dart" src="minefield_tutorial.dart"></script> | |
<script src="packages/browser/dart.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment