-
Notifications
You must be signed in to change notification settings - Fork 0
/
cliffbar.wl
68 lines (56 loc) · 1.55 KB
/
cliffbar.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
63
64
65
66
67
68
import "entity.wl"
import "libwl/gl.wl"
import "drawDevice.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 "man.wl"
use "importc"
import(C) "math.h"
class Cliffbar : Entity {
static GLMesh mesh
static GLTexture texture
bool dead
bool isDead() return .dead
float yummyNummies() return 10.0f
float nummies() return 0.1
this() {
if(!mesh) {
Mesh m = loadMdl(new StringFile(pack "res/cliffbar.mdl"))
.mesh = new GLMesh(m)
}
if(!texture) {
Image i = loadTGA(new StringFile(pack "res/cliffbar.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()) and d.scale > 0.4) {
d.eat(this)
.dead = true
}
.rotation += 0.1
.position.v[1] = (sin(.rotation) / 2.0f + 0.5) / 10.0f
}
Box3 getHitbox() {
vec4 dim = vec4(0.5, 0.5, 0.5, 0)
return Box3(.position, dim)
}
GLMesh getMesh() return mesh
GLTexture getTexture() return texture
}
void initCliffbars() {
for(int i = 0; i < 2; i++) {
(Entity.add(new Cliffbar()))
}
}