feat: PlayerAttackInput is now PlayerJabInput, added PlayerHeavyInput

This commit is contained in:
Sara 2024-01-12 12:40:40 +01:00
parent aca01507ed
commit 95f5bcfee7
2 changed files with 20 additions and 5 deletions

View file

@ -38,9 +38,18 @@ impl_PhysicsEntity_for(Player,
static inline
void Internal_PlayerInitInput(Player* self) {
playerinput_add(self->playerInput, CompositeAxis1D_as_InputAxis(compositeaxis1d_from_keys(SDL_SCANCODE_A, SDL_SCANCODE_D)), (InputDelegateFn)PlayerHorizontalInput);
playerinput_add(self->playerInput, CompositeAxis1D_as_InputAxis(compositeaxis1d_from_keys(SDL_SCANCODE_S, SDL_SCANCODE_W)), (InputDelegateFn)PlayerVerticalInput);
playerinput_add(self->playerInput, KeyBind_as_InputAxis(keybind_new(SDL_SCANCODE_J)), (InputDelegateFn)PlayerAttackInput);
playerinput_add(self->playerInput,
CompositeAxis1D_as_InputAxis(compositeaxis1d_from_keys(SDL_SCANCODE_A, SDL_SCANCODE_D)),
(InputDelegateFn)PlayerHorizontalInput);
playerinput_add(self->playerInput,
CompositeAxis1D_as_InputAxis(compositeaxis1d_from_keys(SDL_SCANCODE_S, SDL_SCANCODE_W)),
(InputDelegateFn)PlayerVerticalInput);
playerinput_add(self->playerInput,
KeyBind_as_InputAxis(keybind_new(SDL_SCANCODE_J)),
(InputDelegateFn)PlayerJabInput);
playerinput_add(self->playerInput,
KeyBind_as_InputAxis(keybind_new(SDL_SCANCODE_K)),
(InputDelegateFn)PlayerHeavyInput);
}
Player* MakePlayer() {
@ -125,7 +134,12 @@ void PlayerVerticalInput(Player* self, InputEvent value) {
self->moveInput.y = -value.as_float;
}
void PlayerAttackInput(Player* self, InputEvent value) {
void PlayerJabInput(Player* self, InputEvent value) {
if(value.as_bool)
self->attackInput = 1;
}
void PlayerHeavyInput(Player* self, InputEvent value) {
if(value.as_bool)
self->attackInput = 1;
}

View file

@ -46,7 +46,8 @@ void DestroyPlayer(Player* self);
void PlayerHorizontalInput(Player* self, InputEvent value);
void PlayerVerticalInput(Player* self, InputEvent value);
void PlayerAttackInput(Player* self, InputEvent value);
void PlayerJabInput(Player* self, InputEvent value);
void PlayerHeavyInput(Player* self, InputEvent value);
void PlayerStart(Player* self);
void PlayerUpdate(Player* self, float deltaTime);