Examples - Wire up Update Slider

This commit is contained in:
Marty Oehme 2018-07-20 19:19:24 +02:00
parent 7a87ad3749
commit 914b2aa5dd
4 changed files with 12 additions and 6 deletions

View file

@ -5,4 +5,8 @@ abstract class LoopExample{
void stop() {}
void start() {}
}
abstract class VariableUpdates {
double MS_PER_UPDATE = 300.0;
}

View file

@ -3,8 +3,8 @@ import 'dart:html';
import 'package:browserloop/game/Game.dart';
import 'package:browserloop/game/LoopExample.dart';
class FixedLoopVariableRender implements LoopExample {
static final double MS_PER_UPDATE = 1000.0;
class FixedLoopVariableRender implements LoopExample, VariableUpdates {
double MS_PER_UPDATE = 1000.0;
static final double SAFE_GUARD = 500.0;
Stopwatch elapsed = new Stopwatch();
double lag = 0.0;

View file

@ -3,8 +3,8 @@ import 'dart:html';
import 'package:browserloop/game/Game.dart';
import 'package:browserloop/game/LoopExample.dart';
class DirtyFlagRender implements LoopExample {
static final double MS_PER_UPDATE = 1000.0;
class DirtyFlagRender implements LoopExample, VariableUpdates {
double MS_PER_UPDATE = 1000.0;
static final double SAFE_GUARD = 500.0;
Stopwatch elapsed = new Stopwatch();
double lag = 0.0;

View file

@ -130,7 +130,9 @@ void addControls(Example ex) {
// Don't add controls which don't work anyways (for simple examples)
if(examples.indexOf(ex) <= 1) return;
VariableUpdates loop = (ex.loop as VariableUpdates);
// Update Speed Slider
group
..append(new LabelElement()
..htmlFor = "update_speed"
@ -138,11 +140,11 @@ void addControls(Example ex) {
..append(new InputElement(type: "range")
..id = "update_speed"
..min = "1"
..max = "20"
..max = "50"
..value = "3"
..step = "1"
..onInput.listen((Event e) {
ex.loop;
loop.MS_PER_UPDATE = (1000 / int.parse((e.target as InputElement).value));
}));
// querySelector('#reset').onClick.listen((e) => ex.loop.game.reset());
// querySelector('#plus').onClick.listen((e) => _changeGrid(-5));