diff --git a/.prettierignore b/.prettierignore index d1f6971..8948a86 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,7 @@ **/.git **/node_modules **/dist +test/js/engine.js *.html *.css diff --git a/src/js/objects.js b/src/js/objects.js index 7f54d11..3cad4d9 100644 --- a/src/js/objects.js +++ b/src/js/objects.js @@ -95,8 +95,10 @@ export class Sprite { } export class TiledSprite extends Sprite { - constructor(src = null, x, y) { + constructor(src = null, x, y, only = null) { super(src, x, y); + + this.only = only; } draw(context, debug = false) { @@ -126,16 +128,24 @@ export class TiledSprite extends Sprite { break; } - context.drawImage( - this.image(), - this.x - this.image().width * ix, - this.y - this.image().height * iy - ); - context.drawImage( - this.image(), - this.x + this.image().width * ix, - this.y - this.image().height * iy - ); + switch (this.only) { + case 'y': + context.drawImage(this.image(), this.x, this.y - this.image().height * iy); + break; + case null: + default: + context.drawImage( + this.image(), + this.x + this.image().width * ix, + this.y - this.image().height * iy + ); + context.drawImage( + this.image(), + this.x - this.image().width * ix, + this.y - this.image().height * iy + ); + break; + } } } @@ -149,16 +159,24 @@ export class TiledSprite extends Sprite { break; } - context.drawImage( - this.image(), - this.x - this.image().width * ix, - this.y + this.image().height * iy - ); - context.drawImage( - this.image(), - this.x + this.image().width * ix, - this.y + this.image().height * iy - ); + switch (this.only) { + case 'y': + context.drawImage(this.image(), this.x, this.y + this.image().height * iy); + break; + case null: + default: + context.drawImage( + this.image(), + this.x + this.image().width * ix, + this.y + this.image().height * iy + ); + context.drawImage( + this.image(), + this.x - this.image().width * ix, + this.y + this.image().height * iy + ); + break; + } } } }