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/engine/screen.js | |
parent | a840990bdcabf45fb0d377478ba0ab27222434ae (diff) |
hello kitty base done
Diffstat (limited to 'src/engine/screen.js')
-rw-r--r-- | src/engine/screen.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/engine/screen.js b/src/engine/screen.js index 2d32b62..173e285 100644 --- a/src/engine/screen.js +++ b/src/engine/screen.js @@ -20,12 +20,14 @@ export class Screen { this.div = document.createElement("div") this.div.id = "screen" this.div.style.backgroundColor = "black" + this.div.style.zIndex = -11 /* create background image */ this.background = document.createElement("img") this.background.className = "background" this.background.src = `${BACKGROUND.DEFAULT}` this.background.style.visibility = "hidden" + this.background.style.zIndex = -10 this.div.appendChild(this.background) /* create relative div to append children */ @@ -77,11 +79,20 @@ export class Screen { draw(span, position, size, /* rotation = 0 */) { span.style.width = `${size.x * this.scale}px` span.style.height = `${size.y * this.scale}px` - span.style.top = `${(position.y - size.x / 2) * this.scale}px` - span.style.left = `${(position.x - size.y / 2) * this.scale}px` + span.style.top = `${(position.y - size.y / 2) * this.scale}px` + span.style.left = `${(position.x - size.x / 2) * this.scale}px` } setBackground(img) { this.background.src = img } showBackground() { this.background.visibility = "visible" } hideBackground() { this.background.visibility = "hidden" } + + isOffLimits(position, size) { + return ( + position.x + size.x < 0 || + position.y + size.y < 0 || + position.x - size.x > this.viewport.x || + position.y - size.y > this.viewport.y + ) + } } |