Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F133127
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/boarddiamond.cpp b/boarddiamond.cpp
index 13bdb64..6e92135 100644
--- a/boarddiamond.cpp
+++ b/boarddiamond.cpp
@@ -1,41 +1,38 @@
#include "boarddiamond.h"
BoardDiamond::BoardDiamond()
{
}
BoardDiamond::BoardDiamond(TextureHolder *textures, int idNumber,
- int element, int boardPosition)
+ int playerNumber, int boardPosition)
{
this->textures = textures;
- this->element = element;
+ this->playerNumber = playerNumber;
this->boardPosition = boardPosition;
this->idNumber = idNumber;
spriteHolder.setTexture(this->textures->textureBoardDiamond);
sf::IntRect textureRect(idNumber*44, 0, 44,44);
spriteHolder.setTextureRect(textureRect);
spriteHolder.scale(0.5, 0.5);
setBoardPosition(boardPosition);
}
-int BoardDiamond::getPlayerNumber()
-{
-}
void BoardDiamond::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
if (boardPosition>-1)
{
states.transform *= getTransform();
sf::Vector2f where(getPosition());
target.draw(spriteHolder, states);
}
}
void BoardDiamond::update(sf::Time deltaTime, std::set<int> &busyTiles)
{
}
diff --git a/boarddiamond.h b/boarddiamond.h
index a30085f..74ffccb 100644
--- a/boarddiamond.h
+++ b/boarddiamond.h
@@ -1,35 +1,32 @@
#ifndef BOARDDIAMOND_H
#define BOARDDIAMOND_H
#include <set>
#include "textureholder.h"
#include "elem.h"
#include <SFML/Graphics.hpp>
class BoardDiamond: public Elem
{
public:
BoardDiamond();
BoardDiamond(TextureHolder *textures, int idNumber,
- int element, int boardPosition);
+ int playerNumber, int boardPosition);
TextureHolder *textures;
/*!
* \brief number from the sprite sheet
*/
int idNumber;
/*!
* \brief 0-3 elements area on the board
*/
- int element;
+ int playerNumber;
sf::Sprite spriteHolder;
- int getPlayerNumber(); /* TODO: this should be solved by saving number
- of the player in the first place.
- */
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
void update(sf::Time deltaTime, std::set<int>& busyTiles);
};
#endif // BOARDDIAMOND_H
diff --git a/command.cpp b/command.cpp
index 62e1a49..07a5492 100644
--- a/command.cpp
+++ b/command.cpp
@@ -1,19 +1,33 @@
#include "command.h"
Command::Command(efc::Game& currentGame) :
game(currentGame)
{
}
void Command::removeDiamond(int playerNumber)
{
/* This should works as following:
* - iterate over BoardDiamondSeq
* - find diamonds belonging to the playerNumber
* - create an array from the aboves
* - get a random element
* - remove from the board - set not active
*/
+ std::vector<int> diamonds;
+ for (auto&& i: game.boardDiamonds.diamonds)
+ {
+ int areaNumber = i.playerNumber;
+ if (areaNumber==playerNumber)
+ {
+ diamonds.push_back(areaNumber);
+ }
+
+
+ }
+ int numberDiamonds = diamonds.size();
+ int elemToRemove = rand() % numberDiamonds;
+
}
diff --git a/command.h b/command.h
index 839b74a..9d262ea 100644
--- a/command.h
+++ b/command.h
@@ -1,23 +1,23 @@
#ifndef COMMAND_H
#define COMMAND_H
#include "game.h"
-
+#include "vector"
namespace efc {
class Game;
}
class Command
{
public:
Command(efc::Game ¤tGame);
/*!
* \brief Removes a diamond from the player's field.
* \param player
*/
void removeDiamond(int playerNumber);
efc::Game &game;
};
#endif // COMMAND_H
diff --git a/game.h b/game.h
index b2c9f25..c3b51ec 100644
--- a/game.h
+++ b/game.h
@@ -1,177 +1,177 @@
#ifndef GAME_H
#define GAME_H
#include <stdlib.h>
#include <iostream>
#include <time.h> /* time */
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "tilemap.h"
#include "selector.h"
#include "playerhud.h"
#include "textureholder.h"
#include "hover.h"
#include "guichoosebuilding.h"
#include "guiwindow.h"
#include "rounddice.h"
#include "guirounddice.h"
#include "grouphud.h"
#include "animatedsprite.h"
#include "character.h"
#include "rotateelem.h"
#include "boarddiamondseq.h"
#include "soundfx.h"
#include "command.h"
namespace efc {
extern int initScreenX;
extern int initScreenY;
class Game
{
private:
sf::Vector2i screenSize;
public:
Game();
sf::RenderWindow window;
sf::View viewFull;
sf::View viewGui;
sf::View viewTiles;
+ BoardDiamondSeq boardDiamonds;
private:
void initBoard();
void loadAssets();
void drawPlayersGui();
void drawSquares();
void drawMenu();
sf::Vector2f getMousePos();
enum states {
state_init,
state_menu,
state_lets_begin,
state_roll_dice,
state_game,
state_gui_elem,
state_select_building,
state_gui_end_round,
state_end_game,
state_quit
};
states currentState;
sf::Texture textureBackground;
sf::Sprite spriteBackground;
sf::Sprite gameBackground;
sf::Sprite spriteBackgroundDark;
sf::Sprite spriteLestBegin;
sf::Texture textureBackgroundArt;
sf::Sprite spriteBackgroundArt;
sf::Texture textureTiles;
sf::Texture textureFaces;
sf::Font gameFont;
sf::Font menuFont;
sf::Text menuTxt;
TileMap map;
PlayerHud players[4];
int mapSize;
int level[256];
int levelElems[256];
TextureHolder textures;
std::set<int> currentNeighbours;
void command(std::string command);
int selectedPos;
Selector selector;
GuiChooseBuilding guiSelectBuilding;
Character character;
int turn;
void update(sf::Time frameTime);
void render();
std::string gameTitle;
RoundDice roundDice;
int roundNumber;
GuiRoundDice guiRoundDice;
void setCurrentNeighbours ();
void nextPlayer();
void nextRound();
sf::Sprite menuBackground;
sf::Sprite seasons[4];
//int currentSeason = 0;
sf::Music musicGame;
sf::Music musicBackground;
sf::Music musicMenu;
sf::SoundBuffer sfxClickBuffer;
sf::Sound sfxClick;
sf::SoundBuffer sfxDoneBuffer;
sf::Sound sfxDone;
void showMenu();
void hideMenu();
void showGameBoard();
void hideGameBoard();
GroupHud groupHud;
/*!
* \brief showPlayerBoardElems defines if show mouse hover for the player
*/
bool showPlayerBoardElems;
void drawBaseGame();
int month;
Animation walkingAnimationDown;
Animation walkingAnimationUp;
Animation walkingAnimationLeft;
Animation walkingAnimationRight;
Animation* currentAnimation;
AnimatedSprite animatedSprite;
void drawCharacters();
void handleLeftClick(sf::Vector2f pos,
sf::Vector2f posGui, sf::Vector2f posFull, int mousePos);
std::set<int> busyTiles;
int diceResultPlayer;
int numberFinishedPlayers;
RotateElem nextRotateElem;
RotateElem prevRotateElem;
void endGame();
- BoardDiamondSeq boardDiamonds;
SoundFX sfx;
float downTimeCounter;
};
}
#endif // GAME_H
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jun 16, 1:15 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
71604
Default Alt Text
(7 KB)
Attached To
Mode
R82 deerportal
Attached
Detach File
Event Timeline