Space Walk board game
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

48 lines
892 B

  1. #include "infowindow.h"
  2. #include "maingame.h"
  3. #include "player.h"
  4. #include "spaceship.h"
  5. InfoWindow::InfoWindow(int height, int width, Player **player, SpaceShip **ship) :
  6. height(height),
  7. width(width),
  8. player(player),
  9. ship(ship) {
  10. }
  11. InfoWindow::~InfoWindow() {
  12. }
  13. void InfoWindow::update() {
  14. Window::update();
  15. this->resize();
  16. int y = 0;
  17. int x = 1;
  18. for (unsigned char i = 0; i < PLAYER_SIZE; i++) {
  19. this->player[i]->render(this, y, x, i + 1);
  20. y += 6;
  21. int shipIdx = i * SHIP_SIZE / 2;
  22. for (unsigned char j = shipIdx; j < shipIdx + SHIP_SIZE / 2; j++) {
  23. this->ship[j]->render(this, y, x);
  24. x++;
  25. if (x > 3) {
  26. y++;
  27. x = 1;
  28. }
  29. }
  30. y += 2;
  31. }
  32. }
  33. void InfoWindow::resize() {
  34. int rows = this->getMaxRows() - this->height;
  35. int x = this->getMaxCols() - this->width;
  36. int cols = this->getMaxCols() - x;
  37. this->setWindow(rows, cols, 0, x);
  38. Window::resize();
  39. }