mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-27 10:14:39 +00:00
commit
d56e97cf5f
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -16,3 +16,6 @@
|
||||
[submodule "src/CrawlAbstractLvl/CrawlAbstractLevelAssets"]
|
||||
path = src/CrawlAbstractLvl/CrawlAbstractLevelAssets
|
||||
url = ssh://web@quasarapp.ddns.net:2022/QuasarApp/CrawlAbstractLevelAssets.git
|
||||
[submodule "src/JungleLvl/CrawlJungleLvlAssests"]
|
||||
path = src/JungleLvl/CrawlJungleLvlAssests
|
||||
url = ssh://web@quasarapp.ddns.net:2022/QuasarApp/CrawlJungleLvlAssests.git
|
||||
|
@ -66,6 +66,7 @@ add_subdirectory(submodules/ViewSolutions)
|
||||
add_subdirectory(src/Core)
|
||||
add_subdirectory(src/CrawlTestLvl)
|
||||
add_subdirectory(src/CrawlAbstractLvl)
|
||||
add_subdirectory(src/JungleLvl)
|
||||
|
||||
add_subdirectory(src/Client)
|
||||
|
||||
|
@ -26,7 +26,7 @@ else()
|
||||
add_executable(${CURRENT_PROJECT} ${SOURCE_CPP})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME}Core TestLvl AbstractLvl)
|
||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME}Core TestLvl JungleLvl AbstractLvl)
|
||||
|
||||
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
|
||||
target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
|
||||
@ -38,6 +38,7 @@ if (ANDROID)
|
||||
set(SNAKE_EXTRA_LIBS "${PROJECT_NAME}Core"
|
||||
TestLvl
|
||||
AbstractLvl
|
||||
JungleLvl
|
||||
QuasarApp
|
||||
QmlNotyfyService
|
||||
ViewSolutions)
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -26,6 +26,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>JungleLvl::World</name>
|
||||
<message>
|
||||
<source>Jungle world.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Jungle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainMenu</name>
|
||||
<message>
|
||||
|
@ -9,9 +9,10 @@
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <Crawl/clientapp.h>
|
||||
#include <testlvl.h>
|
||||
#include <testlevel.h>
|
||||
#include <abstractlvl.h>
|
||||
#include <quasarapp.h>
|
||||
#include <jungle.h>
|
||||
|
||||
void initLang() {
|
||||
QLocale locale = QLocale::system();
|
||||
@ -38,8 +39,9 @@ int main(int argc, char *argv[])
|
||||
QQmlApplicationEngine engine;
|
||||
CRAWL::ClientApp client;
|
||||
|
||||
client.registerLevel<TestLvl>();
|
||||
client.registerLevel<TestLevel>();
|
||||
client.registerLevel<AbstractLvl>();
|
||||
client.registerLevel<Jungle>();
|
||||
|
||||
if (!client.init(&engine)) {
|
||||
return 1;
|
||||
|
80
src/Core/Crawl/groundclaster.cpp
Normal file
80
src/Core/Crawl/groundclaster.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
//#
|
||||
//# 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 "groundclaster.h"
|
||||
#include "iworld.h"
|
||||
#include "clasteritem.h"
|
||||
|
||||
namespace CRAWL {
|
||||
|
||||
|
||||
GroundClaster::GroundClaster(const QString &name,
|
||||
const QString &viewTempalte,
|
||||
QObject *ptr):
|
||||
IWorldItem(name, viewTempalte, ptr) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GroundClaster::render(unsigned int ) {
|
||||
const IWorldItem *playerObject = getPlayer();
|
||||
|
||||
if (!_itemsOrder.size()) {
|
||||
QuasarAppUtils::Params::log("The GroundClaster do not have any claster items.",
|
||||
QuasarAppUtils::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
auto object = _itemsOrder.at(_index % _itemsOrder.size());
|
||||
|
||||
if (playerObject->position().x() - object->position().x() >
|
||||
newObjectDistance()) {
|
||||
|
||||
auto prewObject = _itemsOrder.at((_index - 1) % _itemsOrder.size());
|
||||
|
||||
object->setposition({prewObject->position().x() + newObjectDistance(),
|
||||
playerObject->position().y(),
|
||||
object->position().z() - static_cast<float>(0.0001)});
|
||||
|
||||
_index++;
|
||||
}
|
||||
}
|
||||
|
||||
void GroundClaster::add(ClasterItem *object) {
|
||||
|
||||
object->setX(newObjectDistance() * _itemsOrder.count());
|
||||
_itemsOrder.push_back(object);
|
||||
|
||||
Claster::add(object);
|
||||
}
|
||||
|
||||
void GroundClaster::remove(ClasterItem *object) {
|
||||
_itemsOrder.push_back(object);
|
||||
|
||||
Claster::remove(object);
|
||||
}
|
||||
|
||||
void GroundClaster::remove(int id) {
|
||||
_itemsOrder.push_back(objects().value(id));
|
||||
|
||||
Claster::remove(id);
|
||||
}
|
||||
|
||||
void GroundClaster::init() {
|
||||
generateItems();
|
||||
}
|
||||
|
||||
int GroundClaster::newObjectDistance() const {
|
||||
return 500;
|
||||
}
|
||||
|
||||
unsigned int GroundClaster::itemsCount() const {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
}
|
58
src/Core/Crawl/groundclaster.h
Normal file
58
src/Core/Crawl/groundclaster.h
Normal file
@ -0,0 +1,58 @@
|
||||
//#
|
||||
//# 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 GROUNDCLASTER_H
|
||||
#define GROUNDCLASTER_H
|
||||
|
||||
#include "Extensions/autogenerateclaster.h"
|
||||
#include "global.h"
|
||||
#include "Crawl/iworlditem.h"
|
||||
|
||||
namespace CRAWL {
|
||||
|
||||
/**
|
||||
* @brief The GroundClaster class This is main control class for background plates of the world.
|
||||
* Default behavior: create the tile grid and move old tiles to end of the world.
|
||||
*
|
||||
* @note use This class with child classes of the GroundTile class.
|
||||
*/
|
||||
class CRAWL_EXPORT GroundClaster: public IWorldItem, public AutoGenerateClaster {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GroundClaster(const QString& name,
|
||||
const QString& viewTempalte = DEFAULT_VIEW_TEMPLATE,
|
||||
QObject *ptr = nullptr);
|
||||
|
||||
// IRender interface
|
||||
void render(unsigned int tbfMsec) override;
|
||||
|
||||
void add(ClasterItem *object) override;
|
||||
void remove(ClasterItem *object) override;
|
||||
void remove(int id) override;
|
||||
void init() override;
|
||||
unsigned int itemsCount() const override;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief newObjectDistance This method should be return default distance betwin clstersItems
|
||||
* @return default distance betwin clstersItems
|
||||
* @note By default this value equals 2000 points
|
||||
*/
|
||||
virtual int newObjectDistance() const;
|
||||
|
||||
private:
|
||||
QList<IWorldItem*> _itemsOrder;
|
||||
unsigned int _index = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GROUNDCLASTER_H
|
14
src/Core/Crawl/groundtile.cpp
Normal file
14
src/Core/Crawl/groundtile.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "groundtile.h"
|
||||
namespace CRAWL {
|
||||
|
||||
GroundTile::GroundTile(const QString &name,
|
||||
const QString &viewTempalte,
|
||||
QObject *ptr):
|
||||
ClasterItem(name, viewTempalte, ptr) {
|
||||
|
||||
}
|
||||
|
||||
void CRAWL::GroundTile::render(unsigned int) {
|
||||
|
||||
}
|
||||
}
|
38
src/Core/Crawl/groundtile.h
Normal file
38
src/Core/Crawl/groundtile.h
Normal file
@ -0,0 +1,38 @@
|
||||
//#
|
||||
//# 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 GROUNDTILE_H
|
||||
#define GROUNDTILE_H
|
||||
|
||||
#include "clasteritem.h"
|
||||
|
||||
namespace CRAWL {
|
||||
|
||||
/**
|
||||
* @brief The GroundTile class It reimplementation of the ClasterItem. The groundTile do not heve own render function because the GroundClaster class control position of this class.
|
||||
*
|
||||
* @note use This class with the GroundClaster class.
|
||||
*/
|
||||
class CRAWL_EXPORT GroundTile: public ClasterItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GroundTile(const QString& name,
|
||||
const QString& viewTempalte = DEFAULT_VIEW_TEMPLATE,
|
||||
QObject *ptr = nullptr);
|
||||
|
||||
// IRender interface
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief render The current render implementation do nothing.
|
||||
* @param tbfMsec This is time betwin frames value. (in milleseconds)
|
||||
*/
|
||||
void render(unsigned int tbfMsec) override;
|
||||
};
|
||||
}
|
||||
#endif // GROUNDTILE_H
|
@ -17,7 +17,7 @@ GuiObject::GuiObject(const QString &name, const QString &viewTempalte, QObject *
|
||||
_viewTemplate = viewTempalte;
|
||||
_className = name;
|
||||
generateId();
|
||||
setRatation({1,1,0,0});
|
||||
setRatation(QQuaternion::fromEulerAngles({0,0,0}));
|
||||
}
|
||||
|
||||
QString GuiObject::color() const {
|
||||
@ -184,4 +184,34 @@ void GuiObject::setMash(const QString &newMash) {
|
||||
emit mashChanged();
|
||||
}
|
||||
|
||||
void GuiObject::setBaseColorMap(const QString &baseColorMap) {
|
||||
if (_baseColorMap == baseColorMap)
|
||||
return;
|
||||
_baseColorMap = baseColorMap;
|
||||
emit baseColorMapChanged();
|
||||
}
|
||||
|
||||
|
||||
void GuiObject::setRoughnessMap(const QString &roughnessMap) {
|
||||
if (_roughnessMap == roughnessMap)
|
||||
return;
|
||||
_roughnessMap = roughnessMap;
|
||||
emit roughnessMapChanged();
|
||||
}
|
||||
|
||||
|
||||
void GuiObject::setNormalMap(const QString &normalMap) {
|
||||
if (_normalMap == normalMap)
|
||||
return;
|
||||
_normalMap = normalMap;
|
||||
emit normalMapChanged();
|
||||
}
|
||||
|
||||
void GuiObject::setEmissiveMap(const QString &emissiveMap) {
|
||||
if (_emissiveMap == emissiveMap)
|
||||
return;
|
||||
_emissiveMap = emissiveMap;
|
||||
emit emissiveMapChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -162,12 +162,36 @@ signals:
|
||||
|
||||
protected:
|
||||
|
||||
int _guiId = -1;
|
||||
QString _color = "#ff1111";
|
||||
/**
|
||||
* @brief setBaseColorMap This method sets path to the base color map of the object. See the baseColorMap method for get more information.
|
||||
* @param baseColorMap This is new value of the path to base color map.
|
||||
*/
|
||||
void setBaseColorMap(const QString& baseColorMap);
|
||||
|
||||
/**
|
||||
* @brief setRoughnessMap This method sets path to the roughness map of the object. See the roughnessMap method for get more information.
|
||||
* @param roughnessMap This is new value of the path to roughness map.
|
||||
*/
|
||||
void setRoughnessMap(const QString& roughnessMap);
|
||||
|
||||
/**
|
||||
* @brief setNormalMap This method sets path to the normal map of the object. See the normalMap method for get more information.
|
||||
* @param normalMap This is new value of the path to normal map.
|
||||
*/
|
||||
void setNormalMap(const QString& normalMap);
|
||||
|
||||
/**
|
||||
* @brief setEmissiveMap This method sets path to the emissive map of the object. See the emissiveMap method for get more information.
|
||||
* @param emissiveMap This is new value of the path to emissive map.
|
||||
*/
|
||||
void setEmissiveMap(const QString& emissiveMap);
|
||||
|
||||
private:
|
||||
void generateId();
|
||||
|
||||
int _guiId = -1;
|
||||
QString _color = "#ff1111";
|
||||
|
||||
QString _baseColorMap;
|
||||
QString _roughnessMap;
|
||||
QString _normalMap;
|
||||
|
@ -5,8 +5,8 @@
|
||||
//# of this license document, but changing it is not allowed.
|
||||
//#
|
||||
|
||||
#ifndef ICONTROL_H
|
||||
#define ICONTROL_H
|
||||
#ifndef CRAWL_ICONTROL_H
|
||||
#define CRAWL_ICONTROL_H
|
||||
|
||||
#include <QObject>
|
||||
#include "global.h"
|
||||
@ -67,4 +67,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // ICONTROL_H
|
||||
#endif // CRAWL_ICONTROL_H
|
||||
|
@ -1,31 +0,0 @@
|
||||
//#
|
||||
//# 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 "iground.h"
|
||||
#include "iworld.h"
|
||||
|
||||
namespace CRAWL {
|
||||
|
||||
|
||||
IGround::IGround(const QString &name,
|
||||
const QString &viewTempalte,
|
||||
QObject *ptr):
|
||||
IWorldItem(name, viewTempalte, ptr) {
|
||||
|
||||
}
|
||||
|
||||
void IGround::render(unsigned int ) {
|
||||
const IWorldItem *playerObject = getPlayer();
|
||||
QVector3D camera = world()->cameraReleativePosition();
|
||||
|
||||
if (playerObject->position().x() - position().x() >
|
||||
camera.z() * 2) {
|
||||
setX(playerObject->position().x() + camera.z() * 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
//#
|
||||
//# 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 IGROUND_H
|
||||
#define IGROUND_H
|
||||
|
||||
#include "iworlditem.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.
|
||||
*/
|
||||
class CRAWL_EXPORT IGround: public IWorldItem {
|
||||
public:
|
||||
IGround(const QString& name,
|
||||
const QString& viewTempalte = DEFAULT_VIEW_TEMPLATE,
|
||||
QObject *ptr = nullptr);
|
||||
|
||||
// IRender interface
|
||||
public:
|
||||
void render(unsigned int tbfMsec) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // IGROUND_H
|
@ -11,7 +11,7 @@
|
||||
#include "iworlditem.h"
|
||||
#include <defaultbackgroundai.h>
|
||||
#include <quasarapp.h>
|
||||
#include "iground.h"
|
||||
#include "groundclaster.h"
|
||||
#include "defaultcontrol.h"
|
||||
#include "worldstatus.h"
|
||||
#include "iai.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
//# of this license document, but changing it is not allowed.
|
||||
//#
|
||||
|
||||
#ifndef IWORLD_H
|
||||
#define IWORLD_H
|
||||
#ifndef CRAWL_IWORLD_H
|
||||
#define CRAWL_IWORLD_H
|
||||
|
||||
#include "iplayer.h"
|
||||
|
||||
@ -27,7 +27,7 @@ namespace CRAWL {
|
||||
|
||||
class IWorldItem;
|
||||
class IPlayer;
|
||||
class IGround;
|
||||
class GroundClaster;
|
||||
class IControl;
|
||||
class IAI;
|
||||
|
||||
@ -489,4 +489,4 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
#endif // IWORLD_H
|
||||
#endif // CRAWL_IWORLD_H
|
||||
|
@ -20,10 +20,8 @@ Snake::Snake(const QString &name, const QString &viewTempalte, QObject *ptr):
|
||||
|
||||
_vectors = new QVector3D[2];
|
||||
setAngularVelocity(100);
|
||||
setSpeed(100);
|
||||
|
||||
setLengthBetwinItems(1);
|
||||
setBodyCount(50);
|
||||
setSpeed(100);
|
||||
|
||||
_clickIndex = 0;
|
||||
@ -31,6 +29,10 @@ Snake::Snake(const QString &name, const QString &viewTempalte, QObject *ptr):
|
||||
setScales({{0, 0.8},
|
||||
{0.4, 1.2},
|
||||
{1, 0.5}});
|
||||
|
||||
setLengthBetwinItemsMap({{0, 0.8},
|
||||
{0.4, 1.2},
|
||||
{1, 0.5}});
|
||||
}
|
||||
|
||||
Snake::~Snake( ){
|
||||
@ -81,53 +83,75 @@ void Snake::remove(int id) {
|
||||
}
|
||||
|
||||
void Snake::init() {
|
||||
generateBody();
|
||||
generateItems();
|
||||
}
|
||||
|
||||
void Snake::onTap() {
|
||||
setMovableVector(_vectors[_clickIndex++ % 2]);
|
||||
}
|
||||
|
||||
void Snake::generateBody() {
|
||||
|
||||
auto scaleIt = _scales.begin();
|
||||
float CRAWL::Snake::getValueFromMap(const QMap<float, float> &map,
|
||||
float position,
|
||||
float defaultValue) {
|
||||
auto it = map.cbegin();
|
||||
|
||||
float from = 0, fromKey = 0;
|
||||
float to = scaleIt.value(), toKey = scaleIt.key();
|
||||
float to = it.value(), toKey = it.key();
|
||||
|
||||
for(int i = 0; i < _bodyCount; ++i) {
|
||||
if (!_factory) {
|
||||
QuasarAppUtils::Params::log("Please use the registerBodyitem method"
|
||||
" before invoke parent constructor.",
|
||||
if (it != _scales.cend()) {
|
||||
while (position >= it.key() && it != _scales.cend()) {
|
||||
it++;
|
||||
|
||||
if (it != _scales.cend()) {
|
||||
from = to;
|
||||
to = it.value();
|
||||
fromKey = toKey;
|
||||
toKey = it.key();
|
||||
}
|
||||
}
|
||||
|
||||
float localPosition = (position - fromKey) / (fromKey - toKey);
|
||||
float valueDiff = from - to;
|
||||
|
||||
return from + localPosition * valueDiff;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
void Snake::generateItems() {
|
||||
|
||||
for(unsigned int i = 0; i < itemsCount(); ++i) {
|
||||
|
||||
SnakeItem* item = dynamic_cast<SnakeItem*>(factory());
|
||||
|
||||
if (!item) {
|
||||
QuasarAppUtils::Params::log("The snake item class should be child class"
|
||||
" of the SnakeItem class.",
|
||||
QuasarAppUtils::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
auto item = _factory();
|
||||
|
||||
float scale = 1;
|
||||
if (scaleIt != _scales.end()) {
|
||||
float position = static_cast<float>(i) / _bodyCount;
|
||||
while (position >= scaleIt.key() && scaleIt != _scales.end()) {
|
||||
scaleIt++;
|
||||
|
||||
if (scaleIt != _scales.end()) {
|
||||
from = to;
|
||||
to = scaleIt.value();
|
||||
fromKey = toKey;
|
||||
toKey = scaleIt.key();
|
||||
}
|
||||
}
|
||||
|
||||
scale = ((position - fromKey) * toKey / (to - from)) + from;
|
||||
}
|
||||
float scale = getValueFromMap(_scales,
|
||||
static_cast<float>(i) / itemsCount());
|
||||
float lengthBIt = getValueFromMap(_lengthBetwinItemsMap,
|
||||
static_cast<float>(i) / itemsCount());
|
||||
|
||||
item->setSize(item->size() * scale);
|
||||
item->setLengthBetwinItems(lengthBIt);
|
||||
|
||||
add(item);
|
||||
}
|
||||
}
|
||||
|
||||
const QMap<float, float> &Snake::lengthBetwinItemsMap() const {
|
||||
return _lengthBetwinItemsMap;
|
||||
}
|
||||
|
||||
void Snake::setLengthBetwinItemsMap(const QMap<float, float> &newLengthBetwinItemsMap) {
|
||||
_lengthBetwinItemsMap = newLengthBetwinItemsMap;
|
||||
}
|
||||
|
||||
float Snake::speed() const {
|
||||
return _speed;
|
||||
}
|
||||
@ -139,12 +163,8 @@ void Snake::setSpeed(float newSpeed) {
|
||||
_vectors[1] = QVector3D(asixPos,-asixPos,0); // right tap
|
||||
}
|
||||
|
||||
int Snake::bodyCount() const {
|
||||
return _bodyCount;
|
||||
}
|
||||
|
||||
void Snake::setBodyCount(int newBodyCount) {
|
||||
_bodyCount = newBodyCount;
|
||||
unsigned int Snake::itemsCount() const {
|
||||
return 50;
|
||||
}
|
||||
|
||||
const QMap<float, float> &Snake::scales() const {
|
||||
|
@ -5,11 +5,11 @@
|
||||
//# of this license document, but changing it is not allowed.
|
||||
//#
|
||||
|
||||
#ifndef SNAKE_H
|
||||
#define SNAKE_H
|
||||
#ifndef CRAWL_SNAKE_H
|
||||
#define CRAWL_SNAKE_H
|
||||
|
||||
#include "iplayer.h"
|
||||
#include "Extensions/claster.h"
|
||||
#include "Extensions/autogenerateclaster.h"
|
||||
|
||||
namespace CRAWL {
|
||||
|
||||
@ -18,7 +18,7 @@ class SnakeItem;
|
||||
/**
|
||||
* @brief The Snake class This class implement render mehod for snake object.
|
||||
*/
|
||||
class CRAWL_EXPORT Snake : public IPlayer, public Claster
|
||||
class CRAWL_EXPORT Snake : public IPlayer, public AutoGenerateClaster
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -48,16 +48,6 @@ public:
|
||||
*/
|
||||
void setLengthBetwinItems(float newLengthBetwinItems);
|
||||
|
||||
template<class Type>
|
||||
/**
|
||||
* @brief registerBodyitem This method register snake body item type. The body items will be generated in the generateBody method. The size of body companents calc from the Snake::scales property.
|
||||
*/
|
||||
void registerBodyitem() {
|
||||
_factory = [](){
|
||||
return new Type;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief scales This method return the map of the snake body scales.
|
||||
* The key of map are position of snake Body and the value are scale factor of current body item.
|
||||
@ -77,19 +67,6 @@ public:
|
||||
*/
|
||||
void setScales(const QMap<float, float> &newScales);
|
||||
|
||||
/**
|
||||
* @brief bodyCount This method return count of the body items of this snake.
|
||||
* @return count of body items of the snake.
|
||||
*/
|
||||
int bodyCount() const;
|
||||
|
||||
/**
|
||||
* @brief setBodyCount This method sets new size of snake.
|
||||
* @param newBodyCount this is new value of the body count.
|
||||
* @note Use This method in the constructor of your child snake class.
|
||||
*/
|
||||
void setBodyCount(int newBodyCount);
|
||||
|
||||
/**
|
||||
* @brief speed This method return current speed snake speed.
|
||||
* @return snake speed
|
||||
@ -102,17 +79,53 @@ public:
|
||||
*/
|
||||
void setSpeed(float newSpeed);
|
||||
|
||||
unsigned int itemsCount() const override;
|
||||
|
||||
/**
|
||||
* @brief lengthBetwinItemsMap This method return map with lengths betwin items.
|
||||
* The key of map are position of snake Body and the value are length betwin this current and parent items.
|
||||
* The default map of snake are:
|
||||
* ```
|
||||
* 0.0 - 0.8
|
||||
* 0.6 - 1.2
|
||||
* 1 - 0.5
|
||||
* ```
|
||||
* @return length betwin items map of snake body.
|
||||
*/
|
||||
const QMap<float, float> &lengthBetwinItemsMap() const;
|
||||
|
||||
/**
|
||||
* @brief setLengthBetwinItemsMap This method sets new valud of the length betwin items map.
|
||||
* @param newLengthBetwinItemsMap this is new value of the length betwin tems map.
|
||||
* @note for get more information see the lengthBetwinItemsMap method.
|
||||
*/
|
||||
void setLengthBetwinItemsMap(const QMap<float, float> &newLengthBetwinItemsMap);
|
||||
|
||||
/**
|
||||
* @brief getValueFromMap This method return near value from the map by position.
|
||||
* @param map This is map that contains list of the values.
|
||||
* @param position This requried position from map.
|
||||
* @param defaultValue This value will be returned when map are empty.
|
||||
* @return near value of the requried position.
|
||||
*
|
||||
* @note This function works as a gradient.
|
||||
*/
|
||||
float getValueFromMap(const QMap<float, float> &map,
|
||||
float position,
|
||||
float defaultValue = 1);
|
||||
|
||||
protected slots:
|
||||
void onTap() override;
|
||||
|
||||
|
||||
private:
|
||||
void generateBody();
|
||||
void generateItems() override;
|
||||
|
||||
|
||||
QMap<float, float> _scales;
|
||||
std::function<ClasterItem*()> _factory = nullptr;
|
||||
QMap<float, float> _lengthBetwinItemsMap;
|
||||
|
||||
float _lengthBetwinItems;
|
||||
int _bodyCount;
|
||||
const IWorldItem* _lastSnakeItem = nullptr;
|
||||
unsigned int _clickIndex;
|
||||
QVector3D* _vectors;
|
||||
@ -122,4 +135,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // SNAKE_H
|
||||
#endif // CRAWL_SNAKE_H
|
||||
|
@ -11,7 +11,8 @@
|
||||
namespace CRAWL {
|
||||
|
||||
|
||||
SnakeItem::SnakeItem(const QString itemName): SingleClasterWorldItem(itemName) {
|
||||
SnakeItem::SnakeItem(const QString &name, const QString &viewTempalte, QObject *ptr):
|
||||
SingleClasterWorldItem(name, viewTempalte, ptr) {
|
||||
setAngularVelocity(-1);
|
||||
|
||||
}
|
||||
@ -31,9 +32,9 @@ void SnakeItem::render(unsigned int tbfMsec) {
|
||||
if (auto claster = static_cast<Snake*>(parentClaster())) {
|
||||
float ratationLength = ratationVector.length();
|
||||
|
||||
if (ratationLength > claster->lengthBetwinItems() * 10) {
|
||||
if (ratationLength > lengthBetwinItems() * 10) {
|
||||
setposition(_prevObject->position());
|
||||
} else if (ratationLength > claster->lengthBetwinItems()) {
|
||||
} else if (ratationLength > lengthBetwinItems()) {
|
||||
setMovableVector(ratationVector.normalized() * claster->currentMovableVector().length());
|
||||
}
|
||||
}
|
||||
@ -44,4 +45,12 @@ void SnakeItem::render(unsigned int tbfMsec) {
|
||||
const IWorldItem * SnakeItem::prev() const {
|
||||
return _prevObject;
|
||||
}
|
||||
|
||||
float SnakeItem::lengthBetwinItems() const {
|
||||
return _lengthBetwinItems;
|
||||
}
|
||||
|
||||
void SnakeItem::setLengthBetwinItems(float newLengthBetwinItems) {
|
||||
_lengthBetwinItems = newLengthBetwinItems;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ class CRAWL_EXPORT SnakeItem: public SingleClasterWorldItem, public MovableObjec
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SnakeItem(const QString itemName = "SnakeItem");
|
||||
SnakeItem(const QString& name,
|
||||
const QString& viewTempalte = DEFAULT_VIEW_TEMPLATE,
|
||||
QObject *ptr = nullptr);
|
||||
|
||||
/**
|
||||
* @brief setPrev This method sets id of the previous snake item.
|
||||
@ -34,8 +36,22 @@ public:
|
||||
*/
|
||||
const IWorldItem * prev() const;
|
||||
|
||||
/**
|
||||
* @brief lengthBetwinItems This method return current length betwin current and parew item.
|
||||
* @return current length betwin current and parew item.
|
||||
* @note See also the setPrev method.
|
||||
*/
|
||||
float lengthBetwinItems() const;
|
||||
|
||||
/**
|
||||
* @brief setLengthBetwinItems This method sets new valeu of the length betwin current and parew item.
|
||||
* @param newLengthBetwinItems This is new value of the length betwin current and parew item.
|
||||
*/
|
||||
void setLengthBetwinItems(float newLengthBetwinItems);
|
||||
|
||||
private:
|
||||
const IWorldItem *_prevObject = nullptr;
|
||||
float _lengthBetwinItems = 1;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ import NotifyModule 1.0
|
||||
ApplicationWindow {
|
||||
id: mainWindow;
|
||||
visible: true;
|
||||
width: 640;
|
||||
height: 480;
|
||||
width: 1024;
|
||||
height: 720;
|
||||
title: qsTr("Crawl");
|
||||
|
||||
Metrix {id: metrix}
|
||||
@ -36,4 +36,6 @@ ApplicationWindow {
|
||||
NotificationServiceView {
|
||||
anchors.fill: parent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ Model {
|
||||
model.emissiveMap.length ||
|
||||
model.roughnessMap.length ||
|
||||
model.normalMap.length)
|
||||
property int tilies: 1
|
||||
|
||||
DefaultMaterial {
|
||||
id: defaultMaterial
|
||||
@ -25,10 +26,39 @@ Model {
|
||||
|
||||
PrincipledMaterial {
|
||||
id: objMaterial
|
||||
baseColorMap: Texture { source: (model)? model.baseColorMap: "" }
|
||||
emissiveMap: Texture { source: (model)? model.emissiveMap: "" }
|
||||
roughnessMap: Texture { source: (model)? model.roughnessMap: "" }
|
||||
normalMap: Texture { source: (model)? model.normalMap: "" }
|
||||
roughness : 1
|
||||
baseColorMap: Texture {
|
||||
source: (model)? model.baseColorMap: ""
|
||||
tilingModeHorizontal: (tilies > 1)? Texture.Repeat : Texture.ClampToEdge
|
||||
tilingModeVertical: (tilies > 1)? Texture.Repeat : Texture.ClampToEdge
|
||||
scaleU: tilies
|
||||
scaleV: tilies
|
||||
|
||||
}
|
||||
|
||||
emissiveMap: Texture {
|
||||
source: (model)? model.emissiveMap: ""
|
||||
tilingModeHorizontal: (tilies > 1)? Texture.Repeat : Texture.ClampToEdge
|
||||
tilingModeVertical: (tilies > 1)? Texture.Repeat : Texture.ClampToEdge
|
||||
scaleU: tilies
|
||||
scaleV: tilies
|
||||
}
|
||||
|
||||
roughnessMap: Texture {
|
||||
source: (model)? model.roughnessMap: ""
|
||||
tilingModeHorizontal: (tilies > 1)? Texture.Repeat : Texture.ClampToEdge
|
||||
tilingModeVertical: (tilies > 1)? Texture.Repeat : Texture.ClampToEdge
|
||||
scaleU: tilies
|
||||
scaleV: tilies
|
||||
}
|
||||
|
||||
normalMap: Texture {
|
||||
source: (model)? model.normalMap: ""
|
||||
tilingModeHorizontal: (tilies > 1)? Texture.Repeat : Texture.ClampToEdge
|
||||
tilingModeVertical: (tilies > 1)? Texture.Repeat : Texture.ClampToEdge
|
||||
scaleU: tilies
|
||||
scaleV: tilies
|
||||
}
|
||||
}
|
||||
|
||||
materials: [
|
||||
|
@ -75,8 +75,8 @@ Item {
|
||||
|
||||
standardButtons: Dialog.Save | Dialog.Cancel | Dialog.RestoreDefaults
|
||||
modal: false;
|
||||
width: 12 * metrix.controlPtMaterial
|
||||
height: 8 * metrix.controlPtMaterial;
|
||||
width: parent.width * 0.8
|
||||
height: parent.height * 0.8;
|
||||
|
||||
onAccepted: {
|
||||
settingsView.save();
|
||||
@ -109,8 +109,8 @@ Item {
|
||||
}
|
||||
|
||||
modal: false;
|
||||
width: 12 * metrix.controlPtMaterial
|
||||
height: 8 * metrix.controlPtMaterial;
|
||||
width: parent.width * 0.8
|
||||
height: parent.height * 0.8;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ View3D {
|
||||
|
||||
}
|
||||
|
||||
PointLight {
|
||||
position: camera.position
|
||||
DirectionalLight {
|
||||
position: Qt.vector3d(10000, 0, 10000);
|
||||
rotation: camera.rotation
|
||||
|
||||
brightness: 250
|
||||
brightness: 120
|
||||
}
|
||||
|
||||
environment: SceneEnvironment {
|
||||
|
39
src/Core/Extensions/autogenerateclaster.cpp
Normal file
39
src/Core/Extensions/autogenerateclaster.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
//#
|
||||
//# 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 "autogenerateclaster.h"
|
||||
namespace CRAWL {
|
||||
|
||||
AutoGenerateClaster::AutoGenerateClaster() {
|
||||
}
|
||||
|
||||
void AutoGenerateClaster::generateItems() {
|
||||
|
||||
for (unsigned int count = itemsCount(); count > 0; count--) {
|
||||
if (!_factory) {
|
||||
QuasarAppUtils::Params::log("Please use the registerItemType method"
|
||||
" before invoke parent constructor.",
|
||||
QuasarAppUtils::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
add(_factory());
|
||||
}
|
||||
}
|
||||
|
||||
ClasterItem *AutoGenerateClaster::factory() const {
|
||||
|
||||
if (!_factory) {
|
||||
QuasarAppUtils::Params::log("Please use the registerBodyitem method"
|
||||
" before invoke parent constructor.",
|
||||
QuasarAppUtils::Error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return _factory();
|
||||
}
|
||||
}
|
65
src/Core/Extensions/autogenerateclaster.h
Normal file
65
src/Core/Extensions/autogenerateclaster.h
Normal file
@ -0,0 +1,65 @@
|
||||
//#
|
||||
//# 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 AUTOGENERATECLASTER_H
|
||||
#define AUTOGENERATECLASTER_H
|
||||
|
||||
#include "claster.h"
|
||||
|
||||
namespace CRAWL {
|
||||
|
||||
/**
|
||||
* @brief The AutoGenerateClaster class hs support the registration default claster item class and factory method for the items.
|
||||
*/
|
||||
class CRAWL_EXPORT AutoGenerateClaster: public Claster
|
||||
{
|
||||
public:
|
||||
AutoGenerateClaster();
|
||||
|
||||
/**
|
||||
* @brief itemsCount This method sould be return count of the registered items on the claster object.
|
||||
* @return items count of the child objects.
|
||||
*/
|
||||
virtual unsigned int itemsCount() const = 0;
|
||||
|
||||
template<class Type>
|
||||
/**
|
||||
* @brief registerItemType This method register claster item type. Items will be generated in the generateItems method. The size of body companents calc from the itemsCount property.
|
||||
*/
|
||||
void registerItemType() {
|
||||
_factory = [](){
|
||||
return new Type;
|
||||
};
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief generateItems This method invoked after iit object on the world and generate list of the default claster items.
|
||||
* @note This method should be invked after initialized of this object.
|
||||
*/
|
||||
virtual void generateItems();
|
||||
|
||||
/**
|
||||
* @brief factory This method create new item of the claster. See the registerItemType for get more information.
|
||||
* @return return new item of the claster item. If the object not registered return nullptr.
|
||||
*/
|
||||
ClasterItem* factory() const;
|
||||
|
||||
/**
|
||||
* @brief isClasterItemRegistered
|
||||
* @return
|
||||
*/
|
||||
bool isClasterItemRegistered() const;
|
||||
|
||||
|
||||
private:
|
||||
std::function<ClasterItem*()> _factory = nullptr;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // AUTOGENERATECLASTER_H
|
@ -51,7 +51,7 @@ void MovableObject::setBreakingForce(float newBreakingForce) {
|
||||
|
||||
void MovableObject::renderRatation(GuiObject *object, unsigned int) {
|
||||
if (_currentMovableVector.length() > 0) {
|
||||
object->setRatation(QQuaternion::rotationTo({1.0f, 0.0, 0.0}, _currentMovableVector));
|
||||
object->setRatation(QQuaternion::rotationTo({1.0f, 0.0, 0.0}, _currentMovableVector) * staticRotation());
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,6 +87,14 @@ void MovableObject::renderPosition(GuiObject *object, unsigned int tbfMsec) {
|
||||
|
||||
}
|
||||
|
||||
const QQuaternion &MovableObject::staticRotation() const {
|
||||
return _staticRotation;
|
||||
}
|
||||
|
||||
void MovableObject::setStaticRotation(const QQuaternion &newStaticRotation) {
|
||||
_staticRotation = newStaticRotation;
|
||||
}
|
||||
|
||||
const QVector3D &MovableObject::currentMovableVector() const {
|
||||
return _currentMovableVector;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#define MOVABLEOBJECT_H
|
||||
|
||||
#include "Crawl/irender.h"
|
||||
#include <QQuaternion>
|
||||
#include <QVector3D>
|
||||
|
||||
namespace CRAWL {
|
||||
@ -85,6 +86,20 @@ public:
|
||||
*/
|
||||
const QVector3D ¤tMovableVector() const;
|
||||
|
||||
/**
|
||||
* @brief staticRotation This method retur nstatic rotation in quaternion. The static rotation rotate object to setted value independet then movable vector.
|
||||
* @return quterion of the static rotation
|
||||
*/
|
||||
const QQuaternion &staticRotation() const;
|
||||
|
||||
/**
|
||||
* @brief setStaticRotation This metho sets new value of the static rotation of this object.
|
||||
* @param newStaticRotation new value of the static rotation.
|
||||
* @note if you want use eilor angles then use the QQuaternion::fromEulerAngles method.
|
||||
* @note See the staticRotation method for get more information.
|
||||
*/
|
||||
void setStaticRotation(const QQuaternion &newStaticRotation);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@ -104,6 +119,7 @@ protected:
|
||||
private:
|
||||
QVector3D _movableVector;
|
||||
QVector3D _currentMovableVector;
|
||||
QQuaternion _staticRotation = QQuaternion::fromEulerAngles(0,0,0);
|
||||
|
||||
float _angularVelocity = 0;
|
||||
float _breakingForce = 0;
|
||||
|
@ -15,7 +15,7 @@ AbsLvlSnake::AbsLvlSnake(): Snake("Snake") {
|
||||
setMash("qrc:/mesh/meshes/SnakePatternHead.mesh");
|
||||
setSize({2,1,1});
|
||||
|
||||
registerBodyitem<AbsLvlSnakeItem>();
|
||||
registerItemType<AbsLvlSnakeItem>();
|
||||
}
|
||||
|
||||
void AbsLvlSnake::onIntersects(const IWorldItem *item) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "abslvlsnakeitem.h"
|
||||
|
||||
AbsLvlSnakeItem::AbsLvlSnakeItem() {
|
||||
AbsLvlSnakeItem::AbsLvlSnakeItem():CRAWL::SnakeItem("AbstractSnakeItem") {
|
||||
setMash("qrc:/mesh/meshes/SnakePatternBody.mesh");
|
||||
setColor("#20aa9a");
|
||||
setSize({1,1,1});
|
||||
|
25
src/CrawlTestLvl/private/background.cpp
Normal file
25
src/CrawlTestLvl/private/background.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
//#
|
||||
//# 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 "background.h"
|
||||
#include "plate.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
Background::Background(): CRAWL::GroundClaster("TestBackground") {
|
||||
registerItemType<Plate>();
|
||||
}
|
||||
|
||||
void Background::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item)
|
||||
}
|
||||
|
||||
unsigned int Background::itemsCount() const {
|
||||
return 3;
|
||||
}
|
||||
|
||||
}
|
33
src/CrawlTestLvl/private/background.h
Normal file
33
src/CrawlTestLvl/private/background.h
Normal file
@ -0,0 +1,33 @@
|
||||
//#
|
||||
//# 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 BACKGROUND_H
|
||||
#define BACKGROUND_H
|
||||
|
||||
#include "Crawl/groundclaster.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
/**
|
||||
* @brief The Background class
|
||||
*/
|
||||
class Background: public CRAWL::GroundClaster
|
||||
{
|
||||
public:
|
||||
Background();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
// AutoGenerateClaster interface
|
||||
public:
|
||||
unsigned int itemsCount() const override;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // BACKGROUND_H
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <QColor>
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
Box::Box(): IWorldItem("Box") {
|
||||
setMash("qrc:/mesh/meshes/cube.mesh");
|
||||
@ -28,3 +29,4 @@ Box::Box(): IWorldItem("Box") {
|
||||
void Box::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,9 @@
|
||||
#define BOX_H
|
||||
#include "Crawl/iworlditem.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
|
||||
class Box: public CRAWL::IWorldItem {
|
||||
|
||||
public:
|
||||
@ -18,5 +21,5 @@ public:
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // BOX_H
|
||||
|
@ -7,13 +7,22 @@
|
||||
|
||||
#include "plate.h"
|
||||
|
||||
Plate::Plate(): IGround("plate")
|
||||
namespace TestLvl {
|
||||
|
||||
|
||||
Plate::Plate(): CRAWL::GroundTile("TestPlate")
|
||||
{
|
||||
setMash("qrc:/mesh/meshes/cube.mesh");
|
||||
setSize({100,100,0});
|
||||
setMash("#Cube");
|
||||
setColor("#5c4f45");
|
||||
setSize({10,10,0.01});
|
||||
setZ(0);
|
||||
}
|
||||
|
||||
void Plate::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item)
|
||||
}
|
||||
|
||||
void Plate::render(unsigned int){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,25 @@
|
||||
|
||||
#ifndef PLATE_H
|
||||
#define PLATE_H
|
||||
#include "Crawl/iground.h"
|
||||
#include "Crawl/groundtile.h"
|
||||
namespace TestLvl {
|
||||
|
||||
class Plate: public CRAWL::IGround {
|
||||
|
||||
/**
|
||||
* @brief The Plate class
|
||||
*/
|
||||
class Plate: public CRAWL::GroundTile {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Plate();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
// IRender interface
|
||||
public:
|
||||
void render(unsigned int tbfMsec) override;
|
||||
};
|
||||
}
|
||||
#endif // PLATE_H
|
||||
|
@ -1,5 +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 "testcontrol.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
TestControl::TestControl() {
|
||||
|
||||
}
|
||||
@ -7,3 +16,4 @@ TestControl::TestControl() {
|
||||
QString TestControl::initQmlView() const {
|
||||
return "qrc:/qml/TestControl.qml";
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +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.
|
||||
//#
|
||||
|
||||
#ifndef TESTCONTROL_H
|
||||
#define TESTCONTROL_H
|
||||
#include "Crawl/defaultcontrol.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
/**
|
||||
* @brief The TestControl class This controll support custom camera-ratation functions.
|
||||
*/
|
||||
@ -17,4 +26,6 @@ signals:
|
||||
void yChanged(double);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TESTCONTROL_H
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "testsnake.h"
|
||||
#include <testsnakeitem.h>
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
TestSnake::TestSnake(): Snake("Snake") {
|
||||
setBreakingForce(50);
|
||||
setAngularVelocity(100);
|
||||
@ -15,7 +17,7 @@ TestSnake::TestSnake(): Snake("Snake") {
|
||||
setMash("qrc:/mesh/meshes/cube.mesh");
|
||||
setSize({2,1,1});
|
||||
|
||||
registerBodyitem<TestSnakeItem>();
|
||||
registerItemType<TestSnakeItem>();
|
||||
|
||||
}
|
||||
|
||||
@ -23,3 +25,8 @@ void TestSnake::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
|
||||
}
|
||||
|
||||
unsigned int TestSnake::itemsCount() const {
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "Crawl/snake.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
class TestSnake : public CRAWL::Snake {
|
||||
|
||||
Q_OBJECT
|
||||
@ -21,6 +23,12 @@ public:
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
|
||||
// AutoGenerateClaster interface
|
||||
public:
|
||||
unsigned int itemsCount() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TESTSNAKE_H
|
||||
|
@ -5,10 +5,10 @@
|
||||
//# of this license document, but changing it is not allowed.
|
||||
//#
|
||||
|
||||
|
||||
#include "testsnakeitem.h"
|
||||
namespace TestLvl {
|
||||
|
||||
TestSnakeItem::TestSnakeItem() {
|
||||
TestSnakeItem::TestSnakeItem():CRAWL::SnakeItem("TestSnakeItem") {
|
||||
setMash("qrc:/mesh/meshes/cube.mesh");
|
||||
setColor("#20aa9a");
|
||||
setSize({1,1,1});
|
||||
@ -19,3 +19,4 @@ void TestSnakeItem::onIntersects(const IWorldItem *item) {
|
||||
Q_UNUSED(item);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,9 @@
|
||||
|
||||
#include "Crawl/snakeitem.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
|
||||
class TestSnakeItem: public CRAWL::SnakeItem
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -22,4 +25,5 @@ protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TESTSNAKEITEM_H
|
||||
|
@ -5,6 +5,7 @@
|
||||
//# of this license document, but changing it is not allowed.
|
||||
//#
|
||||
|
||||
#include "background.h"
|
||||
#include "box.h"
|
||||
#include "plate.h"
|
||||
#include "testcontrol.h"
|
||||
@ -12,6 +13,9 @@
|
||||
#include <testsnake.h>
|
||||
#include "Crawl/iworlditem.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
|
||||
World::World() {
|
||||
setCameraReleativePosition({0,0,100});
|
||||
setCameraRatation(QQuaternion::fromEulerAngles({0,0,-90}));
|
||||
@ -19,7 +23,8 @@ World::World() {
|
||||
|
||||
CRAWL::WorldRule *World::initWorldRules() {
|
||||
return new CRAWL::WorldRule {
|
||||
{0, {{registerObject<Box>(), 1000}}}
|
||||
{0, {{registerObject<Box>(), 1000},
|
||||
{registerObject<Background>(), 1}}}
|
||||
};
|
||||
}
|
||||
|
||||
@ -75,3 +80,4 @@ void World::handleYViewChanged(double dy) {
|
||||
eilorRatation.setY(eilorRatation.y() + dy );
|
||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include "Crawl/iworld.h"
|
||||
|
||||
namespace TestLvl {
|
||||
|
||||
|
||||
class World : public CRAWL::IWorld {
|
||||
|
||||
// IWorld interface
|
||||
@ -34,4 +37,6 @@ private slots:
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif // WORLD_H
|
||||
|
@ -5,14 +5,14 @@
|
||||
//# of this license document, but changing it is not allowed.
|
||||
//#
|
||||
|
||||
#include "testlvl.h"
|
||||
#include "testlevel.h"
|
||||
#include "world.h"
|
||||
|
||||
TestLvl::TestLvl() {
|
||||
TestLevel::TestLevel() {
|
||||
|
||||
}
|
||||
|
||||
CRAWL::IWorld *TestLvl::world() {
|
||||
CRAWL::IWorld *TestLevel::world() {
|
||||
initTestLvlResources();
|
||||
return new World();
|
||||
return new TestLvl::World();
|
||||
}
|
@ -17,10 +17,10 @@ inline void initTestLvlResources() { Q_INIT_RESOURCE(Empty);
|
||||
/**
|
||||
* @brief The TestLvl class This is test lvlv wraper of the crawl
|
||||
*/
|
||||
class CRAWL_TEST_LEVEL_EXPORT TestLvl: public CRAWL::ILevel
|
||||
class CRAWL_TEST_LEVEL_EXPORT TestLevel: public CRAWL::ILevel
|
||||
{
|
||||
public:
|
||||
TestLvl();
|
||||
TestLevel();
|
||||
|
||||
// ILevel interface
|
||||
public:
|
29
src/JungleLvl/CMakeLists.txt
Normal file
29
src/JungleLvl/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
set(CURRENT_PROJECT "JungleLvl")
|
||||
|
||||
add_definitions(-DCRAWL_JUNGLE_LEVEL_LIBRARY)
|
||||
|
||||
file(GLOB SOURCE_CPP
|
||||
"*.cpp"
|
||||
"private/*.cpp"
|
||||
"*.qrc"
|
||||
"private/*.qrc"
|
||||
"CrawlJungleLvlAssests/*.qrc"
|
||||
)
|
||||
|
||||
set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/private")
|
||||
|
||||
add_library(${CURRENT_PROJECT} ${SOURCE_CPP})
|
||||
|
||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME}Core)
|
||||
|
||||
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
|
||||
target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
|
1
src/JungleLvl/CrawlJungleLvlAssests
Submodule
1
src/JungleLvl/CrawlJungleLvlAssests
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 858c0f949ac542d8a4c00b07bfb74ae5091d456c
|
14
src/JungleLvl/Models/Ground.qml
Normal file
14
src/JungleLvl/Models/Ground.qml
Normal file
@ -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.
|
||||
//#
|
||||
|
||||
import QtQuick 2.15
|
||||
import CrawlModule 1.0
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
GraphicItem {
|
||||
tilies: (model)? model.tiliesCount : 1
|
||||
}
|
19
src/JungleLvl/jungle.cpp
Normal file
19
src/JungleLvl/jungle.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
//#
|
||||
//# 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 "jungle.h"
|
||||
#include "world.h"
|
||||
|
||||
Jungle::Jungle() {
|
||||
|
||||
}
|
||||
|
||||
CRAWL::IWorld *Jungle::world() {
|
||||
initJungleLvlResources();
|
||||
return new JungleLvl::World();
|
||||
}
|
34
src/JungleLvl/jungle.h
Normal file
34
src/JungleLvl/jungle.h
Normal file
@ -0,0 +1,34 @@
|
||||
//#
|
||||
//# 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 JUNGLE_H
|
||||
#define JUNGLE_H
|
||||
|
||||
#include "jungle_global.h"
|
||||
#include <Crawl/ilevel.h>
|
||||
|
||||
inline void initJungleLvlResources() { Q_INIT_RESOURCE(jungleHDR);
|
||||
Q_INIT_RESOURCE(jungleMash);
|
||||
Q_INIT_RESOURCE(jungleIntro);
|
||||
Q_INIT_RESOURCE(jungleSound);
|
||||
Q_INIT_RESOURCE(jungle);}
|
||||
|
||||
/**
|
||||
* @brief The Jungle class This is main class of the jungle lvl
|
||||
*/
|
||||
class CRAWL_JUNGLE_LEVEL_EXPORT Jungle: public CRAWL::ILevel
|
||||
{
|
||||
public:
|
||||
Jungle();
|
||||
|
||||
// ILevel interface
|
||||
public:
|
||||
CRAWL::IWorld *world() override;
|
||||
};
|
||||
|
||||
#endif // JUNGLE_H
|
5
src/JungleLvl/jungle.qrc
Normal file
5
src/JungleLvl/jungle.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/qml">
|
||||
<file>Models/Ground.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
12
src/JungleLvl/jungle_global.h
Normal file
12
src/JungleLvl/jungle_global.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef Crawl_JUNGLE_LEVEL_GLOBAL_H
|
||||
#define Crawl_JUNGLE_LEVEL_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(CRAWL_JUNGLE_LEVEL_LIBRARY)
|
||||
# define CRAWL_JUNGLE_LEVEL_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define CRAWL_JUNGLE_LEVEL_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // Crawl_JUNGLE_LEVEL_GLOBAL_H
|
23
src/JungleLvl/private/ground.cpp
Normal file
23
src/JungleLvl/private/ground.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
//#
|
||||
//# 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 "ground.h"
|
||||
#include "groundplate.h"
|
||||
namespace JungleLvl {
|
||||
|
||||
Ground::Ground() : CRAWL::GroundClaster("JungelGroud") {
|
||||
registerItemType<GroundPlate>();
|
||||
}
|
||||
|
||||
void Ground::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
unsigned int Ground::itemsCount() const {
|
||||
return 3;
|
||||
}
|
||||
}
|
34
src/JungleLvl/private/ground.h
Normal file
34
src/JungleLvl/private/ground.h
Normal file
@ -0,0 +1,34 @@
|
||||
//#
|
||||
//# 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 GROUND_H
|
||||
#define GROUND_H
|
||||
|
||||
#include "Crawl/groundclaster.h"
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
|
||||
/**
|
||||
* @brief The Ground class This is main ground plate
|
||||
*/
|
||||
class Ground : public CRAWL::GroundClaster
|
||||
{
|
||||
public:
|
||||
Ground();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
// AutoGenerateClaster interface
|
||||
public:
|
||||
unsigned int itemsCount() const override;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // GROUND_H
|
39
src/JungleLvl/private/groundplate.cpp
Normal file
39
src/JungleLvl/private/groundplate.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
//#
|
||||
//# 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 "groundplate.h"
|
||||
namespace JungleLvl {
|
||||
|
||||
GroundPlate::GroundPlate(): CRAWL::GroundTile("JungleGroundTile",
|
||||
"qrc:/qml/Models/Ground.qml") {
|
||||
setMash("#Cube");
|
||||
setSize({6, 6, 0.01});
|
||||
setBaseColorMap("qrc:/mesh/meshes/Other/Terrain_Base.jpg");
|
||||
setNormalMap("qrc:/mesh/meshes/Other/Terrain_Normal.jpg");
|
||||
// setRoughnessMap("qrc:/mesh/meshes/Other/Roughness_without.jpg");
|
||||
// setEmissiveMap("qrc:/mesh/meshes/Other/Emission_without.jpg");
|
||||
setTiliesCount(6);
|
||||
|
||||
}
|
||||
|
||||
void GroundPlate::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
int GroundPlate::tiliesCount() const {
|
||||
return _tiliesCount;
|
||||
}
|
||||
|
||||
void GroundPlate::setTiliesCount(int newTiliesCount) {
|
||||
if (_tiliesCount == newTiliesCount)
|
||||
return;
|
||||
_tiliesCount = newTiliesCount;
|
||||
emit tiliesCountChanged();
|
||||
}
|
||||
|
||||
}
|
40
src/JungleLvl/private/groundplate.h
Normal file
40
src/JungleLvl/private/groundplate.h
Normal file
@ -0,0 +1,40 @@
|
||||
//#
|
||||
//# 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 GROUNDPLATE_H
|
||||
#define GROUNDPLATE_H
|
||||
|
||||
#include "Crawl/groundtile.h"
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
/**
|
||||
* @brief The GroundPlate class
|
||||
*/
|
||||
class GroundPlate: public CRAWL::GroundTile
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int tiliesCount READ tiliesCount WRITE setTiliesCount NOTIFY tiliesCountChanged)
|
||||
|
||||
public:
|
||||
GroundPlate();
|
||||
|
||||
int tiliesCount() const;
|
||||
void setTiliesCount(int newTiliesCount);
|
||||
|
||||
signals:
|
||||
void tiliesCountChanged();
|
||||
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
private:
|
||||
int _tiliesCount = 1;
|
||||
};
|
||||
}
|
||||
#endif // GROUNDPLATE_H
|
41
src/JungleLvl/private/snake.cpp
Normal file
41
src/JungleLvl/private/snake.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
//#
|
||||
//# 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 "snake.h"
|
||||
#include "snakeitem.h"
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
Snake::Snake(): CRAWL::Snake("JungleSnake") {
|
||||
setBreakingForce(50);
|
||||
setAngularVelocity(100);
|
||||
|
||||
registerItemType<JungleLvl::SnakeItem>();
|
||||
setMash("qrc:/mesh/meshes/Other/Snake_head.mesh");
|
||||
setBaseColorMap("qrc:/mesh/meshes/Other/Snake_Base.jpg");
|
||||
setSize({1,1,1});
|
||||
setStaticRotation(QQuaternion::fromEulerAngles(0,0,0));
|
||||
|
||||
|
||||
setScales({{0, 0.9},
|
||||
{0.6, 1},
|
||||
{1, 0.5}});
|
||||
|
||||
setLengthBetwinItemsMap({{0, 3},
|
||||
{0.001, 0.9},
|
||||
{0.6, 1},
|
||||
{1, 0.5}});
|
||||
}
|
||||
|
||||
void Snake::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
unsigned int Snake::itemsCount() const {
|
||||
return 50;
|
||||
}
|
||||
}
|
36
src/JungleLvl/private/snake.h
Normal file
36
src/JungleLvl/private/snake.h
Normal file
@ -0,0 +1,36 @@
|
||||
//#
|
||||
//# 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 <Crawl/snake.h>
|
||||
#include "jungle_global.h"
|
||||
|
||||
#ifndef SNAKE_H
|
||||
#define SNAKE_H
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
|
||||
/**
|
||||
* @brief The Snake class this is main player class of the jungle level
|
||||
*/
|
||||
class Snake: public CRAWL::Snake
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Snake();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *) override;
|
||||
unsigned int itemsCount() const override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif // SNAKE_H
|
26
src/JungleLvl/private/snakeitem.cpp
Normal file
26
src/JungleLvl/private/snakeitem.cpp
Normal file
@ -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.
|
||||
//#
|
||||
|
||||
#include "snakeitem.h"
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
SnakeItem::SnakeItem(): CRAWL::SnakeItem("JungleSnakeItem") {
|
||||
setMash("qrc:/mesh/meshes/Other/Snake_body.mesh");
|
||||
setBaseColorMap("qrc:/mesh/meshes/Other/Snake_Base.jpg");
|
||||
setSize({1.0,1.0,1.0});
|
||||
}
|
||||
|
||||
void SnakeItem::init() {
|
||||
|
||||
}
|
||||
|
||||
void SnakeItem::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
}
|
28
src/JungleLvl/private/snakeitem.h
Normal file
28
src/JungleLvl/private/snakeitem.h
Normal file
@ -0,0 +1,28 @@
|
||||
//#
|
||||
//# 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 "Crawl/snakeitem.h"
|
||||
|
||||
#ifndef JUNGLESNAKEITEM_H
|
||||
#define JUNGLESNAKEITEM_H
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
|
||||
class SnakeItem : public CRAWL::SnakeItem
|
||||
{
|
||||
public:
|
||||
SnakeItem();
|
||||
void init() override;
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // JUNGLESNAKEITEM_H
|
76
src/JungleLvl/private/world.cpp
Normal file
76
src/JungleLvl/private/world.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
//#
|
||||
//# 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 "ground.h"
|
||||
#include "snake.h"
|
||||
#include "world.h"
|
||||
#include "Crawl/iworlditem.h"
|
||||
|
||||
#include <Crawl/snake.h>
|
||||
namespace JungleLvl {
|
||||
|
||||
World::World() {
|
||||
setCameraReleativePosition({0,0,100});
|
||||
setCameraRatation(QQuaternion::fromEulerAngles({0,0,-90}));
|
||||
}
|
||||
|
||||
CRAWL::WorldRule *World::initWorldRules() {
|
||||
return new CRAWL::WorldRule {
|
||||
{0, {
|
||||
{registerObject<Ground>(), 1}}}
|
||||
};
|
||||
}
|
||||
|
||||
QString World::initHdrBackGround() const {
|
||||
return "qrc:/hdr/hdr/Jungle.hdr";
|
||||
}
|
||||
|
||||
QString World::description() const {
|
||||
return tr("Jungle world.");
|
||||
}
|
||||
|
||||
QString World::imagePreview() const {
|
||||
return "qrc:/hdr/hdr/jungleBanner.jpg";
|
||||
}
|
||||
|
||||
QString World::name() const {
|
||||
return tr("Jungle");
|
||||
}
|
||||
|
||||
int World::costToUnlock() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CRAWL::IControl *World::initUserInterface() const {
|
||||
return IWorld::initUserInterface();
|
||||
}
|
||||
|
||||
void World::initPlayerControl(CRAWL::IControl *control) {
|
||||
return IWorld::initPlayerControl(control);
|
||||
}
|
||||
|
||||
CRAWL::IPlayer *World::initPlayer() const {
|
||||
return new Snake();
|
||||
}
|
||||
|
||||
CRAWL::IAI *World::initBackGroundAI() const {
|
||||
return IWorld::initBackGroundAI();
|
||||
}
|
||||
|
||||
void World::handleXViewChanged(double dx) {
|
||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
||||
eilorRatation.setX(eilorRatation.x() + dx);
|
||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
||||
}
|
||||
|
||||
void World::handleYViewChanged(double dy) {
|
||||
auto eilorRatation = cameraRatation().toEulerAngles();
|
||||
eilorRatation.setY(eilorRatation.y() + dy );
|
||||
setCameraRatation(QQuaternion::fromEulerAngles(eilorRatation));
|
||||
}
|
||||
|
||||
}
|
41
src/JungleLvl/private/world.h
Normal file
41
src/JungleLvl/private/world.h
Normal file
@ -0,0 +1,41 @@
|
||||
//#
|
||||
//# 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 WORLD_H
|
||||
#define WORLD_H
|
||||
|
||||
#include "Crawl/iworld.h"
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
class World : public CRAWL::IWorld {
|
||||
|
||||
// IWorld interface
|
||||
public:
|
||||
|
||||
World();
|
||||
|
||||
CRAWL::WorldRule *initWorldRules() override;
|
||||
QString initHdrBackGround() const override;
|
||||
QString description() const override;
|
||||
QString imagePreview() const override;
|
||||
QString name() const override;
|
||||
int costToUnlock() const override;
|
||||
CRAWL::IControl *initUserInterface() const override;
|
||||
void initPlayerControl(CRAWL::IControl *control) override;
|
||||
CRAWL::IPlayer *initPlayer() const override;
|
||||
CRAWL::IAI *initBackGroundAI() const override;
|
||||
|
||||
private slots:
|
||||
void handleXViewChanged(double dx);
|
||||
void handleYViewChanged(double dy);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // WORLD_H
|
Loading…
x
Reference in New Issue
Block a user