mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-06 22:49:44 +00:00
first work action
This commit is contained in:
parent
109d7c5f25
commit
f0162efaab
src
Core
Crawl
day.hdefaultlight.cppdefaultlight.hfire.cppguiobject.cppguiobject.hiworlditem.hparticleeffect.cppsnake.hwint.cppwint.h
private
CrawlAbstractLvl/private
abslvlsnake.cppabslvlsnake.habslvlsnakeitem.cppabslvlsnakeitem.hbaff.cppbaff.hobstacleblue.cppobstacleblue.hobstaclered.cppobstaclered.h
CrawlTestLvl/private
background.cppbackground.hbox.cppbox.hplate.cppplate.htestsnake.cpptestsnake.htestsnakeitem.cpptestsnakeitem.hworld.cpp
JungleLvl/private
tests/units
@ -167,9 +167,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *) override {};
|
||||
|
||||
private:
|
||||
float lengthToSpeed(float length) const {
|
||||
return (2 * M_PI * radius()) / length;
|
||||
|
@ -24,7 +24,4 @@ void DefaultLight::init() {
|
||||
|
||||
}
|
||||
|
||||
void DefaultLight::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,6 @@ public:
|
||||
|
||||
void render(unsigned int tbfMsec) override;
|
||||
void init() override;
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -19,8 +19,7 @@ Fire::Fire(): ParticleEffect(AUTO_CLASS_NAME, "qrc:/CrawlModule/particles/Fire.q
|
||||
|
||||
setLifeSpanVariation(500);
|
||||
setColor("#ffaf2c");
|
||||
setSize({1, 1, 1});
|
||||
setposition({0,0,10});
|
||||
setposition({0,0,1});
|
||||
setEnabled(true);
|
||||
|
||||
setParticleDelegate("qrc:/CrawlModule/particles/FireParticel.qml");
|
||||
|
@ -36,6 +36,10 @@ void GuiObject::generateId() {
|
||||
setGuiId(id++);
|
||||
}
|
||||
|
||||
void GuiObject::setContainerSize(const QVector3D &newContainerSize) {
|
||||
_containerSize = newContainerSize;
|
||||
}
|
||||
|
||||
bool GuiObject::visible() const {
|
||||
return _visible;
|
||||
}
|
||||
@ -132,14 +136,14 @@ QVector3D GuiObject::center() const {
|
||||
}
|
||||
|
||||
bool GuiObject::intersects(const QVector3D &point) const {
|
||||
auto radius = _size / 2;
|
||||
auto radius = _containerSize / 2;
|
||||
float thisMidRadius = (radius.z() + radius.y() + radius.x()) / 3;
|
||||
return center().distanceToPoint(point) < thisMidRadius ;
|
||||
}
|
||||
|
||||
bool GuiObject::intersects(const GuiObject &object) const {
|
||||
auto radius = _size / 2;
|
||||
auto objRadius = object.size() / 2;
|
||||
auto radius = _containerSize / 2;
|
||||
auto objRadius = object._containerSize / 2;
|
||||
float thisMidRadius = (radius.z() + radius.y() + radius.x()) / 3;
|
||||
float objMidRadius = (objRadius.z() + objRadius.y() + objRadius.x()) / 3;
|
||||
|
||||
|
@ -157,6 +157,13 @@ public:
|
||||
int guiId() const;
|
||||
void setGuiId(int guiId);
|
||||
|
||||
/**
|
||||
* @brief containerSize This method sets container size of object. Change this propertye for setting correct work the GuiObject::intersects method.
|
||||
* @param newContainerSize new is new value of the object contaier cube.
|
||||
* @see GuiObject::intersects
|
||||
*/
|
||||
void setContainerSize(const QVector3D &newContainerSize);
|
||||
|
||||
signals:
|
||||
void guiIdChanged(int guiId);
|
||||
void colorChanged(QString color);
|
||||
@ -213,6 +220,7 @@ private:
|
||||
|
||||
QVector3D _position;
|
||||
QVector3D _size;
|
||||
QVector3D _containerSize = {1,1,1};
|
||||
QQuaternion _rotation;
|
||||
QString _mash;
|
||||
QString _className;
|
||||
|
@ -86,12 +86,6 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief onIntersects This is intersect event betwin this and subscribet objects.
|
||||
* @param item This is pointer to the event object.
|
||||
*/
|
||||
virtual void onIntersects(const IWorldItem *item) = 0;
|
||||
|
||||
/**
|
||||
* @brief getItem This method return item world by id. If object is not exits then return nullptr.
|
||||
* @return constant pointer tot the item world.
|
||||
|
@ -17,6 +17,7 @@ ParticleEffect::ParticleEffect(const QString &name,
|
||||
QObject *ptr):
|
||||
IWorldItem(name, viewTempalte, ptr) {
|
||||
|
||||
setFDecorative(true);
|
||||
}
|
||||
|
||||
bool ParticleEffect::enabled() const {
|
||||
|
@ -131,6 +131,8 @@ private:
|
||||
QVector3D* _vectors;
|
||||
float _speed;
|
||||
|
||||
int _hp = 100;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ namespace CRAWL {
|
||||
Wint::Wint(): Affector(AUTO_CLASS_NAME, "qrc:/CrawlModule/particles/Wint.qml") {
|
||||
}
|
||||
|
||||
void Wint::onIntersects(const IWorldItem *) {}
|
||||
|
||||
float Wint::magnitude() const {
|
||||
return _magnitude;
|
||||
}
|
||||
|
@ -66,8 +66,7 @@ signals:
|
||||
void directionChanged();
|
||||
void magnitudeChanged();
|
||||
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
private:
|
||||
|
||||
QVector3D _direction = {1, 0, 0};
|
||||
float _magnitude = 10;
|
||||
|
@ -41,7 +41,7 @@ void EventServer::handleAvailableObjectChanges(const Diff &diff) {
|
||||
for (int added: diff.addedIds) {
|
||||
auto obj = _worldInstance->getItem(added);
|
||||
|
||||
if (!obj->isDecorative()) {
|
||||
if (obj->isDecorative()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,5 @@ AbsLvlSnake::AbsLvlSnake(): Snake(AUTO_CLASS_NAME) {
|
||||
registerItemType<AbsLvlSnakeItem>();
|
||||
}
|
||||
|
||||
void AbsLvlSnake::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ class AbsLvlSnake : public CRAWL::Snake {
|
||||
public:
|
||||
AbsLvlSnake();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -15,9 +15,4 @@ AbsLvlSnakeItem::AbsLvlSnakeItem():CRAWL::SnakeItem(AUTO_CLASS_NAME) {
|
||||
setSize({1,1,1});
|
||||
}
|
||||
|
||||
void AbsLvlSnakeItem::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,9 +19,6 @@ class AbsLvlSnakeItem: public CRAWL::SnakeItem {
|
||||
public:
|
||||
AbsLvlSnakeItem();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,5 @@ Baff::Baff() : IWorldItem(AUTO_CLASS_NAME) {
|
||||
setZ(0);
|
||||
}
|
||||
|
||||
void Baff::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,10 +14,6 @@ namespace AbstractLvl {
|
||||
class Baff: public CRAWL::IWorldItem {
|
||||
public:
|
||||
Baff();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,4 @@ ObstacleBlue::ObstacleBlue() : IWorldItem(AUTO_CLASS_NAME) {
|
||||
setZ(0);
|
||||
}
|
||||
|
||||
void ObstacleBlue::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,10 +14,6 @@ namespace AbstractLvl {
|
||||
class ObstacleBlue: public CRAWL::IWorldItem {
|
||||
public:
|
||||
ObstacleBlue();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,4 @@ ObstacleRed::ObstacleRed() : IWorldItem(AUTO_CLASS_NAME) {
|
||||
setZ(0);
|
||||
}
|
||||
|
||||
void ObstacleRed::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,9 +15,6 @@ class ObstacleRed: public CRAWL::IWorldItem {
|
||||
public:
|
||||
ObstacleRed();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -14,10 +14,6 @@ Background::Background(): CRAWL::GroundClaster("TestBackground") {
|
||||
registerItemType<Plate>();
|
||||
}
|
||||
|
||||
void Background::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item)
|
||||
}
|
||||
|
||||
unsigned int Background::itemsCount() const {
|
||||
return 3;
|
||||
}
|
||||
|
@ -19,13 +19,6 @@ class Background: public CRAWL::GroundClaster
|
||||
{
|
||||
public:
|
||||
Background();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
// AutoGenerateClaster interface
|
||||
public:
|
||||
unsigned int itemsCount() const override;
|
||||
};
|
||||
|
||||
|
@ -24,9 +24,16 @@ Box::Box(): IWorldItem("Box") {
|
||||
setposition({static_cast<float>(rand() % 100) - 50,
|
||||
static_cast<float>(rand() % 100) - 50,
|
||||
0 });
|
||||
|
||||
setFDecorative(false);
|
||||
|
||||
setContainerSize({4, 4, 4});
|
||||
}
|
||||
|
||||
void Box::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
void Box::action(IWorldItem *item) {
|
||||
if (item->className() == getPlayer()->className()) {
|
||||
respawn();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,10 +16,7 @@ class Box: public CRAWL::IWorldItem {
|
||||
|
||||
public:
|
||||
Box();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
void action(IWorldItem *item) override;
|
||||
};
|
||||
}
|
||||
#endif // BOX_H
|
||||
|
@ -18,10 +18,6 @@ Plate::Plate(): CRAWL::GroundTile("TestPlate")
|
||||
setZ(0);
|
||||
}
|
||||
|
||||
void Plate::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item)
|
||||
}
|
||||
|
||||
void Plate::render(unsigned int){
|
||||
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ class Plate: public CRAWL::GroundTile {
|
||||
public:
|
||||
Plate();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
// IRender interface
|
||||
public:
|
||||
void render(unsigned int tbfMsec) override;
|
||||
|
@ -18,11 +18,7 @@ TestSnake::TestSnake(): Snake("Snake") {
|
||||
setSize({2,1,1});
|
||||
|
||||
registerItemType<TestSnakeItem>();
|
||||
|
||||
}
|
||||
|
||||
void TestSnake::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
setContainerSize({2, 2, 2});
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,6 @@ class TestSnake : public CRAWL::Snake {
|
||||
public:
|
||||
TestSnake();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
|
||||
// AutoGenerateClaster interface
|
||||
public:
|
||||
|
@ -15,8 +15,4 @@ TestSnakeItem::TestSnakeItem():CRAWL::SnakeItem("TestSnakeItem") {
|
||||
|
||||
}
|
||||
|
||||
void TestSnakeItem::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ class TestSnakeItem: public CRAWL::SnakeItem
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestSnakeItem();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ CRAWL::WorldRule *World::initWorldRules() {
|
||||
using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>;
|
||||
|
||||
return new CRAWL::WorldRule {
|
||||
{0, {{registerObject<Box>(), 100},
|
||||
{0, {{registerObject<Box>(), 1000},
|
||||
{registerObject<CRAWL::Fire>(), 10},
|
||||
{registerObject<CRAWL::DynamicWint>(), 1},
|
||||
|
||||
|
@ -16,8 +16,6 @@ AbsalutePlate::AbsalutePlate(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
setColor("#000000");
|
||||
}
|
||||
|
||||
void AbsalutePlate::onIntersects(const IWorldItem *) {}
|
||||
|
||||
void AbsalutePlate::render(unsigned int ) {
|
||||
setposition(getPlayer()->position() + QVector3D{0,0,-100});
|
||||
}
|
||||
|
@ -11,10 +11,6 @@ class AbsalutePlate : public CRAWL::IWorldItem
|
||||
public:
|
||||
AbsalutePlate();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
// IRender interface
|
||||
public:
|
||||
void render(unsigned int tbfMsec) override;
|
||||
|
@ -17,8 +17,4 @@ Grees::Grees(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
|
||||
}
|
||||
|
||||
void Grees::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,10 +23,6 @@ class CRAWL_JUNGLE_LEVEL_EXPORT Grees: public CRAWL::IWorldItem
|
||||
Q_OBJECT
|
||||
public:
|
||||
Grees();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
}
|
||||
#endif // GREES_H
|
||||
|
@ -13,10 +13,6 @@ Ground::Ground() : CRAWL::GroundClaster("JungelGroud") {
|
||||
registerItemType<GroundPlate>();
|
||||
}
|
||||
|
||||
void Ground::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
unsigned int Ground::itemsCount() const {
|
||||
return 3;
|
||||
}
|
||||
|
@ -20,13 +20,6 @@ class Ground : public CRAWL::GroundClaster
|
||||
{
|
||||
public:
|
||||
Ground();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
// AutoGenerateClaster interface
|
||||
public:
|
||||
unsigned int itemsCount() const override;
|
||||
};
|
||||
|
||||
|
@ -21,10 +21,6 @@ GroundPlate::GroundPlate(): CRAWL::GroundTile("JungleGroundTile",
|
||||
|
||||
}
|
||||
|
||||
void GroundPlate::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
int GroundPlate::tiliesCount() const {
|
||||
return _tiliesCount;
|
||||
}
|
||||
|
@ -30,9 +30,6 @@ public:
|
||||
signals:
|
||||
void tiliesCountChanged();
|
||||
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
private:
|
||||
int _tiliesCount = 1;
|
||||
};
|
||||
|
@ -15,7 +15,4 @@ LongGress::LongGress(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
|
||||
}
|
||||
|
||||
void LongGress::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,6 @@ class CRAWL_JUNGLE_LEVEL_EXPORT LongGress: public CRAWL::IWorldItem
|
||||
public:
|
||||
LongGress();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -31,10 +31,6 @@ Snake::Snake(): CRAWL::Snake("JungleSnake") {
|
||||
{1, 0.5}});
|
||||
}
|
||||
|
||||
void Snake::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
unsigned int Snake::itemsCount() const {
|
||||
return 50;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ public:
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *) override;
|
||||
unsigned int itemsCount() const override;
|
||||
|
||||
};
|
||||
|
@ -19,8 +19,4 @@ void SnakeItem::init() {
|
||||
|
||||
}
|
||||
|
||||
void SnakeItem::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,10 +18,6 @@ class SnakeItem : public CRAWL::SnakeItem
|
||||
public:
|
||||
SnakeItem();
|
||||
void init() override;
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,4 @@ Tree::Tree(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
setZ(-static_cast<float>(rand() % 10));
|
||||
}
|
||||
|
||||
void Tree::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,6 @@ class CRAWL_JUNGLE_LEVEL_EXPORT Tree : public CRAWL::IWorldItem
|
||||
Q_OBJECT
|
||||
public:
|
||||
Tree();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *) override;
|
||||
};
|
||||
}
|
||||
#endif // TREE_H
|
||||
|
@ -19,8 +19,6 @@ public:
|
||||
TestGroupObject(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||
|
||||
}
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *) override {};
|
||||
|
||||
// IRender interface
|
||||
void render(unsigned int tbfMsec) override {
|
||||
@ -40,8 +38,6 @@ public:
|
||||
TestGroupObjectItem(): CRAWL::ClasterItem(AUTO_CLASS_NAME) {
|
||||
|
||||
}
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *) override {};
|
||||
};
|
||||
|
||||
GroupObjectTest::GroupObjectTest() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user