bullet_has_hit
This commit is contained in:
parent
0c1d6a58de
commit
5d6835ece3
@ -229,6 +229,7 @@ struct entity {
|
|||||||
struct v2 bullet_src_pos;
|
struct v2 bullet_src_pos;
|
||||||
struct v2 bullet_src_dir;
|
struct v2 bullet_src_dir;
|
||||||
f32 bullet_impulse;
|
f32 bullet_impulse;
|
||||||
|
b32 bullet_has_hit; /* Has the bullet hit a target this tick */
|
||||||
|
|
||||||
/* ====================================================================== */
|
/* ====================================================================== */
|
||||||
/* Testing */
|
/* Testing */
|
||||||
|
|||||||
52
src/game.c
52
src/game.c
@ -960,33 +960,35 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
|
|||||||
if (entity_has_prop(e0, ENTITY_PROP_BULLET) || entity_has_prop(e1, ENTITY_PROP_BULLET)) {
|
if (entity_has_prop(e0, ENTITY_PROP_BULLET) || entity_has_prop(e1, ENTITY_PROP_BULLET)) {
|
||||||
struct entity *bullet = entity_has_prop(e0, ENTITY_PROP_BULLET) ? e0 : e1;
|
struct entity *bullet = entity_has_prop(e0, ENTITY_PROP_BULLET) ? e0 : e1;
|
||||||
struct entity *target = e0 == bullet ? e1 : e0;
|
struct entity *target = e0 == bullet ? e1 : e0;
|
||||||
|
if (!bullet->bullet_has_hit) {
|
||||||
|
bullet->bullet_has_hit = true;
|
||||||
|
(UNUSED)bullet;
|
||||||
|
(UNUSED)target;
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
/* Set bullet position to hit position */
|
||||||
|
struct xform xf = entity_get_xform(bullet);
|
||||||
|
xf.og = event->point;
|
||||||
|
entity_set_xform(bullet, xf);
|
||||||
|
/* Release after publish so user sees bullet in final postiion */
|
||||||
|
entity_enable_prop(bullet, ENTITY_PROP_RELEASE_AFTER_PUBLISH);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
entity_enable_prop(bullet, ENTITY_PROP_RELEASE_BEFORE_PUBLISH);
|
||||||
|
#endif
|
||||||
|
|
||||||
(UNUSED)bullet;
|
/* Create test blood */
|
||||||
(UNUSED)target;
|
/* TODO: Remove this */
|
||||||
#if 0
|
{
|
||||||
{
|
struct xform xf = XFORM_TRS(.t = event->point);
|
||||||
/* Set bullet position to hit position */
|
struct entity *decal = entity_alloc(root);
|
||||||
struct xform xf = entity_get_xform(bullet);
|
decal->sprite = sprite_tag_from_path(STR("res/graphics/blood.ase"));
|
||||||
xf.og = event->point;
|
entity_set_xform(decal, xf);
|
||||||
entity_set_xform(bullet, xf);
|
|
||||||
/* Release after publish so user sees bullet in final postiion */
|
|
||||||
entity_enable_prop(bullet, ENTITY_PROP_RELEASE_AFTER_PUBLISH);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
entity_enable_prop(bullet, ENTITY_PROP_RELEASE_BEFORE_PUBLISH);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Create test blood */
|
entity_enable_prop(decal, ENTITY_PROP_PHYSICAL_KINEMATIC);
|
||||||
/* TODO: Remove this */
|
decal->linear_velocity = v2_mul(v2_norm(event->normal), 0.5f);
|
||||||
{
|
decal->angular_velocity = 1 - (((f32)sys_rand_u32() / (f32)U32_MAX) * 2);
|
||||||
struct xform xf = XFORM_TRS(.t = event->point);
|
}
|
||||||
struct entity *decal = entity_alloc(root);
|
|
||||||
decal->sprite = sprite_tag_from_path(STR("res/graphics/blood.ase"));
|
|
||||||
entity_set_xform(decal, xf);
|
|
||||||
|
|
||||||
entity_enable_prop(decal, ENTITY_PROP_PHYSICAL_KINEMATIC);
|
|
||||||
decal->linear_velocity = v2_mul(v2_norm(event->normal), 0.5f);
|
|
||||||
decal->angular_velocity = 1 - (((f32)sys_rand_u32() / (f32)U32_MAX) * 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user