diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-24 17:58:20 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-24 17:58:20 +0100 |
commit | 25adfc618e77db9a5ee3b98ce0dab0be832efed0 (patch) | |
tree | 36ca56758ddd4674ab5a43df4b76bbfcc5a47af1 /src/entities/entity.js | |
parent | a840990bdcabf45fb0d377478ba0ab27222434ae (diff) |
hello kitty base done
Diffstat (limited to 'src/entities/entity.js')
-rw-r--r-- | src/entities/entity.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/entities/entity.js b/src/entities/entity.js index ac14d4b..9d27508 100644 --- a/src/entities/entity.js +++ b/src/entities/entity.js @@ -1,5 +1,6 @@ import { Vector } from "../engine/vector.js" import { Engine } from "../engine.js" +import { entities } from "../main.js" export class Entity { constructor({ @@ -7,6 +8,7 @@ export class Entity { hitbox = size, sprite, position = new Vector(0,0), + pixelated = false, }) { this.size = size this.hitbox = hitbox @@ -15,9 +17,20 @@ export class Entity { this.span = document.createElement("img") this.span.src = sprite Engine.screen.append(this.span) + + entities.list.push(this) + if (pixelated) this.span.className = "pixelated" } + update() {} + draw() { Engine.screen.draw(this.span, this.position, this.size) } + + + remove() { + this.span.remove() + entities.remove(this) + } } |