Skip to content

Commit

Permalink
misc: Better render positions
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed Apr 22, 2019
1 parent 235fc27 commit 3f793fd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Drakhtar/GameObjects/Battalion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,24 @@ void Battalion::moveToBox(Box* box) {
Unit::moveToBox(box);

const auto rect = box_->getRect();

sizeText_->setPosition(
Vector2D<int>(rect.x + rect.h / 6, rect.y - rect.h / 3));
}

void Battalion::render() const {
SDL_Rect aux = getRect();
if (battalionSize_ > 3) {
aux.x -= box_->getRect().w / 2;
aux.y -= box_->getRect().h / 3;
auto aux = getRect();
aux.x += getTexture()->getFlip() == SDL_FLIP_HORIZONTAL ? -size_.getX() / 4
: size_.getX() / 4;
aux.y -= size_.getY() / 5;
texture_->renderFrame(aux, texture_->getAnimation()[texture_->getFrame()]);
}
Unit::render();
if (battalionSize_ > 7) {
aux.y += box_->getRect().h / 2;
auto aux = getRect();
aux.x += getTexture()->getFlip() == SDL_FLIP_HORIZONTAL ? -size_.getX() / 4
: size_.getX() / 4;
aux.y += size_.getY() / 5;
texture_->renderFrame(aux, texture_->getAnimation()[texture_->getFrame()]);
}
}

0 comments on commit 3f793fd

Please sign in to comment.