JSFiddle - React, Tailwind, and code Playground

by soggydoughnut54

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 = 7; //bird max falling velocity
var vel = 0.5; //bird initial falling velocity--should be less than or equal to maxVel
var velInc = 0.05; //change in bird velocity--should be less than maxVel, probably less tha
var flyingVel = 2; //distance bird will move up when it flaps wings
var birdSize = 64; //size of bird
var birdX = 0; //bird x location
var birdY = 0; //bird starting y location
var birdAnimationRate = 50; //animation speed for bird
//obstacle VARIABLES
var spd = 2 ; //obstacle speed
var pipeWidth = 50; //width of pipe
var pipeDistance = 100; //distance between pipes
var pipeGap = 100; //minimum gap between set of pipes
var numobstacles = 1000; //number of sets of different obstacles in game
var pipeYLocations = []; //set the y location of gaps in sets of pipes
//SCORE VARAIBLES
var scoreSize = 50; //font size for score
var scoreX = 250; //x position of score
var scoreY = 0; //y position of score
var scoreColor = "black"; //color of score
//FRAME RATE
var frameRate = 120;
//ARE YOU PLAYING ON A PHONE?
var mobile = false;
//////////////////////////
//change to your images vvvv
//////////////////////////
var birdImage = "https://imgur.com/YVOWfgZ.png"; //the bird
var pipeImage = "https://imgur.com/Hth9uKq.png"; //the pipes
var backgroundImage = "https://imgur.com/UmTdGV9.png"; //the background

/***********
Game Methods
***********/
/********
draw the game
********/
function draw() {
  //clear the screen
  context.clearRect(0, 0, 500, 500);
  //draw the bg
  //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 context.drawImage(backgroundImage, 0, 0, 500, 500);
  //draw bird here
  //vvvvvvvvvvvvvvvvvvvvvvvvvvv
 // context.drawImage(birdImage, 0, 0, 500, 500);
 bird.draw();
  //move and redraw if playing game
  //all the obstacles in the array should draw
  obstacles.forEach(function(obstacle) {
    //draw obstacle here
    //vvvvvvvvvvvvvvvvvvvvvvvvvvvv
   ...