dartfmt Project

This commit is contained in:
Marty Oehme 2018-07-24 13:35:25 +02:00
parent ba76f934a8
commit 5c2efd2fd9
8 changed files with 31 additions and 30 deletions

View File

@ -68,8 +68,8 @@ class Game {
if (_oscill >= 50.0 || _oscill <= -50.0) { if (_oscill >= 50.0 || _oscill <= -50.0) {
_oscillDir = !_oscillDir; _oscillDir = !_oscillDir;
_oscill = max(min(_oscill, 49.0), -49.0); _oscill = max(min(_oscill, 49.0), -49.0);
} } else
else _oscillDir == true ? _oscill += _OSCILLSPEED : _oscill -= _OSCILLSPEED; _oscillDir == true ? _oscill += _OSCILLSPEED : _oscill -= _OSCILLSPEED;
} }
Color _getOscillatedCol(Color col) { Color _getOscillatedCol(Color col) {

View File

@ -55,10 +55,7 @@ void _demoSetup() {
_start(); _start();
}); });
html.querySelector('#basic_stop').onClick.listen((e) => _stop()); html.querySelector('#basic_stop').onClick.listen((e) => _stop());
html html.querySelector('#basic_reset').onClick.listen((e) => _clear());
.querySelector('#basic_reset')
.onClick
.listen((e) => _clear());
html.querySelector('#basic_plus').onClick.listen((e) => _changeGrid(-5)); html.querySelector('#basic_plus').onClick.listen((e) => _changeGrid(-5));
html.querySelector('#basic_minus').onClick.listen((e) => _changeGrid(5)); html.querySelector('#basic_minus').onClick.listen((e) => _changeGrid(5));
} }

View File

@ -23,7 +23,6 @@ class FixedLoopVariableRender implements LoopExample, VariableUpdates {
} }
render(lag / MS_PER_UPDATE); render(lag / MS_PER_UPDATE);
id = window.requestAnimationFrame(eventloop); id = window.requestAnimationFrame(eventloop);
} }
void update() { void update() {

View File

@ -24,7 +24,6 @@ class DirtyFlagRender implements LoopExample, VariableUpdates {
} }
if (dirty) render(lag / MS_PER_UPDATE); if (dirty) render(lag / MS_PER_UPDATE);
id = window.requestAnimationFrame(eventloop); id = window.requestAnimationFrame(eventloop);
} }
void update() { void update() {

View File

@ -9,10 +9,14 @@ import 'package:browserloop/src/05_DirtyFlagRendering.dart';
CanvasElement baseCanvas = new CanvasElement(width: 480, height: 480); CanvasElement baseCanvas = new CanvasElement(width: 480, height: 480);
List<Example> examples = [ List<Example> examples = [
Example("While Loop Example", "#while_loop", new WhileLoop(new Game(baseCanvas))), Example(
Example("Variable Timestep", "#variable_timestep", new VariableTimestep(new Game(baseCanvas))), "While Loop Example", "#while_loop", new WhileLoop(new Game(baseCanvas))),
Example("Fixed Update, Variable Render", "#fixed_variable", new FixedLoopVariableRender(new Game(baseCanvas))), Example("Variable Timestep", "#variable_timestep",
Example("Variable Render with Dirty Flag", "#dirty_flag", new DirtyFlagRender(new Game(baseCanvas))) new VariableTimestep(new Game(baseCanvas))),
Example("Fixed Update, Variable Render", "#fixed_variable",
new FixedLoopVariableRender(new Game(baseCanvas))),
Example("Variable Render with Dirty Flag", "#dirty_flag",
new DirtyFlagRender(new Game(baseCanvas)))
]; ];
LoopExample active; LoopExample active;
@ -27,6 +31,7 @@ class Example {
if (loop != null) return loop.game.canvas; if (loop != null) return loop.game.canvas;
return new CanvasElement(width: 480, height: 480); return new CanvasElement(width: 480, height: 480);
} }
set canvas(CanvasElement canvas) { set canvas(CanvasElement canvas) {
if (loop != null) loop.game.canvas = canvas; if (loop != null) loop.game.canvas = canvas;
} }
@ -145,7 +150,8 @@ void addControls(Example ex) {
..value = "3" ..value = "3"
..step = "1" ..step = "1"
..onInput.listen((Event e) { ..onInput.listen((Event e) {
loop.MS_PER_UPDATE = (1000 / int.parse((e.target as InputElement).value)); loop.MS_PER_UPDATE =
(1000 / int.parse((e.target as InputElement).value));
})); }));
// querySelector('#reset').onClick.listen((e) => ex.loop.game.reset()); // querySelector('#reset').onClick.listen((e) => ex.loop.game.reset());
// querySelector('#plus').onClick.listen((e) => _changeGrid(-5)); // querySelector('#plus').onClick.listen((e) => _changeGrid(-5));