HTML and CSS Reference
In-Depth Information
case
case 3 :
this
this . width = 16 ;
this
this . height = 16 ;
break
break ;
}
}
Rock . prototype . update = function
function ( xmin , xmax , ymin , ymax ) {
this
this . x += this
this . dx ;
this
this . y += this
this . dy ;
this
this . rotation += this
this . rotationInc ;
iif ( this
this . x > xmax ) {
this
this . x = xmin - this
this . width ;
} else
else iif ( this
this . x < xmin - this
this . width ){
this
this . x = xmax ;
}
iif ( this
this . y > ymax ) {
this
this . y = ymin - this
this . width ;
} else
else iif ( this
this . y < ymin - this
this . width ){
this
this . y = ymax ;
}
}
Rock . prototype . draw = function
function ( context ) {
var
this . rotation * Math . PI / 180 ;
var
var halfWidth = Math . floor ( this
this . width * . 5 ); //used to find center of object
var
var halfHeight = Math . floor ( this
this . height * . 5 ) // used to find center of object
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 ( this
this . x + halfWidth , this
this . y + halfHeight );
context . rotate ( angleInRadians );
context . strokeStyle = '#ffffff' ;
context . beginPath ();
// draw everything offset by 1/2. Zero Relative 1/2 is if .5*width −1.
// Same for height
context . moveTo ( - ( halfWidth - 1 ), - ( halfHeight - 1 ));
context . lineTo (( halfWidth - 1 ), - ( halfHeight - 1 ));
context . lineTo (( halfWidth - 1 ),( halfHeight - 1 ));
Search WWH ::

Custom Search