actually letting the horses finish the race now

This commit is contained in:
2019-07-24 00:10:01 -05:00
parent c6be668a59
commit 1b31f9cd15
2 changed files with 25 additions and 17 deletions

14
game.js
View File

@@ -34,6 +34,7 @@ const horses = [];
const finalPlaces = [];
let finishLineScan = 0;
let fanfarePlayedFlag = false;
// sound effect triggers
@@ -78,6 +79,11 @@ function gameLoop(){
break;
case "finished":
//quick and dirty fanfare check
if (!fanfarePlayedFlag){
playFanfare();
fanfarePlayedFlag = true;
}
CTX.clearRect(0, 0, WIDTH, HEIGHT);
drawResults(BG_CTX, WIDTH, HEIGHT, horseHeight, finalPlaces);
default:
@@ -194,9 +200,13 @@ function runRace(ctx,bg_ctx){
}
// horses.splice(foundHorseIndex);
if (finalPlaces.length === 4){
gameState = "finished";
// gameState = "finished";
stopGallop();
playFanfare();
// this will actually set the gamestate to finished for every frame, but it shouldnt matter since the gamestate never goes anywhere after finsihed
setTimeout(() => {
gameState = "finished";
}, 2000)
}
finishLineScan -= finishLineSpeed;
}