4
1
mirror of https://github.com/QuasarApp/Snake.git synced 2025-05-02 20:49:43 +00:00

added namespace for the Core Level

This commit is contained in:
Andrei Yankovich 2021-07-05 17:39:26 +03:00
parent b678ca8366
commit 3a7c8f171f
57 changed files with 215 additions and 41 deletions

@ -20,7 +20,7 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
ClientApp client; CRAWL::ClientApp client;
client.registerLevel<TestLvl>(); client.registerLevel<TestLvl>();

@ -8,6 +8,9 @@
#include "Extensions/claster.h" #include "Extensions/claster.h"
#include "clasteritem.h" #include "clasteritem.h"
namespace CRAWL {
ClasterItem::ClasterItem(const QString &name, ClasterItem::ClasterItem(const QString &name,
const QString &viewTempalte, const QString &viewTempalte,
QObject *ptr): QObject *ptr):
@ -36,3 +39,5 @@ void ClasterItem::removeClaster(Claster *claster) {
const QSet<Claster *> &ClasterItem::parentClasters() const { const QSet<Claster *> &ClasterItem::parentClasters() const {
return _parentClasters; return _parentClasters;
} }
}

@ -13,6 +13,8 @@
#ifndef CLASTERITEM_H #ifndef CLASTERITEM_H
#define CLASTERITEM_H #define CLASTERITEM_H
namespace CRAWL {
class Claster; class Claster;
/** /**
@ -59,4 +61,5 @@ private:
friend class Claster; friend class Claster;
}; };
}
#endif // CLASTERITEM_H #endif // CLASTERITEM_H

@ -23,6 +23,8 @@
#include <viewsolutions.h> #include <viewsolutions.h>
#include "worldstatus.h" #include "worldstatus.h"
namespace CRAWL {
QByteArray ClientApp::initTheme() { QByteArray ClientApp::initTheme() {
int themeIndex = Settings::instance()->getValue(THEME, THEME_DEFAULT).toInt(); int themeIndex = Settings::instance()->getValue(THEME, THEME_DEFAULT).toInt();
@ -149,3 +151,5 @@ void ClientApp::addLvl(IWorld *levelWordl) {
_availableLvls.insert(data.model->name(), data); _availableLvls.insert(data.model->name(), data);
_menu->addWorldViewModel(data.viewModel); _menu->addWorldViewModel(data.viewModel);
} }
}

@ -14,15 +14,18 @@
#include "global.h" #include "global.h"
#include "ilevel.h" #include "ilevel.h"
class QQmlApplicationEngine;
inline void initCrawlResources() { Q_INIT_RESOURCE(Crawl); }
namespace CRAWL {
class Engine; class Engine;
class IWorld; class IWorld;
class WorldViewData; class WorldViewData;
class QQmlApplicationEngine;
class MainMenuModel; class MainMenuModel;
class IControl; class IControl;
inline void initCrawlResources() { Q_INIT_RESOURCE(Crawl); }
/** /**
* @brief The WordlData struct simple structure that contains information about world. * @brief The WordlData struct simple structure that contains information about world.
@ -32,7 +35,6 @@ struct WordlData {
IWorld * model = nullptr; IWorld * model = nullptr;
}; };
/** /**
* @brief The ClientApp class This is main class of the Game engine. * @brief The ClientApp class This is main class of the Game engine.
*/ */
@ -85,4 +87,6 @@ private:
Engine *_engine = nullptr; Engine *_engine = nullptr;
}; };
}
#endif // CLIENTAPP_H #endif // CLIENTAPP_H

@ -7,6 +7,8 @@
#include "defaultcontrol.h" #include "defaultcontrol.h"
namespace CRAWL {
DefaultControl::DefaultControl() { DefaultControl::DefaultControl() {
} }
@ -14,3 +16,4 @@ DefaultControl::DefaultControl() {
QString DefaultControl::initQmlView() const { QString DefaultControl::initQmlView() const {
return "qrc:/CrawlModule/DefaultMenu.qml"; return "qrc:/CrawlModule/DefaultMenu.qml";
} }
}

@ -11,6 +11,9 @@
#include "icontrol.h" #include "icontrol.h"
#include "global.h" #include "global.h"
namespace CRAWL {
/** /**
* @brief The DefaultControl class This class contains default implementation of the game menu. * @brief The DefaultControl class This class contains default implementation of the game menu.
*/ */
@ -37,4 +40,6 @@ signals:
void userTap(); void userTap();
}; };
}
#endif // DEFAULTCONTROL_H #endif // DEFAULTCONTROL_H

@ -1,5 +1,7 @@
#include "diff.h" #include "diff.h"
namespace CRAWL {
QList<int> Diff::getAddedIds() const { QList<int> Diff::getAddedIds() const {
return addedIds; return addedIds;
} }
@ -8,3 +10,4 @@ QList<int> Diff::getRemoveIds() const {
return removeIds; return removeIds;
} }
}

@ -11,6 +11,8 @@
#include <QList> #include <QList>
#include <QObject> #include <QObject>
namespace CRAWL {
class GuiObject; class GuiObject;
/** /**
@ -27,6 +29,7 @@ public:
QList<int> addedIds; QList<int> addedIds;
}; };
Q_DECLARE_METATYPE(Diff) }
Q_DECLARE_METATYPE(CRAWL::Diff)
#endif // DIFF_H #endif // DIFF_H

@ -8,6 +8,8 @@
#ifndef GAMERESULT_H #ifndef GAMERESULT_H
#define GAMERESULT_H #define GAMERESULT_H
namespace CRAWL {
/** /**
* @brief The GameResult struct This is simple structure with game statistic. * @brief The GameResult struct This is simple structure with game statistic.
*/ */
@ -24,4 +26,6 @@ struct GameResult
int distance = 0; int distance = 0;
}; };
}
#endif // GAMERESULT_H #endif // GAMERESULT_H

@ -9,6 +9,9 @@
#include <QVector3D> #include <QVector3D>
namespace CRAWL {
GuiObject::GuiObject(const QString &name, const QString &viewTempalte, QObject *ptr): GuiObject::GuiObject(const QString &name, const QString &viewTempalte, QObject *ptr):
QObject (ptr) { QObject (ptr) {
_viewTemplate = viewTempalte; _viewTemplate = viewTempalte;
@ -180,3 +183,5 @@ void GuiObject::setMash(const QString &newMash) {
_mash = newMash; _mash = newMash;
emit mashChanged(); emit mashChanged();
} }
}

@ -17,6 +17,9 @@
#define DEFAULT_VIEW_TEMPLATE "qrc:/CrawlModule/GraphicItem.qml" #define DEFAULT_VIEW_TEMPLATE "qrc:/CrawlModule/GraphicItem.qml"
namespace CRAWL {
/** /**
* @brief The GuiObject class This base model for gui objects. * @brief The GuiObject class This base model for gui objects.
* *
@ -162,7 +165,6 @@ protected:
int _guiId = -1; int _guiId = -1;
QString _color = "#ff1111"; QString _color = "#ff1111";
private: private:
void generateId(); void generateId();
@ -179,4 +181,5 @@ private:
QString _className; QString _className;
}; };
}
#endif // GUIOBJECT_H #endif // GUIOBJECT_H

@ -7,6 +7,10 @@
#include "iai.h" #include "iai.h"
namespace CRAWL {
IAI::IAI() { IAI::IAI() {
} }
}

@ -10,6 +10,8 @@
#include "global.h" #include "global.h"
namespace CRAWL {
/** /**
* @brief The IAI class Is default interface for ai classes. * @brief The IAI class Is default interface for ai classes.
* @note example of use : * @note example of use :
@ -36,4 +38,5 @@ public:
virtual void stopAI() = 0; virtual void stopAI() = 0;
}; };
}
#endif // IAI_H #endif // IAI_H

@ -7,6 +7,9 @@
#include "icontrol.h" #include "icontrol.h"
namespace CRAWL {
IControl::IControl() { IControl::IControl() {
} }
@ -30,3 +33,5 @@ void IControl::setView(const QString &newView) {
_view = newView; _view = newView;
emit viewChanged(); emit viewChanged();
} }
}

@ -11,6 +11,9 @@
#include <QObject> #include <QObject>
#include "global.h" #include "global.h"
namespace CRAWL {
/** /**
* @brief The IControl class This interface should be contains implementation of custom user interface * @brief The IControl class This interface should be contains implementation of custom user interface
* How to use this class: * How to use this class:
@ -62,4 +65,6 @@ private:
friend class Engine; friend class Engine;
}; };
}
#endif // ICONTROL_H #endif // ICONTROL_H

@ -8,6 +8,9 @@
#include "iground.h" #include "iground.h"
#include "iworld.h" #include "iworld.h"
namespace CRAWL {
IGround::IGround(const QString &name, IGround::IGround(const QString &name,
const QString &viewTempalte, const QString &viewTempalte,
QObject *ptr): QObject *ptr):
@ -24,3 +27,5 @@ void IGround::render(unsigned int ) {
setX(playerObject->position().x() + camera.z() * 4); setX(playerObject->position().x() + camera.z() * 4);
} }
} }
}

@ -11,6 +11,8 @@
#include "iworlditem.h" #include "iworlditem.h"
#include "global.h" #include "global.h"
namespace CRAWL {
/** /**
* @brief The IGround class This is one tile of the world. Any objects of this type created automatically for filing ground plain. * @brief The IGround class This is one tile of the world. Any objects of this type created automatically for filing ground plain.
*/ */
@ -25,4 +27,6 @@ public:
void render(unsigned int tbfMsec) override; void render(unsigned int tbfMsec) override;
}; };
}
#endif // IGROUND_H #endif // IGROUND_H

@ -8,6 +8,9 @@
#ifndef LEVEL_H #ifndef LEVEL_H
#define LEVEL_H #define LEVEL_H
namespace CRAWL {
class IWorld; class IWorld;
/** /**
@ -27,4 +30,6 @@ public:
virtual IWorld* world() = 0; virtual IWorld* world() = 0;
}; };
}
#endif // LEVEL_H #endif // LEVEL_H

@ -8,6 +8,9 @@
#include "defaultcontrol.h" #include "defaultcontrol.h"
#include "iplayer.h" #include "iplayer.h"
namespace CRAWL {
IPlayer::IPlayer(const QString &name, IPlayer::IPlayer(const QString &name,
const QString &viewTempalte, const QString &viewTempalte,
QObject *ptr): QObject *ptr):
@ -53,3 +56,5 @@ void IPlayer::setControl(const IControl *control) {
void IPlayer::kill() { void IPlayer::kill() {
_fDead = true; _fDead = true;
} }
}

@ -13,6 +13,9 @@
#include "iworlditem.h" #include "iworlditem.h"
#include "Extensions/movableobject.h" #include "Extensions/movableobject.h"
namespace CRAWL {
class IControl; class IControl;
/** /**
@ -83,4 +86,6 @@ private:
}; };
}
#endif // IPLAYER_H #endif // IPLAYER_H

@ -6,8 +6,10 @@
//# //#
#include "irender.h" #include "irender.h"
namespace CRAWL {
IRender::IRender() IRender::IRender()
{ {
} }
}

@ -11,6 +11,8 @@
#include "global.h" #include "global.h"
#include "quasarapp.h" #include "quasarapp.h"
namespace CRAWL {
/** /**
* @brief The IRender class This interface provide render functionality for all objects. * @brief The IRender class This interface provide render functionality for all objects.
* @note Override the render method. * @note Override the render method.
@ -57,4 +59,5 @@ public:
}; };
}; };
}
#endif // IRENDER_H #endif // IRENDER_H

@ -18,6 +18,10 @@
#include "clasteritem.h" #include "clasteritem.h"
#include "thread" #include "thread"
#include "chrono" #include "chrono"
#include "diff.h"
namespace CRAWL {
IWorld::IWorld() { IWorld::IWorld() {
@ -419,3 +423,5 @@ void IWorld::runAsBackGround() {
setTargetFps(30); setTargetFps(30);
} }
}

@ -17,9 +17,13 @@
#include <QQuaternion> #include <QQuaternion>
#include <QString> #include <QString>
#include "irender.h" #include "irender.h"
#include "diff.h"
#include "global.h" #include "global.h"
#include <QMutex> #include <QMutex>
#include "Crawl/diff.h"
class ClastersTest;
namespace CRAWL {
class IWorldItem; class IWorldItem;
class IPlayer; class IPlayer;
@ -239,7 +243,7 @@ signals:
* @brief sigOBjctsListChanged This signal emited when lvel status are changed. * @brief sigOBjctsListChanged This signal emited when lvel status are changed.
* @brief diff This is list of removed and addeds items * @brief diff This is list of removed and addeds items
*/ */
void sigOBjctsListChanged(Diff diff); void sigOBjctsListChanged(CRAWL::Diff diff);
/** /**
* @brief cameraReleativePositionChanged This signal emot when releative position of camera cahged. * @brief cameraReleativePositionChanged This signal emot when releative position of camera cahged.
@ -472,7 +476,8 @@ private:
friend class Engine; friend class Engine;
// testing // testing
friend class ClastersTest; friend ClastersTest;
}; };
}
#endif // IWORLD_H #endif // IWORLD_H

@ -9,6 +9,9 @@
#include "iworld.h" #include "iworld.h"
#include "quasarapp.h" #include "quasarapp.h"
namespace CRAWL {
IWorldItem::IWorldItem(const QString& name, IWorldItem::IWorldItem(const QString& name,
const QString& viewTempalte, const QString& viewTempalte,
QObject *ptr): QObject *ptr):
@ -56,3 +59,5 @@ void IWorldItem::initOnWorld(const IWorld *world, const IWorldItem * player) {
const IWorld *IWorldItem::world() const { const IWorld *IWorldItem::world() const {
return _world; return _world;
} }
}

@ -11,6 +11,9 @@
#include <Crawl/guiobject.h> #include <Crawl/guiobject.h>
#include "global.h" #include "global.h"
namespace CRAWL {
class IWorld; class IWorld;
/** /**
* @brief The IWorldItem class This is World item. This class contains functions for control event system. * @brief The IWorldItem class This is World item. This class contains functions for control event system.
@ -62,5 +65,5 @@ private:
const IWorldItem *_playerObject = nullptr; const IWorldItem *_playerObject = nullptr;
friend class IWorld; friend class IWorld;
}; };
}
#endif // IWORLDITEM_H #endif // IWORLDITEM_H

@ -10,6 +10,9 @@
#include "singleclasterworlditem.h" #include "singleclasterworlditem.h"
#include "quasarapp.h" #include "quasarapp.h"
namespace CRAWL {
SingleClasterWorldItem::SingleClasterWorldItem(const QString &name, SingleClasterWorldItem::SingleClasterWorldItem(const QString &name,
const QString &viewTempalte, const QString &viewTempalte,
QObject *ptr): QObject *ptr):
@ -34,3 +37,5 @@ Claster *SingleClasterWorldItem::parentClaster() const {
return *ClasterItem::parentClasters().begin(); return *ClasterItem::parentClasters().begin();
} }
}

@ -11,6 +11,8 @@
#include "clasteritem.h" #include "clasteritem.h"
namespace CRAWL {
class Claster; class Claster;
/** /**
@ -41,5 +43,6 @@ protected:
friend class Claster; friend class Claster;
}; };
}
#endif // SINGLECLASTERWORLDITEM_H #endif // SINGLECLASTERWORLDITEM_H

@ -12,6 +12,9 @@
#include <quasarapp.h> #include <quasarapp.h>
#include <cmath> #include <cmath>
namespace CRAWL {
Snake::Snake(const QString &name, const QString &viewTempalte, QObject *ptr): Snake::Snake(const QString &name, const QString &viewTempalte, QObject *ptr):
IPlayer (name, viewTempalte, ptr) { IPlayer (name, viewTempalte, ptr) {
@ -159,3 +162,5 @@ float Snake::lengthBetwinItems() const{
void Snake::setLengthBetwinItems(float newLengthBetwinItems) { void Snake::setLengthBetwinItems(float newLengthBetwinItems) {
_lengthBetwinItems = newLengthBetwinItems; _lengthBetwinItems = newLengthBetwinItems;
} }
}

@ -11,6 +11,8 @@
#include "iplayer.h" #include "iplayer.h"
#include "Extensions/claster.h" #include "Extensions/claster.h"
namespace CRAWL {
class SnakeItem; class SnakeItem;
/** /**
@ -118,4 +120,6 @@ private:
}; };
}
#endif // SNAKE_H #endif // SNAKE_H

@ -8,6 +8,9 @@
#include "snake.h" #include "snake.h"
#include "snakeitem.h" #include "snakeitem.h"
namespace CRAWL {
SnakeItem::SnakeItem(const QString itemName): SingleClasterWorldItem(itemName) { SnakeItem::SnakeItem(const QString itemName): SingleClasterWorldItem(itemName) {
setAngularVelocity(-1); setAngularVelocity(-1);
@ -41,3 +44,4 @@ void SnakeItem::render(unsigned int tbfMsec) {
const IWorldItem * SnakeItem::prev() const { const IWorldItem * SnakeItem::prev() const {
return _prevObject; return _prevObject;
} }
}

@ -12,6 +12,9 @@
#include "singleclasterworlditem.h" #include "singleclasterworlditem.h"
#include "Extensions/movableobject.h" #include "Extensions/movableobject.h"
namespace CRAWL {
class CRAWL_EXPORT SnakeItem: public SingleClasterWorldItem, public MovableObject class CRAWL_EXPORT SnakeItem: public SingleClasterWorldItem, public MovableObject
{ {
Q_OBJECT Q_OBJECT
@ -35,4 +38,6 @@ private:
const IWorldItem *_prevObject = nullptr; const IWorldItem *_prevObject = nullptr;
}; };
}
#endif // SNAKEITEM_H #endif // SNAKEITEM_H

@ -98,7 +98,7 @@ View3D {
target: privateRoot.world; target: privateRoot.world;
function onSigOBjctsListChanged(diff) { function onSigOBjctsListChanged(diff) {
if (!diff) { if (!diff) {
console.log("dif not found"); console.log("diff not found");
return; return;
} }

@ -69,7 +69,6 @@ Item {
themeWarning.visible = true; themeWarning.visible = true;
} }
} }
} }
Item { Item {

@ -8,6 +8,8 @@
#include "claster.h" #include "claster.h"
#include "Crawl/singleclasterworlditem.h" #include "Crawl/singleclasterworlditem.h"
namespace CRAWL {
Claster::Claster() {} Claster::Claster() {}
Claster::~Claster() { Claster::~Claster() {
@ -34,3 +36,5 @@ void Claster::remove(int id) {
const QHash<int, ClasterItem *> &Claster::objects() const { const QHash<int, ClasterItem *> &Claster::objects() const {
return _objects; return _objects;
} }
}

@ -10,6 +10,9 @@
#include "Crawl/iworlditem.h" #include "Crawl/iworlditem.h"
namespace CRAWL {
class ClasterItem; class ClasterItem;
/** /**
@ -54,4 +57,5 @@ private:
}; };
}
#endif // CLASTER_H #endif // CLASTER_H

@ -10,6 +10,9 @@
#include <math.h> #include <math.h>
#include <Crawl/guiobject.h> #include <Crawl/guiobject.h>
namespace CRAWL {
MovableObject::MovableObject() { MovableObject::MovableObject() {
} }
@ -87,3 +90,5 @@ void MovableObject::renderPosition(GuiObject *object, unsigned int tbfMsec) {
const QVector3D &MovableObject::currentMovableVector() const { const QVector3D &MovableObject::currentMovableVector() const {
return _currentMovableVector; return _currentMovableVector;
} }
}

@ -12,6 +12,9 @@
#include "Crawl/irender.h" #include "Crawl/irender.h"
#include <QVector3D> #include <QVector3D>
namespace CRAWL {
class GuiObject; class GuiObject;
/** /**
@ -106,4 +109,6 @@ private:
float _breakingForce = 0; float _breakingForce = 0;
}; };
}
#endif // MOVABLEOBJECT_H #endif // MOVABLEOBJECT_H

@ -8,6 +8,8 @@
#include "defaultbackgroundai.h" #include "defaultbackgroundai.h"
#include <QTimer> #include <QTimer>
namespace CRAWL {
DefaultBackgroundAI::DefaultBackgroundAI() { DefaultBackgroundAI::DefaultBackgroundAI() {
_timer = new QTimer(); _timer = new QTimer();
_timer->setInterval(1000); _timer->setInterval(1000);
@ -33,3 +35,5 @@ void DefaultBackgroundAI::handleTimerTriger() {
emit userTap(); emit userTap();
} }
}

@ -10,9 +10,10 @@
#include "Crawl/defaultcontrol.h" #include "Crawl/defaultcontrol.h"
#include <Crawl/iai.h> #include <Crawl/iai.h>
class QTimer; class QTimer;
namespace CRAWL {
class DefaultBackgroundAI: public DefaultControl, public IAI { class DefaultBackgroundAI: public DefaultControl, public IAI {
Q_OBJECT Q_OBJECT
public: public:
@ -31,4 +32,5 @@ private:
QTimer *_timer = nullptr; QTimer *_timer = nullptr;
}; };
}
#endif // DEFAULTBACKGROUNDAI_H #endif // DEFAULTBACKGROUNDAI_H

@ -16,6 +16,8 @@
#include "QDateTime" #include "QDateTime"
#include "QtConcurrent" #include "QtConcurrent"
namespace CRAWL {
Engine::Engine(QObject *parent): QObject(parent) { Engine::Engine(QObject *parent): QObject(parent) {
} }
@ -170,3 +172,5 @@ void Engine::renderLoop() {
} }
}

@ -13,6 +13,8 @@
#include <QQmlEngine> #include <QQmlEngine>
#include <Crawl/diff.h> #include <Crawl/diff.h>
namespace CRAWL {
class IWorld; class IWorld;
/** /**
@ -148,4 +150,5 @@ private:
bool _renderLoop = false; bool _renderLoop = false;
}; };
}
#endif // ENGINE_H #endif // ENGINE_H

@ -11,6 +11,8 @@
#include <quasarapp.h> #include <quasarapp.h>
namespace CRAWL {
MainMenuModel::MainMenuModel(QObject *ptr): QObject (ptr) { MainMenuModel::MainMenuModel(QObject *ptr): QObject (ptr) {
_conf = QuasarAppUtils::Settings::instance(); _conf = QuasarAppUtils::Settings::instance();
@ -39,3 +41,4 @@ void MainMenuModel::newGame(const QString &lvl) {
emit sigNewGame(lvl); emit sigNewGame(lvl);
} }
}

@ -16,6 +16,8 @@ namespace ViewSolutions {
class ListViewModel; class ListViewModel;
} }
namespace CRAWL {
class WorldInfo; class WorldInfo;
/** /**
@ -49,4 +51,5 @@ private:
}; };
}
#endif // NETWORKPROFILEMAINMODEL_H #endif // NETWORKPROFILEMAINMODEL_H

@ -7,6 +7,7 @@
#include "worldviewdata.h" #include "worldviewdata.h"
#include "Crawl/iworld.h" #include "Crawl/iworld.h"
namespace CRAWL {
WorldViewData::WorldViewData(const IWorld *data) { WorldViewData::WorldViewData(const IWorld *data) {
setWorldObject(data); setWorldObject(data);
@ -63,3 +64,4 @@ void WorldViewData::setWorldObject(const IWorld *newWorldObject) {
emit dataChanged(); emit dataChanged();
} }
}

@ -10,6 +10,8 @@
#include <QObject> #include <QObject>
namespace CRAWL {
class IWorld; class IWorld;
/** /**
@ -46,5 +48,5 @@ signals:
void dataChanged(); void dataChanged();
void unlockedChanged(); void unlockedChanged();
}; };
}
#endif // WORLDVIEWDATA_H #endif // WORLDVIEWDATA_H

@ -9,7 +9,7 @@
#define BOX_H #define BOX_H
#include "Crawl/iworlditem.h" #include "Crawl/iworlditem.h"
class Box: public IWorldItem { class Box: public CRAWL::IWorldItem {
public: public:
Box(); Box();

@ -9,7 +9,7 @@
#define PLATE_H #define PLATE_H
#include "Crawl/iground.h" #include "Crawl/iground.h"
class Plate: public IGround { class Plate: public CRAWL::IGround {
public: public:
Plate(); Plate();

@ -5,7 +5,7 @@
/** /**
* @brief The TestControl class This controll support custom camera-ratation functions. * @brief The TestControl class This controll support custom camera-ratation functions.
*/ */
class TestControl: public DefaultControl class TestControl: public CRAWL::DefaultControl
{ {
Q_OBJECT Q_OBJECT
public: public:

@ -10,7 +10,7 @@
#include "Crawl/snake.h" #include "Crawl/snake.h"
class TestSnake : public Snake { class TestSnake : public CRAWL::Snake {
Q_OBJECT Q_OBJECT

@ -11,7 +11,7 @@
#include "Crawl/snakeitem.h" #include "Crawl/snakeitem.h"
class TestSnakeItem: public SnakeItem class TestSnakeItem: public CRAWL::SnakeItem
{ {
Q_OBJECT Q_OBJECT
public: public:

@ -17,8 +17,8 @@ World::World() {
setCameraRatation(QQuaternion::fromEulerAngles({0,0,-90})); setCameraRatation(QQuaternion::fromEulerAngles({0,0,-90}));
} }
WorldRule *World::initWorldRules() { CRAWL::WorldRule *World::initWorldRules() {
return new WorldRule { return new CRAWL::WorldRule {
{0, {{registerObject<Box>(), 1000}}} {0, {{registerObject<Box>(), 1000}}}
}; };
} }
@ -43,11 +43,11 @@ int World::costToUnlock() const {
return 0; return 0;
} }
IControl *World::initUserInterface() const { CRAWL::IControl *World::initUserInterface() const {
return new TestControl(); return new TestControl();
} }
void World::initPlayerControl(IControl *control) { void World::initPlayerControl(CRAWL::IControl *control) {
if (auto test = dynamic_cast<TestControl*>(control)) { if (auto test = dynamic_cast<TestControl*>(control)) {
connect(test, &TestControl::xChanged, this, &World::handleXViewChanged); connect(test, &TestControl::xChanged, this, &World::handleXViewChanged);
connect(test, &TestControl::yChanged, this, &World::handleYViewChanged); connect(test, &TestControl::yChanged, this, &World::handleYViewChanged);
@ -56,11 +56,11 @@ void World::initPlayerControl(IControl *control) {
return IWorld::initPlayerControl(control); return IWorld::initPlayerControl(control);
} }
IPlayer *World::initPlayer() const { CRAWL::IPlayer *World::initPlayer() const {
return new TestSnake(); return new TestSnake();
} }
IAI *World::initBackGroundAI() const { CRAWL::IAI *World::initBackGroundAI() const {
return IWorld::initBackGroundAI(); return IWorld::initBackGroundAI();
} }

@ -10,23 +10,23 @@
#include "Crawl/iworld.h" #include "Crawl/iworld.h"
class World : public IWorld { class World : public CRAWL::IWorld {
// IWorld interface // IWorld interface
public: public:
World(); World();
WorldRule *initWorldRules() override; CRAWL::WorldRule *initWorldRules() override;
QString initHdrBackGround() const override; QString initHdrBackGround() const override;
QString description() const override; QString description() const override;
QString imagePreview() const override; QString imagePreview() const override;
QString name() const override; QString name() const override;
int costToUnlock() const override; int costToUnlock() const override;
IControl *initUserInterface() const override; CRAWL::IControl *initUserInterface() const override;
void initPlayerControl(IControl *control) override; void initPlayerControl(CRAWL::IControl *control) override;
IPlayer *initPlayer() const override; CRAWL::IPlayer *initPlayer() const override;
IAI *initBackGroundAI() const override; CRAWL::IAI *initBackGroundAI() const override;
private slots: private slots:
void handleXViewChanged(double dx); void handleXViewChanged(double dx);

@ -12,7 +12,7 @@ TestLvl::TestLvl() {
} }
IWorld *TestLvl::world() { CRAWL::IWorld *TestLvl::world() {
initTestLvlResources(); initTestLvlResources();
return new World(); return new World();
} }

@ -17,14 +17,14 @@ inline void initTestLvlResources() { Q_INIT_RESOURCE(Empty);
/** /**
* @brief The TestLvl class This is test lvlv wraper of the crawl * @brief The TestLvl class This is test lvlv wraper of the crawl
*/ */
class CRAWL_TEST_LEVEL_EXPORT TestLvl: public ILevel class CRAWL_TEST_LEVEL_EXPORT TestLvl: public CRAWL::ILevel
{ {
public: public:
TestLvl(); TestLvl();
// ILevel interface // ILevel interface
public: public:
IWorld *world() override; CRAWL::IWorld *world() override;
}; };
#endif // TESTLVL_H #endif // TESTLVL_H

@ -13,7 +13,8 @@
#include <Crawl/iworld.h> #include <Crawl/iworld.h>
// Test claster object. // Test claster object.
class TestClasterObject: public IWorldItem, public Claster { class TestClasterObject: public CRAWL::IWorldItem,
public CRAWL::Claster {
public: public:
TestClasterObject(): IWorldItem("TestClaster"){}; TestClasterObject(): IWorldItem("TestClaster"){};
@ -22,7 +23,7 @@ protected:
}; };
// Test single claster item // Test single claster item
class TestClasterSingleItem: public SingleClasterWorldItem { class TestClasterSingleItem: public CRAWL::SingleClasterWorldItem {
public: public:
TestClasterSingleItem(): SingleClasterWorldItem("TestClasterSingleItem"){}; TestClasterSingleItem(): SingleClasterWorldItem("TestClasterSingleItem"){};
protected: protected:
@ -30,7 +31,7 @@ protected:
}; };
// Test claster item // Test claster item
class TestClasterItem: public ClasterItem { class TestClasterItem: public CRAWL::ClasterItem {
public: public:
TestClasterItem(): ClasterItem("TestClasterItem"){}; TestClasterItem(): ClasterItem("TestClasterItem"){};
protected: protected:
@ -38,14 +39,14 @@ protected:
}; };
// Test world of clasters // Test world of clasters
class TestWorld: public IWorld { class TestWorld: public CRAWL::IWorld {
public: public:
TestWorld(): IWorld(){}; TestWorld(): IWorld(){};
// IWorld interface // IWorld interface
public: public:
IPlayer *initPlayer() const {return nullptr;}; CRAWL::IPlayer *initPlayer() const {return nullptr;};
WorldRule *initWorldRules() {return nullptr;}; CRAWL::WorldRule *initWorldRules() {return nullptr;};
QString initHdrBackGround() const {return "";}; QString initHdrBackGround() const {return "";};
QString description() const {return "";}; QString description() const {return "";};
QString imagePreview() const {return "";}; QString imagePreview() const {return "";};