diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-05 16:39:54 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-05 16:39:54 +0100 |
commit | 122253871c5e01197741c105a1c6159f960a57a8 (patch) | |
tree | 453cfd5e6660bf876c24472bfcd41e530f7eb4d2 /src/gameplay.cpp | |
parent | release v0.0.2 (diff) | |
download | threshold-122253871c5e01197741c105a1c6159f960a57a8.tar.gz threshold-122253871c5e01197741c105a1c6159f960a57a8.tar.bz2 threshold-122253871c5e01197741c105a1c6159f960a57a8.tar.xz threshold-122253871c5e01197741c105a1c6159f960a57a8.tar.zst threshold-122253871c5e01197741c105a1c6159f960a57a8.zip |
FINALLY add cowboy
Diffstat (limited to 'src/gameplay.cpp')
-rw-r--r-- | src/gameplay.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 622ff5a..213710a 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -63,6 +63,7 @@ Game::~Game() void Game::start() const { + player->tex = LoadTexture("../meta/media/sprites/cowboy_idle.png"); std::cout << "----- Gameplay: Start -----" << std::endl; std::cout << "Gameplay: " << nEnemies << "enemies need to be spawned" << std::endl; } @@ -76,7 +77,27 @@ void Game::draw() const { DrawCircleV((Vector2){en.posX, en.posY}, en.radius, DARKBLUE); } - DrawCircleV((Vector2){player->posX, player->posY}, 10, GREEN); + // DrawCircleV((Vector2){player->posX, player->posY}, 10, GREEN); + // DrawTexture(player->tex, , WHITE); // Draw a Texture2D + // DrawTextureEx(player->tex, + // (Vector2){player->posX, player->posY}, + // Vector2Angle((Vector2){0.0f, 0.0f}, player->direction), + // 1.0f, + // WHITE); // Draw a Texture2D with extended parameters + int frameWidth = player->tex.width; + int frameHeight = player->tex.height; + + Rectangle sourceRec = { 0.0f, 0.0f, (float)frameWidth, (float)frameHeight }; + + // Destination rectangle (screen rectangle where drawing part of texture) + Rectangle destRec = { player->posX, player->posY, frameWidth * 1.4f, frameHeight * 1.4f }; + + // Origin of the texture (rotation/scale point), it's relative to destination rectangle size + Vector2 origin = { (float)frameWidth, (float)frameHeight }; + + DrawTexturePro(player->tex, sourceRec, destRec, origin, Vector2Angle((Vector2){0.0f, 0.0f}, player->direction), WHITE); + + DrawText("Enemies left : ", 10, 10, 20, GREEN); DrawText(left.c_str(), 150, 10, 20, RED); if (player->fury >= 5) { |