Commit b22cb79a authored by Felix Huther's avatar Felix Huther
Browse files

pit and ramp

parent 61b1f2a1
......@@ -6,6 +6,7 @@ CONFIG -= qt
SOURCES += \
abstractui.cpp \
character.cpp \
controller.cpp \
door.cpp \
dungeoncrawler.cpp \
floor.cpp \
......@@ -25,6 +26,7 @@ SOURCES += \
HEADERS += \
abstractui.h \
character.h \
controller.h \
door.h \
dungeoncrawler.h \
floor.h \
......
......@@ -10,10 +10,6 @@ public:
virtual void draw(Level *pLevel) = 0;
virtual char askMoveFromUser() = 0 ;
protected:
Level* mCurrentLevel;
};
......
#include "controller.h"
Controller::Controller()
{
}
#ifndef CONTROLLER_H
#define CONTROLLER_H
class Controller
{
public:
Controller();
virtual char askMoveFromUser() = 0 ;
};
#endif // CONTROLLER_H
......@@ -47,7 +47,10 @@ void DungeonCrawler::play() {
system("CLS");
mUserInterface->draw(mCurrentLevel);
movingDirection = mUserInterface->askMoveFromUser();
TerminalUI* termUI = static_cast<TerminalUI*>(mUserInterface);
movingDirection= termUI->askMoveFromUser();
switch (movingDirection) {
case 'w': {
int oneRowUp = characterPos.getRow()-1;
......
......@@ -4,6 +4,7 @@
#include "level.h"
#include "character.h"
#include "abstractui.h"
#include "terminalui.h"
class AbstractUI;
class DungeonCrawler {
......
......@@ -9,6 +9,7 @@ Floor::~Floor()
delete currentCharacter;
}
Tile *Floor::onEnter(Tile *fromTile, Character *who) {
if(typeid(*fromTile) == typeid(Pit))
{
......
......@@ -10,6 +10,8 @@ public:
Floor(const std::string &texture, Character *currentCharacter, const Position2D &position);
~Floor();
Floor(const Floor& other);
Tile* onEnter(Tile* fromTile,Character* who) override;
bool moveTo(Tile* destTile, Character* who) override;
Tile* onLeave(Tile* destTile,Character* who) override;
......
......@@ -5,6 +5,12 @@ Level::Level(int height,int width) : mwidth(width),mheight(height) {
setStructure();
}
Level::Level(const Level &other)
:mwidth(other.mwidth),mheight(other.mheight)
{
}
int Level::getHeight() const {
return mheight;
}
......
......@@ -16,8 +16,8 @@ class Level {
//MEMBER VARIABLES
private:
const int mwidth;
const int mheight;
int mwidth;
int mheight;
Character* mcharacter;
std::vector<std::vector<Tile*>>mLevel;
......@@ -28,6 +28,7 @@ private:
//CONSTRUCTOR AND DESTRUCTOR
public:
explicit Level(int height,int width);
Level(const Level& other);
~Level();
//GETTER AND SETTER
......
#ifndef TERMINALUI_H
#define TERMINALUI_H
#include "abstractui.h"
#include "controller.h"
class TerminalUI : public AbstractUI{
class TerminalUI : public AbstractUI, public Controller
{
public:
TerminalUI(Level *mCurrentLevel);
~TerminalUI();
//AbstractUI interface
public:
void draw(Level *pLevel) override;
void draw(Level *pLevel) override;
// Controller interface
public:
char askMoveFromUser() override;
};
#endif // TERMINALUI_H
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeRunConfigurationManager">
<generated>
<config projectName="NEWpraktika1" targetName="NEWpraktika1" />
</generated>
</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="d5b360b0-c34a-4ada-b8c5-2e45a1dab924" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ClangdSettings">
<option name="formatViaClangd" value="false" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/Level.cpp" root0="SKIP_INSPECTION" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectApplicationVersion">
<option name="ide" value="CLion" />
<option name="majorVersion" value="2022" />
<option name="minorVersion" value="1" />
</component>
<component name="ProjectId" id="29OP8O4EnbKvHw8wOWpTjcwGRGQ" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;cf.first.check.clang-format&quot;: &quot;false&quot;,
&quot;cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;cmake.loaded.for.project&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/felix/Documents/GitLab/programmieren2/HoersaalUebungen/22.04.2022_Hoersaal/Hoersaal/Hoersaal.pro.user&quot;
}
}</component>
<component name="RunManager">
<configuration name="NEWpraktika1" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="NEWpraktika1" TARGET_NAME="NEWpraktika1" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="NEWpraktika1" RUN_TARGET_NAME="NEWpraktika1">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d5b360b0-c34a-4ada-b8c5-2e45a1dab924" name="Changes" comment="" />
<created>1652980999060</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1652980999060</updated>
<workItem from="1652981000472" duration="12588000" />
<workItem from="1653024659543" duration="45000" />
<workItem from="1653041073291" duration="1151000" />
<workItem from="1653299928699" duration="13000" />
<workItem from="1654854534198" duration="3904000" />
<workItem from="1655039421786" duration="58000" />
<workItem from="1655051420822" duration="42000" />
<workItem from="1655315712004" duration="24000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>
\ No newline at end of file
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