-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity_projectile_nail.c
64 lines (51 loc) · 1.66 KB
/
entity_projectile_nail.c
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
#include "entity_projectile_nail.h"
#include "entity.h"
#include "game.h"
#include "math.h"
#include "entity_light.h"
#include "audio.h"
void entity_projectile_nail_init(entity_t * e);
void entity_projectile_nail_update(entity_t * e);
void entity_projectile_nail_did_collide(entity_t * e, int axis);
void entity_projectile_nail_did_collide_with_entity(entity_t * e, entity_t * other);
void entity_projectile_nail_constructor(entity_t * e) {
entity_constructor(e);
e->_update = entity_projectile_nail_update;
e->_did_collide = entity_projectile_nail_did_collide;
e->_did_collide_with_entity = entity_projectile_nail_did_collide_with_entity;
entity_projectile_nail_init(e);
}
void entity_projectile_nail_init(entity_t * e) {
e->_gravity = 0;
e->_expires = true;
e->_die_at = game_time + 3;
entity_set_model(e);
}
void entity_projectile_nail_update(entity_t * e) {
e->_update_physics(e);
e->_draw_model(e);
}
void entity_projectile_nail_did_collide(entity_t * e, int axis) {
// silence unused
axis = axis;
e->_kill(e);
e->_play_sound(e, sfx_nailgun_hit);
e->_spawn_particles(e, 2, 80, ENTITY_ID_PARTICLE_SLUG, 0.4);
entity_params_t l = {
.id = ENTITY_ID_LIGHT,
.position = e->p,
.entity_light_params = {
.rgba[0] = 0xff,
.rgba[1] = 0xff,
.rgba[2] = 0xff,
.rgba[3] = 0x01,
},
};
entity_t * tmplight = game_spawn(&l);
tmplight->_expires = true;
tmplight->_die_at = game_time + 0.1;
}
void entity_projectile_nail_did_collide_with_entity(entity_t * e, entity_t * other) {
e->_kill(e);
other->_receive_damage(other, e, 9);
}