From b25309b92d3e6d495713c53e6b259afd0472c8b7 Mon Sep 17 00:00:00 2001 From: "ivaylo.zhelev" Date: Sun, 24 Jan 2021 14:58:18 +0200 Subject: Restructured Folder --- scripts/gameObjects/tankShell.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/gameObjects/tankShell.js (limited to 'scripts/gameObjects/tankShell.js') diff --git a/scripts/gameObjects/tankShell.js b/scripts/gameObjects/tankShell.js new file mode 100644 index 0000000..5f87143 --- /dev/null +++ b/scripts/gameObjects/tankShell.js @@ -0,0 +1,31 @@ +var app = app || {}; + +class TankShell { + constructor(sprite, position, direction) { + this.sprite = sprite; + this.sprite.x = position.x; + this.sprite.y = position.y; + this.direction = direction; + } + + update() { + switch(this.direction) { + case "up": + this.sprite.y--; + break; + case "right": + this.sprite.x++; + break; + case "down": + this.sprite.y++; + break; + case "left": + this.sprite.x--; + break; + } + } + + draw() { + app.pixiApplication.stage.addChild(this.sprite); + } +} -- cgit v1.3.1-26-gb76a