Skip to content

Commit

Permalink
my version of pr #34
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool authored Mar 10, 2018
1 parent a085c5e commit 8c8066c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var pipeBodySprite;
var pipePeakSprite;
var bgImg;
var bgX = 0;
var pipetimer;

function preload() {
pipeBodySprite = loadImage("./graphics/pipe_body.png");
Expand All @@ -25,6 +26,7 @@ function setup() {
createCanvas(600, 600);
bird = new Bird();
pipes.push(new Pipe());
pipetimer = 0;
}

function draw() {
Expand Down Expand Up @@ -66,11 +68,13 @@ function draw() {
bird.update();
bird.show();

if (frameCount % 150 == 0) {
if (pipetimer >= 150) {
pipes.push(new Pipe());
pipetimer = 0;
}

showScores();
pipetimer++;
}

function showScores() {
Expand All @@ -84,7 +88,15 @@ function gameover() {
textSize(64);
text("HIT", width / 2, height / 2);
maxScore = max(score, maxScore);
restart();
}
function restart() {
score = 0;
bird = new Bird();
bgX = 0;
pipes = [];
pipes[0] = new Pipe();
pipetimer = 0;
}
function keyPressed() {
if (key == " ") {
Expand Down

1 comment on commit 8c8066c

@DaGuT
Copy link
Contributor

@DaGuT DaGuT commented on 8c8066c Mar 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dem, that's way better solution than mine with last death frame! :D

Please sign in to comment.