ref #110 Bugfix in draw square and line.

This commit is contained in:
IgorekLoschinin 2021-09-24 23:44:09 +03:00
parent d8b5059c7b
commit db8b9b3f21
3 changed files with 13 additions and 7 deletions

View File

@ -89,6 +89,7 @@ void Layout::drawSquare() {
}
int height = qFloor(qSqrt(objects().size()));
int width = qFloor(objects().size() / height);
int indObject = 0;
for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) {
@ -96,9 +97,8 @@ void Layout::drawSquare() {
float x = indObject % height;
float y = qCeil(indObject / height);
GroupObject::updatePosition(*idObj, {x + _distance,
y + _distance,
0});
GroupObject::updatePosition(*idObj, {(x * _distance) - (height * _distance / 2),
(y * _distance) - (width * _distance / 2), 0});
indObject++;
}
@ -113,8 +113,10 @@ void Layout::drawLine() {
}
float xObject = 0;
for (ClasterItem* object: objects()) {
GroupObject::updatePosition(object->guiId(), {xObject + _distance, 0, 0});
float height = objects().size() * _distance;
for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) {
GroupObject::updatePosition(*idObj, {(xObject * _distance) - (height/2 * _distance), 0, 0});
xObject++;
}

View File

@ -38,7 +38,7 @@ CRAWL::WorldRule *AbsLvlWorld::initWorldRules() {
}
},
{300,
{210,
{
{registerObject<GroupObstacleRed>(), 1}, {registerObject<CRAWL::DefaultLight>(), 1}
}

View File

@ -12,7 +12,11 @@ namespace AbstractLvl {
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);
for(int i(0); i < 4; i++) {