diff --git a/include/belt.h b/include/belt.h new file mode 100644 index 0000000..455b656 --- /dev/null +++ b/include/belt.h @@ -0,0 +1,26 @@ +#pragma once + +#ifndef BELT_H +#define BELT_H + +#include + +#include "object.h" +#include "cell.h" + + +class Belt : public Object { +private: + char direction; + +public: + Belt(float x, float y, int h, int w, char ic, Color col, char dir) + : Object(x, y, h, w, ic, col), direction(dir) {} + + char GetDirection(); + + void Action(Cell** cells); +}; + +//34 +#endif \ No newline at end of file diff --git a/include/gameManager.h b/include/gameManager.h index 2a68fa2..e086c1c 100644 --- a/include/gameManager.h +++ b/include/gameManager.h @@ -3,18 +3,19 @@ #ifndef GAMEMANAGER_H #define GAMEMANAGER_H +#include "belt.h" #include "map.h" #include "hero.h" - #include "../raylib/src/raylib.h" -using namespace std; +#include class GameManager{ private: Hero* hero; Map* map; Camera2D* cam; + std::vector belts; public: GameManager(Map* m, Hero* h, Camera2D* c); @@ -23,6 +24,10 @@ class GameManager{ void Update(); void Show(); + + void BeltsAction(); + + void PrintMap(); }; #endif \ No newline at end of file diff --git a/include/hero.h b/include/hero.h index ff1bc1d..06a9e79 100644 --- a/include/hero.h +++ b/include/hero.h @@ -8,6 +8,7 @@ #include "cell.h" #include "ironItem.h" #include "copperItem.h" +#include "belt.h" #include "../raylib/src/raylib.h" @@ -29,6 +30,9 @@ class Hero : public Object{ void Drop(Cell** cells); + void PlaceItems(Cell** cells, std::vector& belts); + + void PickItem(); private: Inventory* inventory; diff --git a/src/belt.cpp b/src/belt.cpp index fdfc676..53bf66d 100644 --- a/src/belt.cpp +++ b/src/belt.cpp @@ -8,7 +8,6 @@ void Belt::Action(Cell** cells) { int j = std::floor(position.x/ 40); int i = std::floor(position.y / 40); Object* obj = cells[i][j].getObject(); - if (obj->getIcon() == 'b' || obj->getIcon() == '#') { return; } diff --git a/src/gameManager.cpp b/src/gameManager.cpp index 8edc356..d20a8a4 100644 --- a/src/gameManager.cpp +++ b/src/gameManager.cpp @@ -2,7 +2,9 @@ #include #include -GameManager::GameManager(Map* m, Hero* h, Camera2D* c) { +using namespace std; + +GameManager::GameManager(Map* m, Hero* h, Camera2D* c){ map = m; hero = h; cam = c; @@ -32,6 +34,8 @@ void GameManager::Update() { cam->target.y = heroPosition.y; hero->getInventory()->showItems(cam->target); + + } void GameManager::detectCollision() { @@ -52,7 +56,7 @@ void GameManager::Show() { int x = hero->getPosition().x + 600; int y = hero->getPosition().y - 320; - + for (int i = 0; i < objects.size(); i++) { std::stringstream ss; @@ -76,7 +80,6 @@ void GameManager::BeltsAction() { void GameManager::PrintMap() { int j = std::floor(hero->getPosition().x / 40); int i = std::floor(hero->getPosition().y / 40); - for (int a = -10; a < 10; a++) { for (int b = -10; b < 10; b++) { if (i + a < 0 || j + a < 0) { diff --git a/src/inventory.cpp b/src/inventory.cpp index 7596f2a..1521cff 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -16,7 +16,6 @@ void Inventory::showItems(Vector2 target) { for (int i = 0; i < items.size(); i++) { std::stringstream text; - if (items[i]->getIcon() == 'i') { if (i == activeItem) { DrawRectangle(x, y, 24, 24, WHITE);