mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-28 10:44:42 +00:00
ref #74 "added ground to jungle "
This commit is contained in:
parent
dd7158cc23
commit
f5c59e20ac
@ -23,6 +23,13 @@ GroundClaster::GroundClaster(const QString &name,
|
||||
void GroundClaster::render(unsigned int ) {
|
||||
const IWorldItem *playerObject = getPlayer();
|
||||
QVector3D camera = world()->cameraReleativePosition();
|
||||
|
||||
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() >
|
||||
|
@ -17,6 +17,8 @@ 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 {
|
||||
|
||||
|
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
|
@ -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;
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace TestLvl {
|
||||
|
||||
|
||||
Plate::Plate(): CRAWL::ClasterItem("TestPlate")
|
||||
Plate::Plate(): CRAWL::GroundTile("TestPlate")
|
||||
{
|
||||
setMash("#Cube");
|
||||
setColor("#5c4f45");
|
||||
|
@ -7,14 +7,14 @@
|
||||
|
||||
#ifndef PLATE_H
|
||||
#define PLATE_H
|
||||
#include "Crawl/clasteritem.h"
|
||||
#include "Crawl/groundtile.h"
|
||||
namespace TestLvl {
|
||||
|
||||
|
||||
/**
|
||||
* @brief The Plate class
|
||||
*/
|
||||
class Plate: public CRAWL::ClasterItem {
|
||||
class Plate: public CRAWL::GroundTile {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Plate();
|
||||
|
@ -6,12 +6,18 @@
|
||||
//#
|
||||
|
||||
#include "ground.h"
|
||||
#include "groundplate.h"
|
||||
namespace JungleLvl {
|
||||
|
||||
Ground::Ground() : CRAWL::GroundClaster("JungelGroud") {
|
||||
setMash("#Rectangle");
|
||||
setSize({100,100, 100});
|
||||
registerItemType<GroundPlate>();
|
||||
}
|
||||
|
||||
void Ground::onIntersects(const IWorldItem *item) {
|
||||
void Ground::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
unsigned int Ground::itemsCount() const {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include "Crawl/groundclaster.h"
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
|
||||
/**
|
||||
* @brief The Ground class This is main ground plate
|
||||
*/
|
||||
@ -21,6 +24,11 @@ public:
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
// AutoGenerateClaster interface
|
||||
public:
|
||||
unsigned int itemsCount() const override;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // GROUND_H
|
||||
|
24
src/JungleLvl/private/groundplate.cpp
Normal file
24
src/JungleLvl/private/groundplate.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
//#
|
||||
//# 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") {
|
||||
setMash("#Cube");
|
||||
setSize({10, 10, 0.01});
|
||||
setBaseColorMap("qrc:/mesh/meshes/Other/Terrain_Base.jpg");
|
||||
setNormalMap("qrc:/mesh/meshes/Other/Terrain_Normal.jpg");
|
||||
|
||||
}
|
||||
|
||||
void GroundPlate::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
}
|
30
src/JungleLvl/private/groundplate.h
Normal file
30
src/JungleLvl/private/groundplate.h
Normal file
@ -0,0 +1,30 @@
|
||||
//#
|
||||
//# 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
|
||||
public:
|
||||
GroundPlate();
|
||||
|
||||
// IWorldItem interface
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
};
|
||||
}
|
||||
#endif // GROUNDPLATE_H
|
@ -5,6 +5,7 @@
|
||||
//# of this license document, but changing it is not allowed.
|
||||
//#
|
||||
|
||||
#include "ground.h"
|
||||
#include "snake.h"
|
||||
#include "world.h"
|
||||
#include "Crawl/iworlditem.h"
|
||||
@ -19,7 +20,8 @@ World::World() {
|
||||
|
||||
CRAWL::WorldRule *World::initWorldRules() {
|
||||
return new CRAWL::WorldRule {
|
||||
{}
|
||||
{0, {
|
||||
{registerObject<Ground>(), 1}}}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user