aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md12
-rw-r--r--meta/media/sprites/cowboy_idle.pngbin0 -> 1193 bytes
-rw-r--r--src/entity.hpp3
-rw-r--r--src/gameplay.cpp23
-rw-r--r--src/gameplay.hpp2
-rw-r--r--src/main.cpp1
6 files changed, 40 insertions, 1 deletions
diff --git a/README.md b/README.md
index dffa4c1..d254c5c 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,18 @@ Most of the prototype features are done, but it is currenty very barebones.
Feel free to fork & add features.
+## Build
+
+- make sure you have rayib installed, then run :
+
+``` sh
+mkdir build
+cd build
+cmake ..
+./space
+```
+
+
## Work In progress
- Visual improvements
diff --git a/meta/media/sprites/cowboy_idle.png b/meta/media/sprites/cowboy_idle.png
new file mode 100644
index 0000000..92cf0db
--- /dev/null
+++ b/meta/media/sprites/cowboy_idle.png
Binary files differ
diff --git a/src/entity.hpp b/src/entity.hpp
index 0b170ab..dd8a810 100644
--- a/src/entity.hpp
+++ b/src/entity.hpp
@@ -25,6 +25,9 @@ class Entity {
double time;
Vector2 direction;
Weapon * wp;
+ Image img;
+ Texture2D tex;
+
Entity();
~Entity();
};
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) {
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index 168a83a..f53b094 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -27,6 +27,8 @@ class Game {
std::string next; // next level
+ Camera2D * camera;
+
public:
Game(std::string const & path);
~Game();
diff --git a/src/main.cpp b/src/main.cpp
index 52db18e..d014fdb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -103,6 +103,7 @@ int main(void) {
}
EndDrawing();
}
+ EndMode2D();
CloseWindow();
return 0;
}