2d游戏开发--FlappyBird与雷电
FlappyBird 游戏介绍:鼠标点击开始游戏,并控制小鸟的飞翔,躲避障碍物,飞向终点。 HTML代码如下: <html> <head> <meta charset="utf-8"> <title>Flappy Bird</title> </head> <body> <canvas id="canvas" width="340" height="453" style="border: 2px solid #000;background: #fff;"></canvas> <script src="js/bird.js" type="text/javascript"></script> </body> </html>``` JavaScript代码如下: var canvas = document.getElementById("canvas"); var c = canvas.getContext("2d"); //三个类,Bird类,Obstacle类,FlappyBird类(游戏主要函数) function Bird(x, y, image){ this.x = x; this.y = y; this.width = image.width / 2; this.height = image.height; this.image = image; this.draw =