HTML and CSS Reference
In-Depth Information
this.type = type;
this.dx = 0;
this.dy = 0;
this.x = 0;
this.y = 0;
this.rotation = 0;
this.rotationInc = 0;
this.scoreValue = 0;
//ConsoleLog.log("create rock. Scale=" + this.scale);
switch(this.scale){
case 1:
this.width = 50;
this.height = 50;
break;
case 2:
this.width = 25;
this.height = 25;
break;
case 3:
this.width = 16;
this.height = 16;
break;
}
}
Rock.prototype.update = function(xmin,xmax,ymin,ymax) {
this.x += this.dx;
this.y += this.dy;
this.rotation += this.rotationInc;
if (this.x > xmax) {
this.x = xmin-this.width;
}else if (this.x<xmin-this.width){
this.x = xmax;
}
if (this.y > ymax) {
this.y = ymin-this.width;
}else if (this.y<ymin-this.width){
this.y = ymax;
}
}
Rock.prototype.draw = function(context) {
var angleInRadians = this.rotation * Math.PI / 180;
var halfWidth = Math.floor(this.width*.5); //used to find center of object
var halfHeight = Math.floor(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
Search WWH ::




Custom Search