Exemplo n.º 1
0
void ConsoleGame::handleSetBoard(std::istringstream & iss)
{
  std::string fenString;
  std::getline(iss, fenString);
  if (fenString.empty()) {
    std::cout << "A fen string must be provided\n";
    return;
  }

  setBoardPosition(fenString);
}
Exemplo n.º 2
0
Character::Character(TextureHolder *textures, int playerNumber):
    animatedSprite(sf::seconds(0.2f), true, false),
    nextRedirect(0.f)
{

    drawMovements = false;
    this->textures = textures;
    int offset = playerNumber*32;
    active = false;


    rectangleLeft.setFillColor(sf::Color(12, 12, 12,120));
    rectangleLeft.setOutlineColor(sf::Color(24,24,40, 255));
    rectangleRight.setFillColor(sf::Color(240, 240, 240,98));
    rectangleRight.setOutlineColor(sf::Color(24,40,24, 90));

    int charWidth = 32;
    int charHeight = 58;


    walkingAnimationDown.setSpriteSheet(textures->textureCharacters);
    walkingAnimationDown.addFrame(sf::IntRect(offset, 0, charWidth, charHeight));
    walkingAnimationDown.addFrame(sf::IntRect(offset, 58, charWidth, charHeight));

    walkingAnimationRight.setSpriteSheet(textures->textureCharacters);
    walkingAnimationRight.addFrame(sf::IntRect(offset, 116, charWidth, charHeight));
    walkingAnimationRight.addFrame(sf::IntRect(offset, 174, charWidth, charHeight));

    walkingAnimationLeft.setSpriteSheet(textures->textureCharacters);
    walkingAnimationLeft.addFrame(sf::IntRect(offset, 232, charWidth, charHeight));
    walkingAnimationLeft.addFrame(sf::IntRect(offset, 290, charWidth, charHeight));

    walkingAnimationUp.setSpriteSheet(textures->textureCharacters);
    walkingAnimationUp.addFrame(sf::IntRect(offset, 348, charWidth, charHeight));
    walkingAnimationUp.addFrame(sf::IntRect(offset, 406, charWidth, charHeight));

    currentAnimation = &walkingAnimationRight;


    leftChar.move(202,76);
    rightChar.move(202,76);

    animations[efc::DIR_LEFT] = walkingAnimationLeft;
    animations[efc::DIR_RIGHT] = walkingAnimationRight;
    animations[efc::DIR_UP] = walkingAnimationUp;
    animations[efc::DIR_DOWN] = walkingAnimationDown;

    setDirIndex(efc::DIR_LEFT);
    setDir();

    std::array<int, 4> boardPositions{{0,15,255-15,255}};
    setBoardPosition(boardPositions[playerNumber]);
}