diff --git a/src/Core/Crawl/icontrol.h b/src/Core/Crawl/icontrol.h index ef14381..cd8a7ee 100644 --- a/src/Core/Crawl/icontrol.h +++ b/src/Core/Crawl/icontrol.h @@ -42,6 +42,7 @@ public: * @return return path to qml view. */ const QString &view() const; + signals: void viewChanged(); diff --git a/src/Core/Crawl/iworld.cpp b/src/Core/Crawl/iworld.cpp index 5da6e7d..8a6f9f9 100644 --- a/src/Core/Crawl/iworld.cpp +++ b/src/Core/Crawl/iworld.cpp @@ -54,13 +54,20 @@ void IWorld::render(unsigned int tbfMsec) { } _ItemsMutex.lock(); - + QList toRemove; for (auto i = _items.begin(); i != _items.end(); ++i) { + if ((*i)->destroyIsScheduled()) + toRemove.push_back((*i)->guiId()); + (*i)->render(tbfMsec); } _ItemsMutex.unlock(); + for (int id: toRemove) { + removeItem(id); + } + updateWorld(); int waitTime = 1000 / targetFps() - tbfMsec; diff --git a/src/Core/Crawl/iworlditem.cpp b/src/Core/Crawl/iworlditem.cpp index d103ce6..4ca9e24 100644 --- a/src/Core/Crawl/iworlditem.cpp +++ b/src/Core/Crawl/iworlditem.cpp @@ -36,16 +36,7 @@ const IWorldItem *IWorldItem::getPlayer() const { void IWorldItem::render(unsigned int) { if (_playerObject->position().distanceToPoint(position()) > _world->cameraReleativePosition().z() * 3) { - - float dX = _world->cameraReleativePosition().z() * 2 + - (rand() % static_cast(_world->cameraReleativePosition().z())); - - setX(_playerObject->position().x() + dX); - - float dY = (rand() % static_cast(_world->cameraReleativePosition().z() * 3) - - _world->cameraReleativePosition().z() * 1.5); - - setY(_playerObject->position().y() + dY); + respawn(); } } @@ -64,16 +55,36 @@ bool IWorldItem::isSopportEvent(int event) const { return (_supportedEvents & event) == event; } +void IWorldItem::destroy() { + _fDistroy = true; +} + +void IWorldItem::respawn() { + float dX = _world->cameraReleativePosition().z() * 2 + + (rand() % static_cast(_world->cameraReleativePosition().z())); + + setX(_playerObject->position().x() + dX); + + float dY = (rand() % static_cast(_world->cameraReleativePosition().z() * 3) + - _world->cameraReleativePosition().z() * 1.5); + + setY(_playerObject->position().y() + dY); +} + +bool IWorldItem::destroyIsScheduled() const { + return _fDistroy; +} + void IWorldItem::setSupportedEvents(int newSupportedEvents) { _supportedEvents = newSupportedEvents; } void IWorldItem::addSupportOfEvent(int newSupportedEvent) { - + _supportedEvents = _supportedEvents | newSupportedEvent; } void IWorldItem::dropSupportOfEvent(int depricatedEvent) { - + _supportedEvents = _supportedEvents & (~depricatedEvent); } bool IWorldItem::isDecorative() const { diff --git a/src/Core/Crawl/iworlditem.h b/src/Core/Crawl/iworlditem.h index 438f684..62ed575 100644 --- a/src/Core/Crawl/iworlditem.h +++ b/src/Core/Crawl/iworlditem.h @@ -59,6 +59,24 @@ public: */ bool isSopportEvent(int event) const; + /** + * @brief destroy this method will schedule a destroing of this object on the world. + * @see IWorldItem::destroyIsScheduled + */ + virtual void destroy(); + + /** + * @brief respawn this method will schedule a repawning of this object on the world. + */ + virtual void respawn(); + + /** + * @brief destroyIsScheduled This method return true if the current object has been scheduled to destroy. + * @return true if the current object has been scheduled to destroy, else false. + * @see IWorldItem::destroy + */ + bool destroyIsScheduled() const; + protected: /** @@ -122,7 +140,7 @@ private: const IWorldItem *_playerObject = nullptr; bool _fDecorative = true; - + bool _fDistroy = false; int _supportedEvents; friend class IWorld; diff --git a/src/Core/Crawl/playableobject.cpp b/src/Core/Crawl/playableobject.cpp index 0eb9eb0..a9f187e 100644 --- a/src/Core/Crawl/playableobject.cpp +++ b/src/Core/Crawl/playableobject.cpp @@ -23,6 +23,10 @@ void PlayableObject::render(unsigned int tbfMsec) { MovableObject::render(tbfMsec); } +const IControl *PlayableObject::currentControl() const { + return _currentControl; +} + void PlayableObject::setControl(const IControl *control) { diff --git a/src/Core/Crawl/playableobject.h b/src/Core/Crawl/playableobject.h index 5b150cc..e6a39f6 100644 --- a/src/Core/Crawl/playableobject.h +++ b/src/Core/Crawl/playableobject.h @@ -57,6 +57,12 @@ public: */ virtual void setControl(const IControl* control); + /** + * @brief currentControl This method return pointer to current control + * @return + */ + const IControl *currentControl() const; + protected: void render(unsigned int tbfMsec) override; diff --git a/src/Core/Crawl/player.cpp b/src/Core/Crawl/player.cpp new file mode 100644 index 0000000..f3c5baa --- /dev/null +++ b/src/Core/Crawl/player.cpp @@ -0,0 +1,14 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "player.h" +namespace CRAWL { + +Player::Player() { + +} +} diff --git a/src/Core/Crawl/player.h b/src/Core/Crawl/player.h new file mode 100644 index 0000000..4a33df0 --- /dev/null +++ b/src/Core/Crawl/player.h @@ -0,0 +1,26 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef PLAYER_H +#define PLAYER_H + +#include "icontrol.h" + +namespace CRAWL { + +/** + * @brief The Player class is main class of users. + */ +class CRAWL_EXPORT Player: public IControl +{ + Q_OBJECT +public: + Player(); +}; +} +#endif // PLAYER_H diff --git a/src/Core/private/user.cpp b/src/Core/private/user.cpp new file mode 100644 index 0000000..041d3b6 --- /dev/null +++ b/src/Core/private/user.cpp @@ -0,0 +1,16 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "user.h" +namespace CRAWL { + +User::User() +{ + +} + +} diff --git a/src/Core/private/user.h b/src/Core/private/user.h new file mode 100644 index 0000000..47d7796 --- /dev/null +++ b/src/Core/private/user.h @@ -0,0 +1,31 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include + +#ifndef USER_H +#define USER_H + +namespace CRAWL { + +/** + * @brief The User class This is internal class for collection all user data and user state. + */ +class User +{ +public: + User(); + +private: + int _moneu = 0; + int _lvl = 0; + QSet _unlockedItems; + +}; +} + +#endif // USER_H