mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-27 02:04:41 +00:00
ref #110 Bugfix in draw square and line.
This commit is contained in:
parent
d8b5059c7b
commit
db8b9b3f21
@ -89,6 +89,7 @@ void Layout::drawSquare() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int height = qFloor(qSqrt(objects().size()));
|
int height = qFloor(qSqrt(objects().size()));
|
||||||
|
int width = qFloor(objects().size() / height);
|
||||||
|
|
||||||
int indObject = 0;
|
int indObject = 0;
|
||||||
for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) {
|
for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) {
|
||||||
@ -96,9 +97,8 @@ void Layout::drawSquare() {
|
|||||||
float x = indObject % height;
|
float x = indObject % height;
|
||||||
float y = qCeil(indObject / height);
|
float y = qCeil(indObject / height);
|
||||||
|
|
||||||
GroupObject::updatePosition(*idObj, {x + _distance,
|
GroupObject::updatePosition(*idObj, {(x * _distance) - (height * _distance / 2),
|
||||||
y + _distance,
|
(y * _distance) - (width * _distance / 2), 0});
|
||||||
0});
|
|
||||||
indObject++;
|
indObject++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -113,8 +113,10 @@ void Layout::drawLine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float xObject = 0;
|
float xObject = 0;
|
||||||
for (ClasterItem* object: objects()) {
|
float height = objects().size() * _distance;
|
||||||
GroupObject::updatePosition(object->guiId(), {xObject + _distance, 0, 0});
|
for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) {
|
||||||
|
|
||||||
|
GroupObject::updatePosition(*idObj, {(xObject * _distance) - (height/2 * _distance), 0, 0});
|
||||||
|
|
||||||
xObject++;
|
xObject++;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ CRAWL::WorldRule *AbsLvlWorld::initWorldRules() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{300,
|
{210,
|
||||||
{
|
{
|
||||||
{registerObject<GroupObstacleRed>(), 1}, {registerObject<CRAWL::DefaultLight>(), 1}
|
{registerObject<GroupObstacleRed>(), 1}, {registerObject<CRAWL::DefaultLight>(), 1}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,11 @@ namespace AbstractLvl {
|
|||||||
|
|
||||||
GroupObstacleRed::GroupObstacleRed(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
GroupObstacleRed::GroupObstacleRed(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
|
||||||
|
|
||||||
setDistance(20);
|
QQuaternion rotation =
|
||||||
|
QQuaternion::fromAxisAndAngle(QVector3D(0,1,0), 90);
|
||||||
|
|
||||||
|
setDistance(7);
|
||||||
|
setRotation(rotation);
|
||||||
changeLayout(CRAWL::LayoutType::LINE);
|
changeLayout(CRAWL::LayoutType::LINE);
|
||||||
|
|
||||||
for(int i(0); i < 4; i++) {
|
for(int i(0); i < 4; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user