From 4c5d42ffa09ff6f394a8b3f6c06ed610d4fc64f9 Mon Sep 17 00:00:00 2001 From: DaGuT Date: Sat, 24 Mar 2018 20:03:40 +0700 Subject: [PATCH 1/2] added GAMEOVER with pause and restart on space press --- sketch.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sketch.js b/sketch.js index a128b6c..a23bc04 100644 --- a/sketch.js +++ b/sketch.js @@ -20,6 +20,7 @@ var pipePeakSprite; var bgImg; var bgX; var gameoverFrame=0; +var isOver = false; var touched = false; var prevTouched = touched; @@ -107,22 +108,28 @@ function showScores() { function gameover() { textSize(64); - text('HIT', width / 2, height / 2); + textAlign(CENTER,CENTER); + text('GAMEOVER', width / 2, height / 2); + textAlign(LEFT,BASELINE); maxScore = max(score, maxScore); - score = 0; - reset(); + isOver=true; + noLoop(); } function reset() { + isOver=false; + score = 0; bgX = 0; pipes = []; bird = new Bird(); pipes.push(new Pipe()); gameoverFrame=frameCount-1; + loop(); } function keyPressed() { if (key === ' ') { bird.up(); + if (isOver) reset(); //you can just call reset() in Machinelearning if you die, because you cant simulate keyPress with code. } } From 40a6165836795d5aa2f59726956b043e77784144 Mon Sep 17 00:00:00 2001 From: DaGuT Date: Sat, 24 Mar 2018 20:05:13 +0700 Subject: [PATCH 2/2] added mobile support --- sketch.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sketch.js b/sketch.js index a23bc04..967f72b 100644 --- a/sketch.js +++ b/sketch.js @@ -133,3 +133,7 @@ function keyPressed() { if (isOver) reset(); //you can just call reset() in Machinelearning if you die, because you cant simulate keyPress with code. } } + +function touchStarted() { + if (isOver) reset(); +} \ No newline at end of file