Skip to content

Commit

Permalink
Changing to restarting the game
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-tiger authored Mar 13, 2018
1 parent f86964e commit f98fd17
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
// Code for: https://youtu.be/cXgA1d_E-jY

var bird;
var pipes = [];
var pipes;
var score = 0;
var maxScore = 0;
var birdIcon;
var pipeBodySprite;
var bgImg;
var bgX = 0;
var bgX;
var gameisover = false;

function preload() {
Expand All @@ -21,8 +21,7 @@ function preload() {

function setup() {
createCanvas(600, 600);
bird = new Bird();
pipes.push(new Pipe());
reset();
}

function draw() {
Expand Down Expand Up @@ -89,6 +88,14 @@ function gameover() {
score = 0;
gameisover = true;
}

function reset() {
bgX = 0;
pipes = [];
bird = new Bird();
pipes.push(new Pipe());
}

function keyPressed() {
if (key == " ") {
bird.up();
Expand Down

0 comments on commit f98fd17

Please sign in to comment.