HTML and CSS Reference
In-Depth Information
context . save (); //save current state in stack
context . setTransform ( 1 , 0 , 0 , 1 , 0 , 0 ); // reset to identity
//translate the canvas origin to the center of the player
context . translate ( x + . 5 * width , y + . 5 * height );
context . rotate ( angleInRadians );
//drawShip
context . strokeStyle = '#ffffff' ;
context . beginPath ();
//hardcoding in locations
//facing right
context . moveTo ( - 10 , - 10 );
context . lineTo ( 10 , 0 );
context . moveTo ( 10 , 1 );
context . lineTo ( - 10 , 10 );
context . lineTo ( 1 , 1 );
context . moveTo ( 1 , - 1 );
context . lineTo ( - 10 , - 10 );
context . stroke ();
context . closePath ();
//restore context
context . restore (); //pop old state on to screen
}
var
var FRAME_RATE = 40 ;
var
var intervalTime = 1000 / FRAME_RATE ;
gameLoop ();
function
function gameLoop () {
drawScreen ();
window . setTimeout ( gameLoop , intervalTime );
}
document . onkeydown = function
function ( e ){
e = e ? e : window . event ;
//ConsoleLog.log(e.keyCode + "down");
keyPressList [ e . keyCode ] = true
true ;
}
document . onkeyup = function
function ( e ){
//document.body.onkeyup = function(e){
Search WWH ::




Custom Search