HTML and CSS Reference
In-Depth Information
this.UpdateBackground = function(canvas, position, fillArea,
deltaPosition) {
var left;
var top;
var width;
var height;
var xOffset = Math.abs(deltaPosition[0]) % this.texture.width;
var yOffset = Math.abs(deltaPosition[1]) % this.texture.height;
if(deltaPosition[0] < 0)
left = this.texture.width - xOffset;
else
left = xOffset;
if(deltaPosition[1] < 0)
top = this.texture.height - yOffset;
else
top = yOffset;
if(fillArea[0] < this.texture.width - left)
width = fillArea[0];
else
width = this.texture.width - left;
if(fillArea[1] < this.texture.height - top)
height = fillArea[1];
else
height = this.texture.height - top;
canvas.drawImage(this.texture, left, top, width, height,
position[0], position[1], width, height);
return [width, height];
}
var background, position, fillArea, deltaPosition;
this.Draw = function(deltaTime, canvas, deltaX, deltaY) {
background = [0, 0];
for (var y = 0; y < this.height; y += background[1]) {
for (var x = 0; x < this.width; x += background[0]) {
position = [this.x + x, this.y + y];
fillArea = [this.width - x, this.height - y];
deltaPosition = [0, 0];
 
Search WWH ::




Custom Search