mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-05 14:09:47 +00:00
added first snake model
This commit is contained in:
parent
f5c59e20ac
commit
66c3fd78d1
src
Core
CrawlAbstractLvl/private
CrawlTestLvl/private
JungleLvl
@ -22,7 +22,6 @@ 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.",
|
||||
@ -33,11 +32,13 @@ void GroundClaster::render(unsigned int ) {
|
||||
auto object = _itemsOrder.at(_index % _itemsOrder.size());
|
||||
|
||||
if (playerObject->position().x() - object->position().x() >
|
||||
camera.z()) {
|
||||
newObjectDistance()) {
|
||||
|
||||
auto prewObject = _itemsOrder.at((_index - 1) % _itemsOrder.size());
|
||||
object->setX(prewObject->position().x() + newObjectDistance());
|
||||
object->setY(playerObject->position().y());
|
||||
|
||||
object->setposition({prewObject->position().x() + newObjectDistance(),
|
||||
playerObject->position().y(),
|
||||
object->position().z() - static_cast<float>(0.0001)});
|
||||
|
||||
_index++;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -17,6 +17,7 @@ Model {
|
||||
model.emissiveMap.length ||
|
||||
model.roughnessMap.length ||
|
||||
model.normalMap.length)
|
||||
property int tilies: 1
|
||||
|
||||
DefaultMaterial {
|
||||
id: defaultMaterial
|
||||
@ -25,10 +26,38 @@ 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: "" }
|
||||
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: [
|
||||
|
@ -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});
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "testsnakeitem.h"
|
||||
namespace TestLvl {
|
||||
|
||||
TestSnakeItem::TestSnakeItem() {
|
||||
TestSnakeItem::TestSnakeItem():CRAWL::SnakeItem("TestSnakeItem") {
|
||||
setMash("qrc:/mesh/meshes/cube.mesh");
|
||||
setColor("#20aa9a");
|
||||
setSize({1,1,1});
|
||||
|
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
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/qml"/>
|
||||
<qresource prefix="/qml">
|
||||
<file>Models/Ground.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -9,11 +9,13 @@
|
||||
#include "groundplate.h"
|
||||
namespace JungleLvl {
|
||||
|
||||
GroundPlate::GroundPlate(): CRAWL::GroundTile("JungleGroundTile") {
|
||||
GroundPlate::GroundPlate(): CRAWL::GroundTile("JungleGroundTile",
|
||||
"qrc:/qml/Models/Ground.qml") {
|
||||
setMash("#Cube");
|
||||
setSize({10, 10, 0.01});
|
||||
setSize({6, 6, 0.01});
|
||||
setBaseColorMap("qrc:/mesh/meshes/Other/Terrain_Base.jpg");
|
||||
setNormalMap("qrc:/mesh/meshes/Other/Terrain_Normal.jpg");
|
||||
setTiliesCount(6);
|
||||
|
||||
}
|
||||
|
||||
@ -21,4 +23,15 @@ void GroundPlate::onIntersects(const IWorldItem *) {
|
||||
|
||||
}
|
||||
|
||||
int GroundPlate::tiliesCount() const {
|
||||
return _tiliesCount;
|
||||
}
|
||||
|
||||
void GroundPlate::setTiliesCount(int newTiliesCount) {
|
||||
if (_tiliesCount == newTiliesCount)
|
||||
return;
|
||||
_tiliesCount = newTiliesCount;
|
||||
emit tiliesCountChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,12 +19,22 @@ namespace JungleLvl {
|
||||
class GroundPlate: public CRAWL::GroundTile
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int tiliesCount READ tiliesCount WRITE setTiliesCount NOTIFY tiliesCountChanged)
|
||||
|
||||
public:
|
||||
GroundPlate();
|
||||
|
||||
// IWorldItem interface
|
||||
int tiliesCount() const;
|
||||
void setTiliesCount(int newTiliesCount);
|
||||
|
||||
signals:
|
||||
void tiliesCountChanged();
|
||||
|
||||
protected:
|
||||
void onIntersects(const IWorldItem *item) override;
|
||||
|
||||
private:
|
||||
int _tiliesCount = 1;
|
||||
};
|
||||
}
|
||||
#endif // GROUNDPLATE_H
|
||||
|
@ -6,10 +6,15 @@
|
||||
//#
|
||||
|
||||
#include "snake.h"
|
||||
#include "snakeitem.h"
|
||||
|
||||
namespace JungleLvl {
|
||||
|
||||
Snake::Snake(): CRAWL::Snake("JungleSnake") {
|
||||
registerItemType<JungleLvl::SnakeItem>();
|
||||
setMash("qrc:/mesh/meshes/Other/Snake_head.mesh");
|
||||
setBaseColorMap("qrc:/mesh/meshes/Other/Snake_Base.jpg");
|
||||
setSize({1,1,1});
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace JungleLvl {
|
||||
/**
|
||||
* @brief The Snake class this is main player class of the jungle level
|
||||
*/
|
||||
class CRAWL_JUNGLE_LEVEL_EXPORT Snake: public CRAWL::Snake
|
||||
class Snake: public CRAWL::Snake
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
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,1,1});
|
||||
}
|
||||
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user