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

before moving directories

parent a2a1b708
#include "graphicalui.h"
GraphicalUi::GraphicalUi(Level *mCurrentLevel)
: AbstractUI(mCurrentLevel)
{}
char GraphicalUi::askMoveFromUser()
{
Dialog startbildschirm;
startbildschirm.show();
}
......
#ifndef GRAPHICALUI_H
#define GRAPHICALUI_H
#include "abstractui.h"
#include "controller.h"
#include "abstractui.h"
#include "dialog.h"
class GraphicalUi : public AbstractUI,public Controller
class GraphicalUi : public Controller,public AbstractUI
{
public:
GraphicalUi(Level *mCurrentLevel);
// AbstractUI interface
public:
void draw(Level *pLevel) override;
// Controller interface
public:
char askMoveFromUser() override;
// AbstractUI interface
public:
void draw(Level *pLevel) override;
private:
Dialog startbildschirm;
};
#endif // GRAPHICALUI_H
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
../../DungeonCrawler/DungeonGame/abstractui.cpp \
../../DungeonCrawler/DungeonGame/character.cpp \
../../DungeonCrawler/DungeonGame/controller.cpp \
../../DungeonCrawler/DungeonGame/door.cpp \
../../DungeonCrawler/DungeonGame/dungeoncrawler.cpp \
../../DungeonCrawler/DungeonGame/floor.cpp \
../../DungeonCrawler/DungeonGame/graphicalui.cpp \
level.cpp \
../../DungeonCrawler/DungeonGame/main.cpp \
../../DungeonCrawler/DungeonGame/observerpassive.cpp \
../../DungeonCrawler/DungeonGame/pit.cpp \
../../DungeonCrawler/DungeonGame/portal.cpp \
../../DungeonCrawler/DungeonGame/position2d.cpp \
../../DungeonCrawler/DungeonGame/ramp.cpp \
../../DungeonCrawler/DungeonGame/subjectactiv.cpp \
../../DungeonCrawler/DungeonGame/switch.cpp \
../../DungeonCrawler/DungeonGame/terminalui.cpp \
../../DungeonCrawler/DungeonGame/testklasse.cpp \
../../DungeonCrawler/DungeonGame/tile.cpp \
../../DungeonCrawler/DungeonGame/wall.cpp \
dialog.cpp \
main.cpp \
mainwindow.cpp
HEADERS += \
../../DungeonCrawler/DungeonGame/abstractui.h \
../../DungeonCrawler/DungeonGame/character.h \
../../DungeonCrawler/DungeonGame/controller.h \
../../DungeonCrawler/DungeonGame/door.h \
../../DungeonCrawler/DungeonGame/dungeoncrawler.h \
../../DungeonCrawler/DungeonGame/floor.h \
../../DungeonCrawler/DungeonGame/graphicalui.h \
level.h \
../../DungeonCrawler/DungeonGame/observerpassive.h \
../../DungeonCrawler/DungeonGame/pit.h \
../../DungeonCrawler/DungeonGame/portal.h \
../../DungeonCrawler/DungeonGame/position2d.h \
../../DungeonCrawler/DungeonGame/ramp.h \
../../DungeonCrawler/DungeonGame/subjectactiv.h \
../../DungeonCrawler/DungeonGame/switch.h \
../../DungeonCrawler/DungeonGame/terminalui.h \
../../DungeonCrawler/DungeonGame/testklasse.h \
../../DungeonCrawler/DungeonGame/tile.h \
../../DungeonCrawler/DungeonGame/wall.h \
dialog.h \
mainwindow.h
FORMS += \
dialog.ui \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
#include "StartScreen.h"
#include "dialog.h"
#include "ui_dialog.h"
#include <QLabel>
......@@ -35,6 +35,7 @@ Dialog::~Dialog()
void Dialog::switchWindow()
{
}
#include "level.h"
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;
}
int Level::getWidth() const {
return mwidth;
}
Level::~Level() {
mcharacter = nullptr;
for (auto& inner : mLevel) {
for (auto& item : inner) {
item = nullptr;
delete item;
}
}
}
void Level::placeCharacter(Character *character, Position2D position) {
int row = position.getRow();
int column = position.getColumn();
mcharacter = character;
mLevel.at(row).at(column)->setCurrentCharacter(character);
character->setCurrentTile(mLevel.at(row).at(column));
}
Tile* Level::getTileAtPos(Position2D position) {
int row = position.getRow();
int column = position.getColumn();
return mLevel.at(row).at(column);
}
const Tile *Level::constGetTileAtPos(Position2D position) {
int row = position.getRow();
int column = position.getColumn();
return mLevel.at(row).at(column);
}
const std::vector<std::vector<Tile *>> &Level::getMLevel() const {
return mLevel;
}
Character *Level::getCharacter() const {
return mcharacter;
}
void Level::setStructure() {
std::string stwall = "wall";
std::string stportal = "portal";
std::string stfloor = "floor";
std::string stSwitch = "switch";
std::string stDoor = "door";
std::string stpit = "pit";
std::string stramp = "ramp";
Door* doorPointer;
Switch* switchPointer;
for(int i = 0 ; i < mheight; i++){
std::vector<Tile*> vec;
mLevel.push_back(vec);
for(int j = 0 ; j < mwidth;j++)
{
Position2D pos = Position2D(i,j);
//WALL ARROUND THE FIELD
if((i == 0 && j < mwidth) ||
j == 0 || j == mwidth-1 ||
i == mheight-1
){
Tile* wallpointer = new Wall(stwall,nullptr,pos);
mLevel.at(i).push_back(wallpointer);
} // SOME MORE WALLS
else if(j == 6 || j == 18)
{
if(j == 18 && i == 5)
{
doorPointer = new Door(stDoor,nullptr,pos);
mLevel.at(i).push_back(doorPointer);
}
else
{
Tile* wallpointer = new Wall(stwall,nullptr,pos);
mLevel.at(i).push_back(wallpointer);
}
}// PUT PITS WITH A TWO RAMPS
else if(j == 25 || j == 26 || j == 27 || j == 28 || j == 29 || j == 30)
{
if((i == 2 && j == 25) || (i == 8 && j == 30))
{
Tile* rampPointer = new Ramp(stramp,nullptr,pos);
mLevel.at(i).push_back(rampPointer);
}
else{
Tile* pitPointer = new Pit(stpit,nullptr,pos);
mLevel.at(i).push_back(pitPointer);
}
}
// PLACE A SWITCH
else if(i == 8 && j == 15)
{
switchPointer = new Switch(stSwitch,nullptr,pos);
mLevel.at(i).push_back(switchPointer);
}
// PLACES PORTAL
else if((i == 4 && j == 4) || (i == 8 && j == 8))
{
Tile* portalOne;
Tile* portalTwo;
if(i == 4)
{
portalOne = new Portal(stfloor,nullptr,pos,nullptr);
mLevel.at(i).push_back(portalOne);
}
else
{
portalTwo = new Portal(stportal,nullptr,pos,portalOne);
Portal* portalPointer = static_cast<Portal*>(portalOne);
portalPointer->setDestPortal(portalTwo);
mLevel.at(i).push_back(portalTwo);
}
}
else //PLACES FLOOR
{
Tile* floorPointer= new Floor(stfloor, nullptr,pos);
mLevel.at(i).push_back(floorPointer);
}
}
}
connectObserver(doorPointer,switchPointer);
}
void Level::connectObserver(Door *observer, Switch *subject)
{
subject->registerOberserver(observer);
}
#ifndef LEVEL_H
#define LEVEL_H
#include <vector>
#include "typeinfo"
#include "tile.h"
#include "portal.h"
#include "wall.h"
#include "floor.h"
#include "switch.h"
#include "door.h"
#include "ramp.h"
#include "pit.h"
#include "position2d.h"
class Level {
//MEMBER VARIABLES
private:
int mwidth;
int mheight;
Character* mcharacter;
std::vector<std::vector<Tile*>>mLevel;
//SET STRUCTURE OF LEVEL
void setStructure();
void connectObserver(Door* observer, Switch* subject);
//CONSTRUCTOR AND DESTRUCTOR
public:
explicit Level(int height,int width);
Level(const Level& other);
~Level();
//GETTER AND SETTER
public:
int getHeight() const;
int getWidth() const;
Tile* getTileAtPos(Position2D position);
const Tile* constGetTileAtPos(Position2D position);
Character *getCharacter() const;
const std::vector<std::vector<Tile *>> &getMLevel() const;
void placeCharacter(Character* character, Position2D position);
};
#endif // LEVEL_H
#include "mainwindow.h"
#include "dialog.h"
#include "C:\Users\felix\Documents\GitLab\programmieren2\DungeonCrawler\DungeonGame\abstractui.h"
#include "terminalui.h"
#include "dungeoncrawler.h"
#include "level.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
Level* level = new Level(10,40);
AbstractUI* graphicalui = new GraphicalUi(level);
Character* myCharacter = new Character("metal");
level->placeCharacter(myCharacter,Position2D(2,2));
AbstractUI* termUI = new TerminalUI(level);
DungeonCrawler crawler(level,termUI);
return 0;
return a.exec();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar"/>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
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