mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-26 17:54:42 +00:00
ref #97 Chanhe name class ControlPos to layout, delete groupobjitem.
This commit is contained in:
parent
b2c1eda16c
commit
0643c0001e
@ -5,41 +5,41 @@
|
|||||||
//# of this license document, but changing it is not allowed.
|
//# of this license document, but changing it is not allowed.
|
||||||
//#
|
//#
|
||||||
|
|
||||||
#include "controlpos.h"
|
#include "layout.h"
|
||||||
#include "clasteritem.h"
|
#include "clasteritem.h"
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
namespace CRAWL {
|
namespace CRAWL {
|
||||||
|
|
||||||
ControlPos::ControlPos() {
|
Layout::Layout() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPos::add(ClasterItem *object) {
|
void Layout::add(ClasterItem *object) {
|
||||||
|
|
||||||
Claster::add(object);
|
Claster::add(object);
|
||||||
updatePosition();
|
updatePosition();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPos::remove(ClasterItem *object) {
|
void Layout::remove(ClasterItem *object) {
|
||||||
|
|
||||||
Claster::remove(object);
|
Claster::remove(object);
|
||||||
updatePosition();
|
updatePosition();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPos::changeLayout(const Refresh &fig) {
|
void Layout::changeLayout(const Refresh &fig) {
|
||||||
_shape = fig;
|
_shape = fig;
|
||||||
updatePosition();
|
updatePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPos::setDistance(int dist) {
|
void Layout::setDistance(int dist) {
|
||||||
_distance = dist;
|
_distance = dist;
|
||||||
updatePosition();
|
updatePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPos::updatePosition() {
|
void Layout::updatePosition() {
|
||||||
|
|
||||||
switch (_shape) {
|
switch (_shape) {
|
||||||
case CIRCLE:
|
case CIRCLE:
|
||||||
@ -60,7 +60,7 @@ void ControlPos::updatePosition() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPos::drawCircle() {
|
void Layout::drawCircle() {
|
||||||
|
|
||||||
if (objects().size() == 0) {
|
if (objects().size() == 0) {
|
||||||
QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error);
|
QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error);
|
||||||
@ -81,7 +81,7 @@ void ControlPos::drawCircle() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPos::drawSquare() {
|
void Layout::drawSquare() {
|
||||||
|
|
||||||
if (objects().size() == 0) {
|
if (objects().size() == 0) {
|
||||||
QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error);
|
QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error);
|
||||||
@ -105,7 +105,7 @@ void ControlPos::drawSquare() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlPos::drawLine() {
|
void Layout::drawLine() {
|
||||||
|
|
||||||
if (objects().size() == 0) {
|
if (objects().size() == 0) {
|
||||||
QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error);
|
QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."), QuasarAppUtils::Error);
|
@ -5,8 +5,8 @@
|
|||||||
//# of this license document, but changing it is not allowed.
|
//# of this license document, but changing it is not allowed.
|
||||||
//#
|
//#
|
||||||
|
|
||||||
#ifndef CONTROLPOS_H
|
#ifndef LAYOUT_H
|
||||||
#define CONTROLPOS_H
|
#define LAYOUT_H
|
||||||
|
|
||||||
#include <Crawl/groupobject.h>
|
#include <Crawl/groupobject.h>
|
||||||
|
|
||||||
@ -25,9 +25,9 @@ enum Refresh {
|
|||||||
/**
|
/**
|
||||||
* @brief The ControlPos class The class that control position of group objects.
|
* @brief The ControlPos class The class that control position of group objects.
|
||||||
*/
|
*/
|
||||||
class ControlPos: public GroupObject {
|
class Layout: public GroupObject {
|
||||||
public:
|
public:
|
||||||
ControlPos();
|
Layout();
|
||||||
|
|
||||||
// Claster interface
|
// Claster interface
|
||||||
public:
|
public:
|
||||||
@ -75,4 +75,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // CONTROLPOS_H
|
#endif // LAYOUT_H
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace TestLvl {
|
namespace TestLvl {
|
||||||
|
|
||||||
Box::Box(): IWorldItem("Box") {
|
Box::Box(): ClasterItem("Box") {
|
||||||
setMash("qrc:/mesh/meshes/cube.mesh");
|
setMash("qrc:/mesh/meshes/cube.mesh");
|
||||||
setSize({2,2,2});
|
setSize({2,2,2});
|
||||||
setColor(QColor::fromRgb(rand()).name());
|
setColor(QColor::fromRgb(rand()).name());
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
|
|
||||||
#ifndef BOX_H
|
#ifndef BOX_H
|
||||||
#define BOX_H
|
#define BOX_H
|
||||||
#include "Crawl/iworlditem.h"
|
#include "Crawl/clasteritem.h"
|
||||||
|
|
||||||
namespace TestLvl {
|
namespace TestLvl {
|
||||||
|
|
||||||
|
|
||||||
class Box: public CRAWL::IWorldItem {
|
class Box: public CRAWL::ClasterItem {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Box();
|
Box();
|
||||||
|
@ -7,20 +7,34 @@
|
|||||||
|
|
||||||
#include "box.h"
|
#include "box.h"
|
||||||
#include "groupobjbox.h"
|
#include "groupobjbox.h"
|
||||||
#include "groupobjboxitem.h"
|
|
||||||
|
|
||||||
namespace TestLvl {
|
namespace TestLvl {
|
||||||
|
|
||||||
GroupObjBox::GroupObjBox(): CRAWL::IWorldItem("GroupObjBox") {
|
GroupObjBox::GroupObjBox(): CRAWL::ClasterItem("GroupObjBox") {
|
||||||
|
|
||||||
setDistance(2);
|
setDistance(2);
|
||||||
changeLayout(CRAWL::Refresh::CIRCLE);
|
changeLayout(CRAWL::Refresh::CIRCLE);
|
||||||
|
|
||||||
add(new GroupObjboxItem);
|
add(new Box);
|
||||||
add(new GroupObjboxItem);
|
add(new Box);
|
||||||
add(new GroupObjboxItem);
|
add(new Box);
|
||||||
add(new GroupObjboxItem);
|
add(new Box);
|
||||||
add(new GroupObjboxItem);
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
add(new Box);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,4 +49,6 @@ void GroupObjBox::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
#ifndef GROUPOBJBOX_H
|
#ifndef GROUPOBJBOX_H
|
||||||
#define GROUPOBJBOX_H
|
#define GROUPOBJBOX_H
|
||||||
|
|
||||||
#include "Crawl/controlpos.h"
|
#include "Crawl/layout.h"
|
||||||
#include "Crawl/iworlditem.h"
|
#include "Crawl/clasteritem.h"
|
||||||
|
|
||||||
namespace TestLvl {
|
namespace TestLvl {
|
||||||
|
|
||||||
class GroupObjBox: public CRAWL::ControlPos, public CRAWL::IWorldItem {
|
class GroupObjBox: public CRAWL::Layout, public CRAWL::ClasterItem {
|
||||||
public:
|
public:
|
||||||
GroupObjBox();
|
GroupObjBox();
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
void render(unsigned int tbfMsec);
|
void render(unsigned int tbfMsec);
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +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 "groupobjboxitem.h"
|
|
||||||
|
|
||||||
namespace TestLvl {
|
|
||||||
|
|
||||||
GroupObjboxItem::GroupObjboxItem(): CRAWL::ClasterItem("GroupObjboxItem") {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupObjboxItem::init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupObjboxItem::render(unsigned int tbfMsec) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +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 GROUPOBJBOXITEM_H
|
|
||||||
#define GROUPOBJBOXITEM_H
|
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "Crawl/clasteritem.h"
|
|
||||||
|
|
||||||
namespace TestLvl {
|
|
||||||
|
|
||||||
class GroupObjboxItem: public CRAWL::ClasterItem, public Box {
|
|
||||||
|
|
||||||
public:
|
|
||||||
GroupObjboxItem();
|
|
||||||
|
|
||||||
// IRender interface
|
|
||||||
public:
|
|
||||||
void init();
|
|
||||||
void render(unsigned int tbfMsec);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // GROUPOBJBOXITEM_H
|
|
@ -32,7 +32,7 @@ CRAWL::WorldRule *World::initWorldRules() {
|
|||||||
using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>;
|
using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>;
|
||||||
|
|
||||||
return new CRAWL::WorldRule {
|
return new CRAWL::WorldRule {
|
||||||
{0, {{registerObject<Box>(), 1000},
|
{0, {{registerObject<Box>(), 1},
|
||||||
{registerObject<CRAWL::Fire>(), 10},
|
{registerObject<CRAWL::Fire>(), 10},
|
||||||
{registerObject<CRAWL::DynamicWint>(), 1},
|
{registerObject<CRAWL::DynamicWint>(), 1},
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ CRAWL::WorldRule *World::initWorldRules() {
|
|||||||
{registerObject<Day>(), 1}}},
|
{registerObject<Day>(), 1}}},
|
||||||
{500,
|
{500,
|
||||||
{
|
{
|
||||||
{registerObject<GroupObjBox>(),20}
|
{registerObject<GroupObjBox>(),1}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user