HTML and CSS Reference
In-Depth Information
Rock Object Prototype
Toconservespace,wedidnotcreateseparateobjectprototypesforthevariousdisplayobjects
in this game. However, Example 8-12 is a Rock prototype object that can be used in a game
such as Geo Blaster Basic .
Example 8-12. The Rock.js prototype
//*** Rock Object Prototype
function
function Rock ( scale , type ) {
//scale
//1 = large
//2 = medium
//3 = small
//these will be used as the divisor for the new size
//50/1 = 50
//50/2 = 25
//50/3 = 16
this
this . scale = scale ;
iif ( this
this . scale < 1 || this
this . scale > 3 ){
this
this . scale = 1 ;
}
this
this . type = type ;
this
this . dx = 0 ;
this
this . dy = 0 ;
this
this . x = 0 ;
this
this . y = 0 ;
this
this . rotation = 0 ;
this
this . rotationInc = 0 ;
this
this . scoreValue = 0 ;
//ConsoleLog.log("create rock. Scale=" + this.scale);
switch
switch ( this
this . scale ){
case
case 1 :
this
this . width = 50 ;
this
this . height = 50 ;
break
break ;
case
case 2 :
this
this . width = 25 ;
this
this . height = 25 ;
break
break ;
Search WWH ::




Custom Search