diff options
| author | Maksymilian Jopek <maks@jopek.eu> | 2022-05-24 18:25:43 +0200 |
|---|---|---|
| committer | Maksymilian Jopek <maks@jopek.eu> | 2022-05-24 18:25:43 +0200 |
| commit | 2f8b8c87fb2062313afea7b625ccb20d1bea95b9 (patch) | |
| tree | 973e20986e4b9279b9322a9fd140e6f989eaf492 /src/drawables/Background.ts | |
| download | 1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.tar.gz 1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.tar.zst 1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.zip | |
Initial commit
Diffstat (limited to 'src/drawables/Background.ts')
| -rw-r--r-- | src/drawables/Background.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/drawables/Background.ts b/src/drawables/Background.ts new file mode 100644 index 0000000..1eef6c4 --- /dev/null +++ b/src/drawables/Background.ts @@ -0,0 +1,26 @@ +import { canvas, ctx } from "../consts"; +import Drawable from "../Drawable"; +import { IMGS } from "../Images"; + +export class Background extends Drawable { + sprite = IMGS.bg; + width = canvas.width + height = canvas.height - 24 + constructor() { + super(0, 0) + } + // delta = -1751 + 24 + 2693; + delta = 0 + move(): boolean { + this.delta += 1; + return true; + } + draw() { + if (this.sprite.src == null) this.sprite = IMGS.bg; + ctx.drawImage(this.sprite, 0, 2693 - this.delta + 24, 320, 200 - 24, 0, 24, this.width, this.height) + } + getImageData() { + ctx.drawImage(this.sprite, 0, 2693 - this.delta + 24, 320, 200 - 24, 0, 24, this.width, this.height) + return ctx.getImageData(0, 24, this.width, this.height); + } +} |
