Skip to content
Open

belt #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions include/belt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#ifndef BELT_H
#define BELT_H

#include <string>

#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
9 changes: 7 additions & 2 deletions include/gameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<vector>

class GameManager{
private:
Hero* hero;
Map* map;
Camera2D* cam;
std::vector<Belt*> belts;
public:
GameManager(Map* m, Hero* h, Camera2D* c);

Expand All @@ -23,6 +24,10 @@ class GameManager{
void Update();

void Show();

void BeltsAction();

void PrintMap();
};

#endif
4 changes: 4 additions & 0 deletions include/hero.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "cell.h"
#include "ironItem.h"
#include "copperItem.h"
#include "belt.h"

#include "../raylib/src/raylib.h"

Expand All @@ -29,6 +30,9 @@ class Hero : public Object{

void Drop(Cell** cells);

void PlaceItems(Cell** cells, std::vector<Belt*>& belts);

void PickItem();

private:
Inventory* inventory;
Expand Down
1 change: 0 additions & 1 deletion src/belt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 6 additions & 3 deletions src/gameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include <string>
#include <sstream>

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;
Expand Down Expand Up @@ -32,6 +34,8 @@ void GameManager::Update() {
cam->target.y = heroPosition.y;

hero->getInventory()->showItems(cam->target);


}

void GameManager::detectCollision() {
Expand All @@ -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;

Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down