aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-05 17:36:21 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-05 17:36:21 +0100
commit152b9439805369aee79a0734927ae0475b97eee9 (patch)
tree3e14c46360732c45a401b1a38d1cce90d30189b8
parentFINALLY add cowboy (diff)
downloadthreshold-152b9439805369aee79a0734927ae0475b97eee9.tar.gz
threshold-152b9439805369aee79a0734927ae0475b97eee9.tar.bz2
threshold-152b9439805369aee79a0734927ae0475b97eee9.tar.xz
threshold-152b9439805369aee79a0734927ae0475b97eee9.tar.zst
threshold-152b9439805369aee79a0734927ae0475b97eee9.zip
v0.0.3 onwards to better levels
-rw-r--r--src/gameplay.cpp21
-rw-r--r--src/gameplay.hpp25
2 files changed, 23 insertions, 23 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 213710a..3adaa2d 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -61,11 +61,17 @@ Game::~Game()
delete player;
}
-void Game::start() const
+void Game::start()
{
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;
+ frameWidth = player->tex.width;
+ frameHeight = player->tex.height;
+
+ sourceRec = { 0.0f, 0.0f, (float)frameWidth, (float)frameHeight };
+
+ origin = { (float)frameWidth, (float)frameHeight };
}
// draw bad boys and player
@@ -77,23 +83,10 @@ void Game::draw() const
{
DrawCircleV((Vector2){en.posX, en.posY}, en.radius, DARKBLUE);
}
- // 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);
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index f53b094..e325730 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -29,17 +29,24 @@ class Game {
Camera2D * camera;
- public:
- Game(std::string const & path);
- ~Game();
+ int frameWidth;
+ int frameHeight;
- void start() const ;
- void draw() const ;
- int tick() const ;
- int getKeys() const ;
- int shoot() const ;
+ Rectangle sourceRec;
- std::string const & getNext() const ; // returns next level's string
+ Vector2 origin;
+
+ public:
+ Game(std::string const &path);
+ ~Game();
+
+ void start() ;
+ void draw() const;
+ int tick() const;
+ int getKeys() const;
+ int shoot() const;
+
+ std::string const &getNext() const; // returns next level's string
};
#endif // GAMEPLAY_H_