more bullet testing
This commit is contained in:
parent
ca6c058675
commit
2a357c127f
BIN
res/graphics/bullet.ase
(Stored with Git LFS)
BIN
res/graphics/bullet.ase
(Stored with Git LFS)
Binary file not shown.
@ -126,7 +126,7 @@ struct entity {
|
|||||||
/* ====================================================================== */
|
/* ====================================================================== */
|
||||||
/* Bullet */
|
/* Bullet */
|
||||||
|
|
||||||
struct entity_handle bullet_src_ent;
|
struct entity_handle bullet_src;
|
||||||
|
|
||||||
/* ====================================================================== */
|
/* ====================================================================== */
|
||||||
/* Testing */
|
/* Testing */
|
||||||
|
|||||||
14
src/game.c
14
src/game.c
@ -559,6 +559,12 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
|
|||||||
out_vec = v2_norm(out_vec);
|
out_vec = v2_norm(out_vec);
|
||||||
out_vec = v2_mul(out_vec, 25);
|
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
|
/* FIXME: Weapon velocity should affect bullet velocity
|
||||||
* (This should also make bullet_src_ent unnecessary for
|
* (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 */
|
/* Spawn bullet */
|
||||||
struct entity *bullet = entity_alloc(root);
|
struct entity *bullet = entity_alloc(root);
|
||||||
bullet->sprite = sprite_tag_from_path(STR("res/graphics/bullet.ase"));
|
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);
|
entity_set_xform(bullet, bullet_xf);
|
||||||
bullet->velocity = out_vec;
|
bullet->velocity = out_vec;
|
||||||
bullet->bullet_src_ent = ent->handle;
|
bullet->bullet_src = ent->handle;
|
||||||
entity_enable_prop(bullet, ENTITY_PROP_BULLET);
|
entity_enable_prop(bullet, ENTITY_PROP_BULLET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -625,6 +631,10 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
|
|||||||
* Update sound emitters
|
* 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) {
|
for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) {
|
||||||
struct entity *ent = &store->entities[entity_index];
|
struct entity *ent = &store->entities[entity_index];
|
||||||
if (!(ent->valid && entity_has_prop(ent, ENTITY_PROP_ACTIVE))) continue;
|
if (!(ent->valid && entity_has_prop(ent, ENTITY_PROP_ACTIVE))) continue;
|
||||||
|
|||||||
@ -793,12 +793,6 @@ INTERNAL void user_update(void)
|
|||||||
|
|
||||||
struct sprite_tag sprite = ent->sprite;
|
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 entity *parent = entity_from_handle(store, ent->parent);
|
||||||
|
|
||||||
struct xform xf = entity_get_xform(ent);
|
struct xform xf = entity_get_xform(ent);
|
||||||
@ -819,7 +813,7 @@ INTERNAL void user_update(void)
|
|||||||
struct v2 end = xf.og;
|
struct v2 end = xf.og;
|
||||||
|
|
||||||
struct v2 start;
|
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) {
|
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(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);
|
start = xform_mul_v2(entity_get_xform(src), start);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user