A RPG I'm messing with made in Raylib.
at main 38 lines 895 B view raw
1#include "../../include/player_state/default.h" 2 3#include "../../include/player_state/walk.h" 4 5#include "../../include/player.h" 6#include "../../include/raylib.h" 7 8static void player_state_default_update(PlayerState *state, Player *player) 9{ 10 if (IsKeyPressed(KEY_UP)) 11 { 12 player_state_transition_to_walk(&player->state, player); 13 } 14 15 if (IsKeyPressed(KEY_DOWN)) 16 { 17 player_state_transition_to_walk(&player->state, player); 18 } 19 20 if (IsKeyPressed(KEY_LEFT)) 21 { 22 player_state_transition_to_walk(&player->state, player); 23 } 24 25 if (IsKeyPressed(KEY_RIGHT)) 26 { 27 player_state_transition_to_walk(&player->state, player); 28 } 29} 30 31void player_state_transition_to_default(PlayerState *state, Player *player) 32{ 33 state->name = "Default"; 34 state->update = player_state_default_update; 35 36 player->velocity = Vector2Zero(); 37 player->texture = player->textures[PLAYER_TEXTURE_FORWARD]; 38}