/*********************
Make the Flappy Birds
*********************/
//game variables
//BIRD VARIABLES
var maxVel = 5; //bird max falling velocity--increse to make bird fall
var vel = 3; //bird initial falling velocity--should be less than or equal to maxVel
var velInc = 0.5; //change in bird velocity--should be less than maxVel, probably less than 1
var flyingVel = 3; //distance bird will move up when he flaps wings--increase to fly
var birdSize = 64; //size of bird
var birdX = 0; //bird x location
var birdY = 0; //bird starting y location
var birdAnimationRate = 10; //animation speed for bird
//obstacle VARIABLES
var spd = 5; //obstacle speed--increase to move pipes faster
var pipeWidth = 64; //width of pipe
var pipeDistance =5; //distance between pipes--increase to have separation
var pipeGap = 5; //minimum gap between set of pipes--increase to pass through gaps
var numobstacles = 1; //number of sets of different obstacles in game
//SCORE VARAIBLES
var scoreSize = 5; //font size for score
var scoreX = 0; //x position of score
var scoreY = 0; //y position of score
var scoreColor = ""; //color of score
//FRAME RATE
var frameRate = 30; //increase to speed up the game
//ARE YOU PLAYING ON A PHONE?
var mobile = false;
//////////////////////////
//change to your images vvvv
//////////////////////////
var birdImage = "https://i.postimg.cc/FHSZwt5t/ugly_bird_copy.png"; //the bird
var pipeImage = "https://i.postimg.cc/VkzQkFYV/pipe_sprite.png"; //the pipes
var backgroundImage = "https://i.postimg.cc/wM29242n/flappybirdbackround.png"; //the background
/***********
Game Methods
***********/
/***********
Initialize game and reset all variables
************/
function init() {
clearInterval(thread);
playing = false;
score = 0;
vel = initVel;
//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...
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.