lol was hab ich eigentlich geaendert

This commit is contained in:
huaqo-games
2025-03-19 19:50:24 +01:00
parent 5d048a5269
commit e55db94d48
+9 -13
View File
@@ -49,10 +49,8 @@ Player CreatePlayer(Texture2D texture, float frameWidth, int maxFrame, int frame
}; };
} }
void UpdateState(PlayerState *state) { void UpdatePlayerState(PlayerState *state, Vector2 *dir) {
Vector2 dir = GetDirectionVector(); if (dir->x == 0 && dir->y == 0) {
if (dir.x == 0 && dir.y == 0) {
switch (*state) { switch (*state) {
case WALKING_DOWN: *state = IDLE_DOWN; break; case WALKING_DOWN: *state = IDLE_DOWN; break;
case WALKING_UP: *state = IDLE_UP; break; case WALKING_UP: *state = IDLE_UP; break;
@@ -61,19 +59,17 @@ void UpdateState(PlayerState *state) {
default: break; default: break;
} }
} else { } else {
if (dir.y == -1) *state = WALKING_DOWN; if (dir->y == -1) *state = WALKING_DOWN;
else if (dir.y == 1) *state = WALKING_UP; else if (dir->y == 1) *state = WALKING_UP;
else if (dir.x == 1) *state = WALKING_RIGHT; else if (dir->x == 1) *state = WALKING_RIGHT;
else if (dir.x == -1) *state = WALKING_LEFT; else if (dir->x == -1) *state = WALKING_LEFT;
} }
} }
void UpdatePlayer(Player* player){ void UpdatePlayer(Player* player){
UpdatePhysics(&player->physics, GetDirectionVector()); Vector2 dir = GetDirectionVector();
UpdateState(&player->state); UpdatePlayerState(&player->state, &dir);
// UpdateSpriteRotation(&player->sprite, &player->physics.direction); UpdatePhysics(&player->physics, dir);
UpdateSpriteDestRec(&player->sprite, &player->physics.position); UpdateSpriteDestRec(&player->sprite, &player->physics.position);
UpdateAnimation(&player->animation, GetFrameTime()); UpdateAnimation(&player->animation, GetFrameTime());
UpdateSpriteSourceRec(&player->sprite, &(Vector2){player->sprite.frameSize.x * player->state, player->sprite.frameSize.y * player->animation.currentFrame}); UpdateSpriteSourceRec(&player->sprite, &(Vector2){player->sprite.frameSize.x * player->state, player->sprite.frameSize.y * player->animation.currentFrame});