dartfmt Project
This commit is contained in:
parent
ba76f934a8
commit
5c2efd2fd9
8 changed files with 31 additions and 30 deletions
|
|
@ -65,11 +65,11 @@ class Game {
|
|||
|
||||
// Slightly oscillating colors to highlight rendering updates
|
||||
void _oscillate() {
|
||||
if(_oscill >= 50.0 || _oscill <= -50.0) {
|
||||
if (_oscill >= 50.0 || _oscill <= -50.0) {
|
||||
_oscillDir = !_oscillDir;
|
||||
_oscill = max( min(_oscill, 49.0), -49.0);
|
||||
}
|
||||
else _oscillDir == true ? _oscill += _OSCILLSPEED : _oscill -= _OSCILLSPEED;
|
||||
_oscill = max(min(_oscill, 49.0), -49.0);
|
||||
} else
|
||||
_oscillDir == true ? _oscill += _OSCILLSPEED : _oscill -= _OSCILLSPEED;
|
||||
}
|
||||
|
||||
Color _getOscillatedCol(Color col) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:browserloop/game/Game.dart';
|
||||
|
||||
abstract class LoopExample{
|
||||
abstract class LoopExample {
|
||||
Game game;
|
||||
|
||||
void stop() {}
|
||||
|
|
@ -9,4 +9,4 @@ abstract class LoopExample{
|
|||
|
||||
abstract class VariableUpdates {
|
||||
double MS_PER_UPDATE = 300.0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ void _demoSetup() {
|
|||
ctx.setFillColorRgb(rng.nextInt(255), rng.nextInt(255), rng.nextInt(255));
|
||||
};
|
||||
var _changeGrid = (int delta) {
|
||||
_clear();
|
||||
int newgrid = GRIDNUM + delta;
|
||||
GRIDNUM = (newgrid == 0) ? GRIDNUM : newgrid;
|
||||
_start();
|
||||
_clear();
|
||||
int newgrid = GRIDNUM + delta;
|
||||
GRIDNUM = (newgrid == 0) ? GRIDNUM : newgrid;
|
||||
_start();
|
||||
};
|
||||
_clear();
|
||||
|
||||
|
|
@ -55,10 +55,7 @@ void _demoSetup() {
|
|||
_start();
|
||||
});
|
||||
html.querySelector('#basic_stop').onClick.listen((e) => _stop());
|
||||
html
|
||||
.querySelector('#basic_reset')
|
||||
.onClick
|
||||
.listen((e) => _clear());
|
||||
html.querySelector('#basic_reset').onClick.listen((e) => _clear());
|
||||
html.querySelector('#basic_plus').onClick.listen((e) => _changeGrid(-5));
|
||||
html.querySelector('#basic_minus').onClick.listen((e) => _changeGrid(5));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@ class WhileLoop implements LoopExample {
|
|||
void start() {
|
||||
window.requestAnimationFrame(eventloop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,4 @@ class VariableTimestep implements LoopExample {
|
|||
elapsed.reset();
|
||||
window.requestAnimationFrame(eventloop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ class FixedLoopVariableRender implements LoopExample, VariableUpdates {
|
|||
}
|
||||
render(lag / MS_PER_UPDATE);
|
||||
id = window.requestAnimationFrame(eventloop);
|
||||
|
||||
}
|
||||
|
||||
void update() {
|
||||
|
|
@ -45,4 +44,4 @@ class FixedLoopVariableRender implements LoopExample, VariableUpdates {
|
|||
elapsed.reset();
|
||||
window.requestAnimationFrame(eventloop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,8 @@ class DirtyFlagRender implements LoopExample, VariableUpdates {
|
|||
update();
|
||||
lag -= MS_PER_UPDATE;
|
||||
}
|
||||
if(dirty) render(lag / MS_PER_UPDATE);
|
||||
if (dirty) render(lag / MS_PER_UPDATE);
|
||||
id = window.requestAnimationFrame(eventloop);
|
||||
|
||||
}
|
||||
|
||||
void update() {
|
||||
|
|
@ -51,4 +50,4 @@ class DirtyFlagRender implements LoopExample, VariableUpdates {
|
|||
elapsed.reset();
|
||||
window.requestAnimationFrame(eventloop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue