diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-03 22:55:39 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-03 22:55:39 +0100 |
commit | ec5eb920ba1998df048b47c4f136ce980d1d9c38 (patch) | |
tree | 2597ccf4e5869688198ec048580aef7baadc986c /src/gameplay.cpp | |
parent | move to entity and add player (diff) | |
download | threshold-ec5eb920ba1998df048b47c4f136ce980d1d9c38.tar.gz threshold-ec5eb920ba1998df048b47c4f136ce980d1d9c38.tar.bz2 threshold-ec5eb920ba1998df048b47c4f136ce980d1d9c38.tar.xz threshold-ec5eb920ba1998df048b47c4f136ce980d1d9c38.tar.zst threshold-ec5eb920ba1998df048b47c4f136ce980d1d9c38.zip |
I may have an idea
Diffstat (limited to 'src/gameplay.cpp')
-rw-r--r-- | src/gameplay.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 260ddde..3cbc17f 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -11,10 +11,16 @@ Game::~Game() Game::Game(void) { - nEnemies = GetRandomValue(5, 15); + // nEnemies = GetRandomValue(5, 15); + + enemies = 3; enemies = new std::vector<Entity>(nEnemies); player = new Entity; + player->posX = SCREENWIDTH / 2; + player->posY = SCREENHEIGHT / 2; + player->direction.x = 1; + player->direction.y = 0; } void Game::start() const @@ -29,6 +35,7 @@ void Game::draw() const { DrawCircleV((Vector2){en.posX, en.posY}, 10, RED); } + DrawCircleV((Vector2){player->posX, player->posY}, 10, GREEN); } @@ -47,8 +54,26 @@ void Game::tick() const en.posX += en.direction.x; en.posY += en.direction.y; } + player->posX += player->direction.x; + player->posY += player->direction.y; } void Game::getKeys() const { + if (IsKeyPressed(KEY_UP)) { + player->direction.x = 0; + player->direction.y = -2; + } + if (IsKeyPressed(KEY_DOWN)) { + player->direction.x = 0; + player->direction.y = 2; + } + if (IsKeyPressed(KEY_LEFT)) { + player->direction.x = -2; + player->direction.y = 0; + } + if (IsKeyPressed(KEY_RIGHT)) { + player->direction.x = 2; + player->direction.y = 0; + } } |