/*********************
Make the Flappy Birds
*********************/
//game variables
//BIRD VARIABLES
var maxVel = 10; //bird max falling velocity
var vel = 2; //bird falling velocity--should be less than maxVel
var velInc = 0.7; //change in bird velocity--should be less than 1
var flyingVel = 8; //distance bird will move up when he flaps wings
var birdSize = 64; //size of bird
var birdX = 190; //bird x location
var birdY = 190; //bird starting y location
var birdAnimationRate = 15; //animation speed for bird
//obstacle VARIABLES
var spd = 3; //obstacle speed
var pipeWidth = 64; //width of pipe
var pipeDistance = 100; //distance between pipes
var numobstacles = 100; //number of sets of different obstacles in game
//SCORE VARAIBLES
var scoreSize = 50; //font size for score
var scoreX = 465; //x position of score
var scoreY = 5; //y position of score
var scoreColor = "white"; //color of score
//FRAME RATE
var frameRate = 30;
//ARE YOU PLAYING ON A PHONE?
var mobile = false;
//////////////////////////
//change to your images vvvv
//////////////////////////
var birdImage = "https://s22.postimg.org/9frj47rxt/TURTLE.png";
var topPipeImage = "https://s14.postimg.org/j8h6ck81t/image.png";
var bottomPipeImage = "https://s18.postimg.org/bdovoqi6h/image.png";
var backgroundImage = "https://s12.postimg.org/ednnufe71/image.jpg";
/***********
Game Methods
***********/
/***********
Initialize game and reset all variables
************/
function init() {
clearInterval(thread);
playing = false;
score = 0;
//initialize bird
bird = new Bird();
//initialize all the obstacles
for (i = 0; i < numobstacles; i += 2) {
//calculate x position of the pipe
var x = (i * pipeDistance) + 500 + (pipeWidth*i/2);
//random distance between top and bottom pipes
var dist = Math.round(Math.random() * 100) + 100;
//random height of top pipe
var height = Math.ceil(Math.random() * 4) * 50 + 50;
//add the top pipe
obstacles[i] = new obstacle(height, x, 0,...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.