more bullet testing

This commit is contained in:
jacob 2024-08-14 14:21:51 -05:00
parent ca6c058675
commit 2a357c127f
4 changed files with 16 additions and 12 deletions

BIN
res/graphics/bullet.ase (Stored with Git LFS)

Binary file not shown.

View File

@ -126,7 +126,7 @@ struct entity {
/* ====================================================================== */
/* Bullet */
struct entity_handle bullet_src_ent;
struct entity_handle bullet_src;
/* ====================================================================== */
/* Testing */

View File

@ -559,6 +559,12 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
out_vec = v2_norm(out_vec);
out_vec = v2_mul(out_vec, 25);
/* TODO: Remove this (testing) */
{
struct entity *parent = entity_from_handle(store, ent->parent);
out_vec = v2_add(out_vec, parent->velocity);
}
{
/* FIXME: Weapon velocity should affect bullet velocity
* (This should also make bullet_src_ent unnecessary for
@ -567,10 +573,10 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
/* Spawn bullet */
struct entity *bullet = entity_alloc(root);
bullet->sprite = sprite_tag_from_path(STR("res/graphics/bullet.ase"));
struct xform bullet_xf = XFORM_POS(out_pos);
struct xform bullet_xf = XFORM_TRS(.t = out_pos, .r = v2_angle(out_vec) + PI / 2);
entity_set_xform(bullet, bullet_xf);
bullet->velocity = out_vec;
bullet->bullet_src_ent = ent->handle;
bullet->bullet_src = ent->handle;
entity_enable_prop(bullet, ENTITY_PROP_BULLET);
}
}
@ -625,6 +631,10 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
* Update sound emitters
* ========================== */
/* TODO: Sound entities should be created by game thread, but played by the
* user thread. This is so sounds play at the correct time on the user
* thread regardless of interp delay. */
for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) {
struct entity *ent = &store->entities[entity_index];
if (!(ent->valid && entity_has_prop(ent, ENTITY_PROP_ACTIVE))) continue;

View File

@ -793,12 +793,6 @@ INTERNAL void user_update(void)
struct sprite_tag sprite = ent->sprite;
/* Skip undrawable entities */
if (ent->is_root
|| (sprite_tag_is_nil(sprite) && !entity_has_prop(ent, ENTITY_PROP_CAMERA))) {
continue;
}
struct entity *parent = entity_from_handle(store, ent->parent);
struct xform xf = entity_get_xform(ent);
@ -819,7 +813,7 @@ INTERNAL void user_update(void)
struct v2 end = xf.og;
struct v2 start;
struct entity *src = entity_from_handle(store, ent->bullet_src_ent);
struct entity *src = entity_from_handle(store, ent->bullet_src);
if (src->valid) {
start = xform_mul_v2(src->sprite_local_xform, sprite_sheet_get_slice(sprite_sheet_from_tag_await(sprite_frame_scope, src->sprite), STR("out"), src->animation_frame).center);
start = xform_mul_v2(entity_get_xform(src), start);