Commit 68246cb2 authored by Felix Huther's avatar Felix Huther
Browse files

small changes mainly at TermUI and DungeonCrawler.play

parent d3a379c6
#ifndef ABSTRACTUI_H
#define ABSTRACTUI_H
#pragma once
#include "level.h"
class AbstractUI
......@@ -8,6 +7,7 @@ class AbstractUI
public:
AbstractUI();
virtual void draw(Level* lvl) = 0;
virtual void userInterface() = 0;
};
#endif // ABSTRACTUI_H
#ifndef CHARACTER_H
#define CHARACTER_H
//#include "tile.h"
#include<string>
class Tile;
......
#include "dungeoncrawler.h"
DungeonCrawler::DungeonCrawler(AbstractUI * abstractUi, Level* currentLevel)
:abstractUi(abstractUi)
:abstractUi(abstractUi),currentLevel(currentLevel)
{
this->levels.push_back(currentLevel);
}
void DungeonCrawler::play()
{
currentLevel->setLevelStructure();
std::string texture = "metal";
Character* TestChar = new Character(texture);
if(currentLevel->getCharacter() == nullptr)
{
const int column = 1;
const int row = 1;
Position2D pos = Position2D(row,column);
currentLevel->placeCharacter(TestChar,pos);
}
while(true){
abstractUi->userInterface();
abstractUi->draw(currentLevel);
}
}
......@@ -12,7 +12,7 @@ public:
private:
AbstractUI* abstractUi;
std::vector<Level*> levels;
Level* currentLevel;
};
......
......@@ -3,7 +3,7 @@
Level::Level(int height, int width)
:height(height),width(width)
:height(height),width(width),character(nullptr)
{
}
......@@ -89,4 +89,9 @@ void Level::setLevelStructure()
// }
}
Character *Level::getCharacter() const
{
return character;
}
#ifndef LEVEL_H
#define LEVEL_H
#pragma once
#include "tile.h"
#include "floor.h"
#include "wall.h"
......@@ -24,6 +23,8 @@ public:
int getWidth() const;
Character *getCharacter() const;
private:
const int height;
const int width;
......
......@@ -6,13 +6,10 @@ using namespace std;
int main()
{
TerminalUI* termUI = new TerminalUI();
AbstractUI* termUI = new TerminalUI();
Level* level = new Level(10,10);
level->setLevelStructure();
termUI->interface();
// DungeonCrawler* dungeonCraler = new DungeonCrawler(termUI,level);
termUI->draw(level);
DungeonCrawler dungeonCrawler(termUI,level);
dungeonCrawler.play();
return 0;
}
......@@ -23,7 +23,7 @@ void TerminalUI::draw(Level *lvl)
}
}
void TerminalUI::interface()
void TerminalUI::userInterface()
{
cout << "Welcome to the DungeonCrawler Game\n";
......@@ -31,20 +31,14 @@ void TerminalUI::interface()
int UserOperation = {};
cout<<"Tell me your desires\n"
<< "1: Create a field\n"
<< "2: Enter the Dungeon\n"
<< "1: Enter the Dungeon\n"
<< "0: Exit\n";
cin >> UserOperation;
switch (UserOperation) {
case 1: int height,width;
cout << "height\n>";
cin >> height;
cout << "\n width\n>";
cin >> width;
std::cout << endl;
Level* level = new Level(height,width);
level->setLevelStructure();
case 1: { cout << "You entered the Dungeon\n";return;
}
}
}
......
......@@ -10,7 +10,7 @@ public:
// AbstractUI interface
void draw(Level *lvl) override;
void interface();
void userInterface() override;
void levelInterface();
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment