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/Bullet.ts | |
| download | 1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.tar.gz 1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.tar.zst 1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.zip | |
Initial commit
Diffstat (limited to 'src/drawables/Bullet.ts')
| -rw-r--r-- | src/drawables/Bullet.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/drawables/Bullet.ts b/src/drawables/Bullet.ts new file mode 100644 index 0000000..68f55e8 --- /dev/null +++ b/src/drawables/Bullet.ts @@ -0,0 +1,27 @@ +import { canvas } from "../consts"; +import Drawable from "../Drawable"; + +export default class Bullet extends Drawable { + static width = 2; + static height = 5; + static color = "black"; + color = "black"; + sprite = "black"; + + squares = [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; + } + + 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 + ); + } +} |
