flappy 4.1
Make your own flappy
by Kyle Bezio
HTML
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;"></canvas>
<audio src = "https://drive.google.com/uc?export=download&id=0B79Zz2TplH8walE3Vi1mOWsydWM" autoplay loop>
</audio>
JavaScript
/*********************
Make the Flappy Birds
*********************/
//game variables
//BIRD VARIABLES
var maxVel = 10; //bird max falling velocity
var vel = 1; //bird falling velocity--should be less than maxVel
var velInc = 1; //change in bird velocity--should be less than 1
var flyingVel = 10; //distance bird will move up when he flaps wings
var birdSize = 32; //size of bird
var birdX = 100; //bird x location
var birdY = 250; //bird starting y location
var birdAnimationRate = 5; //animation speed for bird
//obstacle VARIABLES
var spd = 2; //obstacle speed
var pipeWidth = 64; //width of pipe
var pipeDistance = 100; //distance between pipes
var numobstacles = 10; //number of sets of different obstacles in game
//SCORE VARAIBLES
var scoreSize = 0; //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;
//ARE YOU PLAYING ON A PHONE?
var mobile = false;
//////////////////////////
//change to your images vvvv
//////////////////////////
var birdImage = "https://s11.postimg.org/9w474jiur/Flappy_Toaster_Sprite.png";
var topPipeImage = "https://s10.postimg.org/i4ukvrdyx/Flappy_Toaster_Obsticle_Top.png";
var bottomPipeImage = "http://s12.postimg.org/k7b1gvnct/Flappy_Toaster_Obsticle.png";
var backgroundImage = "https://s12.postimg.org/ltnj421h9/Flappy_Toaster_Backup_Background.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;
...