Bars::Bars()
{
hp_amount = 1400;
hunger_amount = 1400;
thirst_amount = 1400;
QVector<QPointF> hp_points,hunger_points,thirst_points;
hp_points <<
QPointF(1,
0) <<
QPointF(2,
0) <<
QPointF(2.33,
1) <<
QPointF(2.66,
2) <<
QPointF(3,
3) <<
QPointF(3,
4) <<
QPointF(2.66,
5) <<
QPointF(2.33,
6) <<
QPointF(2,
7) <<
QPointF(1,
7) <<
QPointF(0.66,
6) <<
QPointF(0.33,
5) <<
QPointF(0,
4) <<
QPointF(0,
3) <<
QPointF(0.33,
2) <<
QPointF(0.66,
1);
hunger_points <<
QPointF(-1,
0) <<
QPointF(0,
0) <<
QPointF(-0.33,
1) <<
QPointF(-0.66,
2) <<
QPoint(-1,
3) <<
QPoint(-1,
4) <<
QPointF(-0.66,
5) <<
QPointF(-0.33,
6) <<
QPointF(0,
7) <<
QPoint(-1,
7) <<
QPointF(-1.33,
6) <<
QPointF(-1.66,
5) <<
QPoint(-2,
4) <<
QPointF(-2,
3) <<
QPointF(-1.66,
2) <<
QPointF(-1.33,
1);
thirst_points <<
QPoint(3,
0) <<
QPoint(4,
0) <<
QPointF(4.33,
1) <<
QPointF(4.66,
2) <<
QPoint(5,
3) <<
QPoint(5,
4) <<
QPointF(4.66,
5) <<
QPointF(4.33,
6) <<
QPointF(4,
7) <<
QPointF(3,
7) <<
QPointF(3.33,
6) <<
QPointF(3.66,
5) <<
QPointF(4,
4) <<
QPointF(4,
3) <<
QPointF(3.66,
2) <<
QPointF(3.33,
1);
line.setPoints(hunger_points[0], hp_points[0]);
dist.setPoints(hp_points[0], hp_points[1]);
size = game->getViewHeight()/57;
for(int i=0;i<hp_points.size();i++){
hp_points[i] *= size;
hunger_points[i] *= size;
thirst_points[i] *= size;
}
hp_height = hp->boundingRect().height();
hunger_height = hunger->boundingRect().height();
thirst_height = thirst->boundingRect().height();
setPosition();
hp
->setBrush
(QBrush("#f44047"));
hunger
->setBrush
(QBrush("#efbc12"));
thirst
->setBrush
(QBrush("#00a8f3"));
//hp->setPen(Qt::NoPen);
//hunger->setPen(Qt::NoPen);
//thirst->setPen(Qt::NoPen);
hp->setZValue(16);
}
void Bars::setPosition()
{
game->scene->removeItem(hp);
game->scene->addItem(hp);
game->scene->removeItem(hunger);
game->scene->addItem(hunger);
game->scene->removeItem(thirst);
game->scene->addItem(thirst);
hp->setPos(game->hotbarSlots->slot[8]->x()+game->hotbarSlots->slot[8]->boundingRect().width()+(game->getViewWidth()*0.175)/2-dist.length()/2, game->hotbarSlots->slot[8]->y()+game->hotbarSlots->slot[8]->boundingRect().width()-hp_height);
hunger->setPos(hp->x()-line.length()/2,game->hotbarSlots->slot[8]->y()+game->hotbarSlots->slot[8]->boundingRect().width()-hunger_height);
thirst->setPos(hp->x()+line.length()/2,game->hotbarSlots->slot[8]->y()+game->hotbarSlots->slot[8]->boundingRect().width()-thirst_height);
}
Bars::Bars()
{
hp_amount = 1400;
hunger_amount = 1400;
thirst_amount = 1400;
QVector<QPointF> hp_points,hunger_points,thirst_points;
hp_points << QPointF(1,0) << QPointF(2,0) << QPointF(2.33,1) << QPointF(2.66,2) << QPointF(3,3) << QPointF(3,4) << QPointF(2.66,5) << QPointF(2.33,6) << QPointF(2,7) << QPointF(1,7) << QPointF(0.66,6) << QPointF(0.33,5) << QPointF(0,4) << QPointF(0,3) << QPointF(0.33,2) << QPointF(0.66,1);
hunger_points << QPointF(-1,0) << QPointF(0,0) << QPointF(-0.33,1) << QPointF(-0.66,2) << QPoint(-1,3) << QPoint(-1,4) << QPointF(-0.66,5) << QPointF(-0.33,6) << QPointF(0,7) << QPoint(-1,7) << QPointF(-1.33,6) << QPointF(-1.66,5) << QPoint(-2,4) << QPointF(-2,3) << QPointF(-1.66,2) << QPointF(-1.33,1);
thirst_points << QPoint(3,0) << QPoint(4,0) << QPointF(4.33,1) << QPointF(4.66,2) << QPoint(5,3) << QPoint(5,4) << QPointF(4.66,5) << QPointF(4.33,6) << QPointF(4,7) << QPointF(3,7) << QPointF(3.33,6) << QPointF(3.66,5) << QPointF(4,4) << QPointF(4,3) << QPointF(3.66,2) << QPointF(3.33,1);
line.setPoints(hunger_points[0], hp_points[0]);
dist.setPoints(hp_points[0], hp_points[1]);
size = game->getViewHeight()/57;
for(int i=0;i<hp_points.size();i++){
hp_points[i] *= size;
hunger_points[i] *= size;
thirst_points[i] *= size;
}
hp = new QGraphicsPolygonItem(QPolygonF(hp_points));
hunger = new QGraphicsPolygonItem(QPolygonF(hunger_points));
thirst = new QGraphicsPolygonItem(QPolygonF(thirst_points));
hp_height = hp->boundingRect().height();
hunger_height = hunger->boundingRect().height();
thirst_height = thirst->boundingRect().height();
setPosition();
hp->setBrush(QBrush("#f44047"));
hunger->setBrush(QBrush("#efbc12"));
thirst->setBrush(QBrush("#00a8f3"));
//hp->setPen(Qt::NoPen);
//hunger->setPen(Qt::NoPen);
//thirst->setPen(Qt::NoPen);
hp->setZValue(16);
}
void Bars::setPosition()
{
game->scene->removeItem(hp);
game->scene->addItem(hp);
game->scene->removeItem(hunger);
game->scene->addItem(hunger);
game->scene->removeItem(thirst);
game->scene->addItem(thirst);
hp->setPos(game->hotbarSlots->slot[8]->x()+game->hotbarSlots->slot[8]->boundingRect().width()+(game->getViewWidth()*0.175)/2-dist.length()/2, game->hotbarSlots->slot[8]->y()+game->hotbarSlots->slot[8]->boundingRect().width()-hp_height);
hunger->setPos(hp->x()-line.length()/2,game->hotbarSlots->slot[8]->y()+game->hotbarSlots->slot[8]->boundingRect().width()-hunger_height);
thirst->setPos(hp->x()+line.length()/2,game->hotbarSlots->slot[8]->y()+game->hotbarSlots->slot[8]->boundingRect().width()-thirst_height);
}
To copy to clipboard, switch view to plain text mode
Bookmarks