aboutsummaryrefslogtreecommitdiffstats
path: root/src/drawables
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-06-02 08:54:02 +0200
committerMaksymilian Jopek <maks@jopek.eu>2022-06-02 08:54:02 +0200
commit6c37585ef4ef2535aff8c45c64850be0a6c26eab (patch)
treec53e07505182735fbd23687a0c731d4bb2f10e14 /src/drawables
parent7a494b148dd03d6346a63641fc479015e7450a26 (diff)
download1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.tar.gz
1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.tar.zst
1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.zip
Death animations
Diffstat (limited to 'src/drawables')
-rw-r--r--src/drawables/Background.ts3
-rw-r--r--src/drawables/Bullet.ts27
2 files changed, 16 insertions, 14 deletions
diff --git a/src/drawables/Background.ts b/src/drawables/Background.ts
index da091a1..622a608 100644
--- a/src/drawables/Background.ts
+++ b/src/drawables/Background.ts
@@ -10,8 +10,9 @@ export class Background extends Drawable {
super(0, 0)
}
// delta = -1751 + 24 + 2693;
- delta = 0
+ delta = 2500
move() {
+ if (this.delta + 1 > 2580) return true
this.delta += 1;
return true;
}
diff --git a/src/drawables/Bullet.ts b/src/drawables/Bullet.ts
index a745a06..f121cfa 100644
--- a/src/drawables/Bullet.ts
+++ b/src/drawables/Bullet.ts
@@ -1,29 +1,30 @@
-import { canvas } from "../consts";
import Drawable, { Rectangle } from "../Drawable";
+import { IMGS } from "../Images";
export default class Bullet extends Drawable {
static width = 2;
static height = 5;
static color = "black";
- width = 2;
- height = 5;
- color = "black";
- sprite = "black";
+ // width = 2;
+ // height = 5;
+ // color = "black";
- squares: Rectangle[] = [new Rectangle(this)]
- constructor(x: number, y: number, public xvel: number, public yvel: number, public players: boolean) {
- super(x, y);
- // this.width = Bullet.width;
- // this.height = Bullet.height;
+ constructor(x: number, y: number, public xvel: number, public yvel: number, public players: boolean, public power?: number) {
+ super(Math.floor(x), Math.floor(y));
+ //@ts-expect-error
+ if (players) this.sprite = IMGS["playerBullet" + power]
+ else this.sprite = IMGS.enemyBullet;
+ this.width = (this.sprite as HTMLImageElement).width
+ this.height = (this.sprite as HTMLImageElement).height
+ this.squares = [new Rectangle(this)]
+ console.log(this.width, this.height);
}
move(): boolean {
this.x += this.xvel;
this.y += this.yvel;
- return (
- this.x + this.width < 0 || this.y + this.height < 0 || this.x > canvas.width || this.y > canvas.height
- );
+ return this.isOutsideMap()
}
}