flappy 1.0 - JSFiddle

Make your own flappy

by DavisC_WL

HTML

<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;"></canvas>

JavaScript

/*********************
Make the Flappy Birds
*********************/
//game variables
//BIRD VARIABLES
var maxVel = 10; //bird max falling velocity--increse to make bird fall
var vel = 2; //bird initial falling velocity--should be less than or equal to maxVel
var velInc = 1; //change in bird velocity--should be less than maxVel, probably less than 1
var flyingVel = 10; //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 = 30; //animation speed for bird
//obstacle VARIABLES
var spd = 10; //obstacle speed--increase to move pipes faster 
var pipeWidth = 64; //width of pipe
var pipeDistance = 190; //distance between pipes--increase to have separation
var pipeGap = 175;	//minimum gap between set of pipes--increase to pass through gaps
var numobstacles = 1000; //number of sets of different obstacles in game
//SCORE VARAIBLES
var scoreSize = 50; //font size for score
var scoreX = 0; //x position of score
var scoreY = 0; //y position of score
var scoreColor = "white"; //color of score
//FRAME RATE
var frameRate = 35; //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/RhKFZmGb/davisc_flappysprites_raw.png"; //the bird
var pipeImage = "https://i.postimg.cc/PfYrZtzS/Davis_C_Flappy_Bird_Pipes.jpg"; //the pipes
var backgroundImage = "https://i.postimg.cc/7ZsxDbwZ/Davis_C_Flappy_Bird_BG.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)...