From be9ccb73bc20b03f62c77f5d529602a10ef4eda9 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 12 Mar 2022 12:09:58 -0500 Subject: player has a sprite now thanks to world of solaria --- src/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 1805357..5178110 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -207,6 +207,7 @@ bool processKeys(Game& game, const Input& keystate) { int px = game.player_x; int py = game.player_y; + Direction dir = Direction::up; if (keystate.up) { @@ -216,20 +217,26 @@ bool processKeys(Game& game, const Input& keystate) if (keystate.down) { py++; + dir = Direction::down; } if (keystate.left) { px--; + dir = Direction::left; } if (keystate.right) { px++; + dir = Direction::right; } if (!(game.player_x == px && game.player_y == py)) { + game.playerAnim.setAnimation("walk"); + game.playerAnim.setDirection(dir); + return movePlayer(game, px, py); } else { return false; @@ -614,6 +621,8 @@ int main(int, char**) { game.firstInput = true; game.lastInput = keystate; + } else if (losing == LoseState::None) { + game.playerAnim.setAnimation("still"); } dustAcc += frameTime; @@ -767,6 +776,8 @@ int main(int, char**) zoomAcc -= zoomDt; } + game.playerAnim.update(frameTime); + game.muxer.update(); renderer.render(game, true); } -- cgit 1.4.1