-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBullet.ts
77 lines (58 loc) · 1.5 KB
/
Bullet.ts
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { Anim, AnimField, AnimFrame } from './lib/juego/Anim.js'
import { Entity } from "./lib/juego/Entity.js"
import { Shape } from './lib/juego/Shape.js'
import { Material } from './lib/juego/Material.js'
import { Vec2 } from "./lib/juego/Vec2.js"
import { CenteredEntity } from './CenteredEntity.js'
export class Bullet extends CenteredEntity {
speed: number;
/* property overrides */
flavorName: string = 'BULLET';
constructor( pos: Vec2, vel: Vec2 ) {
super( pos, 8, 8 );
this.material = new Material( 45, 1.0, 0.5 );
this.material.emit = 0.3;
//this.material.cornerShaderIndex = 1;
this.vel = vel;
}
setVel() {
this.vel.normalize();
this.vel.scale( this.speed );
}
onCollideLeft() {
this.removeThis = true;
}
onCollideRight() {
this.removeThis = true;
}
onCollideUp() {
this.removeThis = true;
}
onCollideDown() {
this.removeThis = true;
}
}
export class PlayerBullet extends Bullet {
constructor( pos: Vec2, vel: Vec2, material: Material=null ) {
super( pos, vel );
if ( material ) {
this.material = material;
}
this.anim = new Anim( {
'alpha': new AnimField( this.material, 'alpha', 0.1 )
},
new AnimFrame( {
'alpha': { value: 0.3 }
} ) );
this.material.alpha = 0.0;
}
}
export class Gutter extends CenteredEntity {
/* property overrides */
flavorName: string = 'GUTTER';
constructor( pos: Vec2=new Vec2(), w: number=20, h: number=100 ) {
super( pos, w, h );
this.material = new Material( 30, 1.0, 0.6, 1 );
this.material.emit = 0.8;
}
}