diff --git a/src/index.html b/src/index.html
index 81ac2ff..c8d1a91 100644
--- a/src/index.html
+++ b/src/index.html
@@ -40,6 +40,7 @@
let curUI;
let startUI;
let endUI;
+let dt = 1;
function registerBook(ctx, bookFileName){
@@ -86,11 +87,11 @@
}
update(){
- this.x -= SCROLLSPEED;
+ this.x -= SCROLLSPEED * dt;
if (showPipesDebug) this.debugRectangle.x = this.x;
// Moves books to the left
this.books.forEach(book => {
- book.x -= SCROLLSPEED;
+ book.x -= SCROLLSPEED * dt;
});
// Check if pipe is past owl
@@ -305,9 +306,10 @@
}
}
-function update() {
+function update(time, delta) {
+ dt = delta / 16.5;
if (!GAMEENDED){
- bg.tilePositionX += SCROLLSPEED; // keep the background moving!
+ bg.tilePositionX += SCROLLSPEED * dt; // keep the background moving!
}
if (GAMESTATE === "UI"){
curUI.update();
@@ -341,7 +343,7 @@
function managePiping(ctx) {
if (lastPipeSpawn > 0){
- lastPipeSpawn -= SCROLLSPEED;
+ lastPipeSpawn -= SCROLLSPEED * dt;
} else {
// Spawn new pipe
lastPipeSpawn = pipeSpawnDelay;