HTML and CSS Reference
In-Depth Information
camera . y = 0 ;
rowBuffer = 0 ;
} else
else iif ( camera . y > ( world . height - camera . height ) - scrollRate ) {
camera . y = world . height - camera . height ;
rowBuffer = 0 ;
} else
else {
rowBuffer = 1 ;
}
console . log ( "scrollRate=" , scrollRate );
var
var xDistance = ( world . width - camera . width ) - scrollRate ;
console . log ( "camera.x=" , camera . x );
console . log ( "(world.width - camera.width)-scrollRate =" , xDistance );
var
var yDistance = ( world . height - camera . height ) - scrollRate ;
console . log ( "camera.y=" , camera . y );
console . log ( "(world.height - camera.height)-scrollRate =" , yDistance );
console . log ( "colBuffer=" , colBuffer );
console . log ( "rowBuffer" , rowBuffer );
context . fillStyle = '#000000' ;
context . fillRect ( 0 , 0 , theCanvas . width , theCanvas . height );
//draw camera
//calculate starting tile position
var
var tilex = Math . floor ( camera . x / world . tileWidth );
var
var tiley = Math . floor ( camera . y / world . tileHeight );
var
var rowCtr ;
var
var colCtr ;
var
var tileNum ;
context . setTransform ( 1 , 0 , 0 , 1 , 0 , 0 );
context . translate ( - camera . x % world . tileWidth , - camera . y % world . tileHeight );
for
for ( rowCtr = 0 ; rowCtr < camera . rows + rowBuffer ; rowCtr ++ ) {
for
for ( colCtr = 0 ; colCtr < camera . cols + colBuffer ; colCtr ++ ) {
tileNum = ( world . map [ rowCtr + tiley ][ colCtr + tilex ]);
var
var tilePoint = {};
tilePoint . x = colCtr * world . tileWidth ;
tilePoint . y = rowCtr * world . tileHeight ;
var
var source = {};
Search WWH ::




Custom Search