diff options
-rw-r--r-- | src/player.c | 16 | ||||
-rw-r--r-- | src/player.h | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/player.c b/src/player.c index 4232842..3d84b0f 100644 --- a/src/player.c +++ b/src/player.c @@ -79,6 +79,22 @@ mf_player_new(struct mf_maze *maze, int cell_width) return p; } +void +mf_player_get_vector(struct mf_player *p, int *x, int *y, int *travel, + int *dx, int *dy) +{ + *x = p->cur_x; + *y = p->cur_y; + *travel = p->travel; + switch (p->cur_dir) { + case MF_PLAYER_DIR_U_: *dx = 0; *dy = -1; break; + case MF_PLAYER_DIR_D_: *dx = 0; *dy = 1; break; + case MF_PLAYER_DIR_L_: *dx = -1; *dy = 0; break; + case MF_PLAYER_DIR_R_: *dx = 1; *dy = 0; break; + default: *dx = 0; *dy = 0; break; + } +} + static void _mf_player_move(struct mf_player *p, enum _mf_player_dir dir) { diff --git a/src/player.h b/src/player.h index d27500c..b180e20 100644 --- a/src/player.h +++ b/src/player.h @@ -26,6 +26,10 @@ struct mf_player * mf_player_new(struct mf_maze *maze, int cell_width); void +mf_player_get_vector(struct mf_player *p, int *x, int *y, int *travel, + int *dx, int *dy); + +void mf_player_key_event(struct mf_player *p, SDL_Event *e); int |