blob: 6420db25ade9ede44196381edfa388b4aeb48454 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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";
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)]
}
move(): boolean {
this.x += this.xvel;
this.y += this.yvel;
return this.isOutsideMap()
}
}
|