minor tweaks
This commit is contained in:
parent
bac001947b
commit
aa8dd7a4fa
@ -32,10 +32,8 @@ INTERNAL void push_cmds(struct game_cmd_array cmd_array)
|
|||||||
{
|
{
|
||||||
sys_mutex_lock(&L.game_cmds_mutex);
|
sys_mutex_lock(&L.game_cmds_mutex);
|
||||||
{
|
{
|
||||||
for (u64 i = 0; i < cmd_array.count; ++i) {
|
struct game_cmd *cmds = arena_push_array(&L.game_cmds_arena, struct game_cmd, cmd_array.count);
|
||||||
struct game_cmd *write_cmd = arena_push(&L.game_cmds_arena, struct game_cmd);
|
MEMCPY(cmds, cmd_array.cmds, cmd_array.count * sizeof(*cmds));
|
||||||
*write_cmd = cmd_array.cmds[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sys_mutex_unlock(&L.game_cmds_mutex);
|
sys_mutex_unlock(&L.game_cmds_mutex);
|
||||||
}
|
}
|
||||||
@ -81,7 +79,6 @@ INTERNAL void game_update(void)
|
|||||||
static b32 run = 0;
|
static b32 run = 0;
|
||||||
if (!run) {
|
if (!run) {
|
||||||
run = 1;
|
run = 1;
|
||||||
(UNUSED)entity_link;
|
|
||||||
|
|
||||||
/* Player ent */
|
/* Player ent */
|
||||||
struct entity *player_ent;
|
struct entity *player_ent;
|
||||||
@ -227,7 +224,6 @@ INTERNAL void game_update(void)
|
|||||||
/* Movement */
|
/* Movement */
|
||||||
case GAME_CMD_KIND_PLAYER_MOVE: {
|
case GAME_CMD_KIND_PLAYER_MOVE: {
|
||||||
struct v2 dir = cmd.dir;
|
struct v2 dir = cmd.dir;
|
||||||
|
|
||||||
L.world.player_move_dir = v2_add(L.world.player_move_dir, dir);
|
L.world.player_move_dir = v2_add(L.world.player_move_dir, dir);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|||||||
27
src/user.c
27
src/user.c
@ -98,17 +98,7 @@ GLOBAL READONLY enum user_bind_kind g_binds[SYS_BTN_COUNT] = {
|
|||||||
* Window -> user communication
|
* Window -> user communication
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
INTERNAL void window_event_callback(struct sys_event event)
|
INTERNAL struct sys_event_array pop_sys_events(struct arena *arena)
|
||||||
{
|
|
||||||
sys_mutex_lock(&L.sys_events_mutex);
|
|
||||||
{
|
|
||||||
struct sys_event *write_event = arena_push(&L.sys_events_arena, struct sys_event);
|
|
||||||
*write_event = event;
|
|
||||||
}
|
|
||||||
sys_mutex_unlock(&L.sys_events_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
INTERNAL struct sys_event_array pull_sys_events(struct arena *arena)
|
|
||||||
{
|
{
|
||||||
struct sys_event_array array = { 0 };
|
struct sys_event_array array = { 0 };
|
||||||
if (L.sys_events_arena.pos > 0) {
|
if (L.sys_events_arena.pos > 0) {
|
||||||
@ -126,6 +116,15 @@ INTERNAL struct sys_event_array pull_sys_events(struct arena *arena)
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INTERNAL void window_event_callback(struct sys_event event)
|
||||||
|
{
|
||||||
|
sys_mutex_lock(&L.sys_events_mutex);
|
||||||
|
{
|
||||||
|
*arena_push(&L.sys_events_arena, struct sys_event) = event;
|
||||||
|
}
|
||||||
|
sys_mutex_unlock(&L.sys_events_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Game -> user communication
|
* Game -> user communication
|
||||||
* ========================== */
|
* ========================== */
|
||||||
@ -274,7 +273,7 @@ INTERNAL void queue_game_cmd(struct game_cmd_list *list, struct game_cmd cmd)
|
|||||||
list->last = node;
|
list->last = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERNAL void push_game_cmds(struct game_cmd_list *list)
|
INTERNAL void pubilsh_game_cmds(struct game_cmd_list *list)
|
||||||
{
|
{
|
||||||
struct temp_arena scratch = scratch_begin(list->arena);
|
struct temp_arena scratch = scratch_begin(list->arena);
|
||||||
|
|
||||||
@ -397,7 +396,7 @@ INTERNAL void user_update(void)
|
|||||||
|
|
||||||
/* Read input */
|
/* Read input */
|
||||||
L.screen_mouse = sys_window_get_mouse_pos(L.window);
|
L.screen_mouse = sys_window_get_mouse_pos(L.window);
|
||||||
struct sys_event_array events = pull_sys_events(scratch.arena);
|
struct sys_event_array events = pop_sys_events(scratch.arena);
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Read sys events
|
* Read sys events
|
||||||
@ -891,7 +890,7 @@ INTERNAL void user_update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Push game cmds */
|
/* Push game cmds */
|
||||||
push_game_cmds(&cmd_list);
|
pubilsh_game_cmds(&cmd_list);
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Present
|
* Present
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user