flappy bird test
Flappy !!!!!
by Kyle Bezio
HTML
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;"></canvas>
JavaScript
var canvas;
var context;
var thread;
var rot = 0; //rotation speed
var radius = 20 //radius of robot to wheels
var Yspeed = 0;
var Xspeed = 0;
var angle1 = 0;
var angle2 = 0;
var angle3 = 0;
var angle4 = 0;
var speed1 = 0;
var speed2 = 0;
var speed3 = 0;
var speed4 = 0;
var rotpos = 0; //rotation position
var robY = 250;
var robX = 250;
function init() {
clearInterval(thread);
canvas = document.getElementById("myCanvas");
context = canvas.getContext("2d");
//initiate the procedure!!!
thread = setInterval(draw, 20);
}
init();
/**
draw the game
**/
function draw() {
context.fillStyle = "red";
context.fillRect(0, 0, 500, 500);
context.fillStyle = "black";
context.rotate(angle1);
context.fillRect(pos1 - 5, pos1);
context.rotate(-angle1);
context.rotate(angle2);
context.fillRect();
context.rotate(-angle2);
context.rotate(angle3);
context.fillRect();
context.rotate(-angle3);
context.rotate(angle4);
context.fillRect();
context.rotate(-angle4);
}
/**
key controls
**/
document.onkeydown = function (e) {
//capture the event
e = window.event || e;
//get the key code
var key = e.keyCode;
//prevent default event behavior
e.preventDefault();
};