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.
 
 

58 lines
1.0 KiB

  1. #include "spaceship.h"
  2. #include "window.h"
  3. SpaceShip::SpaceShip() :
  4. color(COLOR_UNSET),
  5. size(SpaceShip::SIZE_UNSET),
  6. planet(PLANET_UNSET) {
  7. }
  8. SpaceShip::SpaceShip(unsigned char color, unsigned char size) :
  9. color(color),
  10. size(size),
  11. planet(PLANET_UNSET) {
  12. }
  13. void SpaceShip::render(Window *window, int y, int x, bool checkPlaced) {
  14. if (checkPlaced && this->planet != PLANET_UNSET) {
  15. return;
  16. }
  17. std::string print = "";
  18. if (this->size == SpaceShip::SMALL) {
  19. print = "S";
  20. }
  21. else if (this->size == SpaceShip::MEDIUM) {
  22. print = "M";
  23. }
  24. else if (this->size == SpaceShip::BIG) {
  25. print = "B";
  26. }
  27. window->print(print, y, x, COLOR_PAIR(this->color));
  28. }
  29. unsigned char SpaceShip::getColor() {
  30. return this->color;
  31. }
  32. void SpaceShip::setColor(unsigned char color) {
  33. this->color = color;
  34. }
  35. unsigned char SpaceShip::getSize() {
  36. return this->size;
  37. }
  38. void SpaceShip::setSize(unsigned char size) {
  39. this->size = size;
  40. }
  41. char SpaceShip::getPlanet() {
  42. return this->planet;
  43. }
  44. void SpaceShip::setPlanet(char planet) {
  45. this->planet = planet;
  46. }