-
Notifications
You must be signed in to change notification settings - Fork 0
/
shroom.wl
62 lines (51 loc) · 1.39 KB
/
shroom.wl
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
import "entity.wl"
import "libwl/gl.wl"
import "libwl/mesh.wl"
import "libwl/image.wl"
import "libwl/fmt/tga.wl"
import "libwl/fmt/mdl.wl"
import "libwl/vec.wl"
import "libwl/file.wl"
import "libwl/random.wl"
import "libwl/collision.wl"
import "drawDevice.wl"
import "man.wl"
use "importc"
import(C) "math.h"
class Shroom : Entity {
static GLMesh mesh
static GLTexture texture
bool dead
bool isDead() return .dead
this() {
if(!mesh) {
Mesh m = loadMdl(new StringFile(pack "res/mushroom.mdl"))
.mesh = new GLMesh(m)
}
if(!texture) {
Image i = loadTGA(new StringFile(pack "res/mushroom.tga"))
.texture = new GLTexture(i)
}
.rotation = randomFloat() * 6 // 6 = 2PI (close enough)
.position.v[0] = randomFloat() * 18.0f - 9.0f
.position.v[2] = randomFloat() * 18.0f - 9.0f
}
void update(float dt) {
DuckMan d = DuckMan.getInstance()
Box3 dhit = d.getHitbox()
if(dhit.collides(.getHitbox())) {
if(d.scale * 2.2 > 1.5) {
d.eat(this)
.dead = true
} else {
}
}
}
float nummies() return 0.01
Box3 getHitbox() {
vec4 dim = vec4(3.3, 0.98, 0.86, 0)
return Box3(.position, dim)
}
GLMesh getMesh() return .mesh
GLTexture getTexture() return .texture
}