diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-03 23:48:32 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-03 23:48:32 +0100 |
commit | 0c135afff5aa837ed8aad418e240357c29c7d4e6 (patch) | |
tree | f5e762269d39233b79edd86b29fc24b743b4580d /src | |
parent | treschaud (diff) | |
download | threshold-0c135afff5aa837ed8aad418e240357c29c7d4e6.tar.gz threshold-0c135afff5aa837ed8aad418e240357c29c7d4e6.tar.bz2 threshold-0c135afff5aa837ed8aad418e240357c29c7d4e6.tar.xz threshold-0c135afff5aa837ed8aad418e240357c29c7d4e6.tar.zst threshold-0c135afff5aa837ed8aad418e240357c29c7d4e6.zip |
well done soldier
Diffstat (limited to 'src')
-rw-r--r-- | src/gameplay.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp index fafe4a5..25f63d7 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -2,6 +2,7 @@ #include <iostream> +#include "raymath.h" Game::~Game() { @@ -19,8 +20,8 @@ Game::Game(void) player = new Entity; player->posX = SCREENWIDTH / 2; player->posY = SCREENHEIGHT / 2; - player->direction.x = 0; - player->direction.y = 0; + player->direction.x = 100; + player->direction.y = 100; } void Game::start() const @@ -67,18 +68,25 @@ void Game::getKeys() const if (IsKeyDown(KEY_UP)) { player->posX += 0; player->posY += -4; + player->direction = Vector2Rotate(player->direction, -0.1f); } if (IsKeyDown(KEY_DOWN)) { player->posX += 0; player->posY += 4; + player->direction = Vector2Rotate(player->direction, 0.1f); } if (IsKeyDown(KEY_LEFT)) { player->posX += -4; player->posY += 0; + player->direction = Vector2Rotate(player->direction, -0.1f); } if (IsKeyDown(KEY_RIGHT)) { player->posX += 4; player->posY += 0; + player->direction = Vector2Rotate(player->direction, 0.1f); + } + if (IsKeyDown(KEY_SPACE)) { + DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), 30, RED); } if (oldX != player->posX || oldY != player->posY) { |