Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
32 KB
Referenced Files
None
Subscribers
None
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..4a93d46
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(deerportal)
+
+find_package(SFML 2.1 COMPONENTS graphics window audio system REQUIRED)
+
+set(SOURCES
+ animatedsprite.cpp
+ animation.cpp
+ boarddiamond.cpp
+ boarddiamondseq.cpp
+ boardelem.cpp
+ boardelems.cpp
+ bubble.cpp
+ calendar.cpp
+ card.cpp
+ cardsdeck.cpp
+ cardslist.cpp
+ character.cpp
+ command.cpp
+ data.cpp
+ elem.cpp
+ game.cpp
+ grouphud.cpp
+ guirounddice.cpp
+ guiwindow.cpp
+ hover.cpp
+ main.cpp
+ particlesystem.cpp
+ pile.cpp
+ playerhud.cpp
+ rotateelem.cpp
+ rounddice.cpp
+ selector.cpp
+ soundfx.cpp
+ textureholder.cpp
+ tilemap.cpp
+)
+
+if (CMAKE_COMPILER_IS_GNUCXX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -static-libgcc -static-libgcc")
+endif()
+
+include_directories(${SFML_INCLUDE_DIR})
+add_executable(deerportal ${SOURCES})
+target_link_libraries(deerportal ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
diff --git a/boardelem.h b/boardelem.h
index cee3857..b41a0e8 100644
--- a/boardelem.h
+++ b/boardelem.h
@@ -1,34 +1,24 @@
#ifndef BOARDELEM_H
#define BOARDELEM_H
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "tilemap.h"
#include "textureholder.h"
namespace efc {
sf::RectangleShape createNeighbour(int pos);
class BoardElem: public sf::Sprite
{
public:
BoardElem();
BoardElem(int pos, int type);
int pos;
int type;
sf::Texture* textureTiles;
-private:
-
-// const sf::Texture* textureElem;
- static const sf::Texture& textureElem2;
-
-
-
-
-// TextureHolder *textures;
-// TextureHolder myHolder;
};
}
#endif // BOARDELEM_H
diff --git a/bubble.cpp b/bubble.cpp
index ef146eb..191f797 100644
--- a/bubble.cpp
+++ b/bubble.cpp
@@ -1,41 +1,39 @@
+#include <cmath>
#include "bubble.h"
Bubble::Bubble():
state(BubbleState::DICE),
timeCounter(0),
posY(0)
{
spritesBubbles = {{spriteDice, spriteFootSteps}};
if (!textureDice.loadFromFile("assets/img/bubble_dice.png"))
std::exit(1);
if (!textureFootSteps.loadFromFile("assets/img/bubble_footsteps.png"))
std::exit(1);
spritesBubbles[0].setTexture(textureDice);
spritesBubbles[1].setTexture(textureFootSteps);
-// sprites[0] = spriteDice;
-// sprites[1] = spriteFootSteps;
-//
}
void Bubble::setPosition(float x, float y) {
Transformable::setPosition(x, y);
posY = y;
}
void Bubble::draw(sf::RenderTarget& target, sf::RenderStates states) const {
states.transform *= getTransform();
target.draw(spritesBubbles[state], states);
}
void Bubble::update(sf::Time deltaTime)
{
timeCounter += deltaTime.asSeconds()*10;
float modifier = sin(timeCounter)*5;
Transformable::setPosition(getPosition().x, posY+modifier);
}
diff --git a/calendar.h b/calendar.h
index 7efe52e..65964f1 100644
--- a/calendar.h
+++ b/calendar.h
@@ -1,74 +1,76 @@
/*
* Pagan
*
* $OpenBSD: calendar.pagan,v 1.2 2002/03/20 22:53:40 mickey Exp $
*/
#ifndef _calendar_pagan_
#define _calendar_pagan_
#include <iostream>
#include <array>
-static std::array<std::array<std::string,3>,59> PAGAN_HOLIDAYS = {{ {"01", "02", "Frigg's Distaff"},
- {"01", "06", "Celtic day of the Three-Fold Goddess"},
- {"01", "10", "Geraints Day"},
- {"01", "13", "Midvintersblot"},
- {"01", "20", "Midvintersblot"},
- {"01", "22", "Festival of the Muses"},
- {"01", "25", "Old Disting Feast"},
- {"01", "TueLast", "Upelly - old fire festival"},
- {"01", "31", "Honoring the Valkyries"},
- {"02", "02", "1st Cross-Quarter Day"},
- {"02", "02", "Imbolg / Imbolc (other Celtic names) / Brighid / Oimelc"},
- {"02", "11", "The Day the Birds Begin to Sing"},
- {"02", "14", "Festival of Vali"},
- {"03", "02", "Day of the Crows"},
- {"03", "13", "Burgsonndeg - festival of rebirth of the sun and the approach of spring"},
- {"03", "17", "Celebration of Trefuilnid Treochar (St.Patrick's day)"},
- {"03", "18", "Sheela's Day"},
- {"03", "19", "1st Quarter Day - Spring (Vernal) Equinox"},
- {"03", "20", "Festival of Iduna"},
- {"03", "21", "Ostara / Eostre (Saxon goddess of Spring)"},
- {"04", "30", "May Eve / Walpurgisnacht (witches' Sabbath) / Walpurgis Night (after St. Walpurga)"},
- {"05", "01", "May Day / Beltane / Bealtaine - Celtic bonfire festival"},
- {"05", "04", "2nd Cross-Quarter Day"},
- {"05", "12", "The Cat Parade"},
- {"05", "14", "Midnight Sun Festival"},
- {"05", "18", "Festival of the Horned God Cennunos"},
- {"05", "20", "Festival of Mjollnir, Thor's Hammer"},
- {"05", "24", "Mother's Day, in celebration of the Triple Goddes"},
- {"06", "20", "2nd Quarter Day - Summer Solstice"},
- {"06", "21", "Litha (Norse/Anglo-Saxon for longest day)"},
- {"06", "23", "St. John's Eve - European Midsummer celebration"},
- {"08", "01", "Lugnasad / Lughnasada / Lunasa - Gaelic summer games of Lug (sun-god)"},
- {"08", "02", "Lady Godiva Day"},
- {"08", "04", "Loch mo Naire"},
- {"08", "05", "3rd Cross-Quarter Day"},
- {"08", "10", "Puck Faire"},
- {"08", "14", "Day of the Burryma"},
- {"08", "17", "Odin's Ordeal"},
- {"08", "23", "Feast of Ilmatar"},
- {"08", "28", "Frey Faxi"},
- {"08", "29", "Festival of Urda"},
- {"09", "21", "3rd Quarter Day - Fall (Autumnal) Equinox"},
- {"10", "08", "Day of Remembrance for Erik the Red"},
- {"10", "09", "Leif Erikson Day"},
- {"10", "11", "Old Lady of the Trees"},
- {"10", "14", "Winter Nights - festival celebrating the harvest"},
- {"10", "18", "Great Horn Faire"},
- {"10", "24", "Feast of the Spirits of the Air"},
- {"10", "27", "Allan Apple Day"},
- {"10", "31", "Hallowmas / Allhallowmas / Allhallows"},
- {"11", "01", "Samhain - Celtic feast of departing Sun & new year"},
- {"11", "05", "4th Cross-Quarter Day"},
- {"12", "06", "Festival of Nicolas, an aspect of Odin, leader of the hunt"},
- {"12", "09", "Yule Cleansing - The Danish fetch water for brewing the Yule-Ale"},
- {"12", "13", "Wodan's Jag - the Wild Hunt of Odin and his Army"},
- {"12", "18", "Festival of Epona"},
- {"12", "20", "4th Quarter Day - Winter Solstice"},
- {"12", "21", "Festival of Beiwe / Nertha / Alban Athuan"},
- {"12", "21", "Yule (Norse for wheel) - Germanic 12-day feast"}}};
+static std::array<std::array<std::string,3>,59> PAGAN_HOLIDAYS = {{
+ {{"01", "02", "Frigg's Distaff"}},
+ {{"01", "06", "Celtic day of the Three-Fold Goddess"}},
+ {{"01", "10", "Geraints Day"}},
+ {{"01", "13", "Midvintersblot"}},
+ {{"01", "20", "Midvintersblot"}},
+ {{"01", "22", "Festival of the Muses"}},
+ {{"01", "25", "Old Disting Feast"}},
+ {{"01", "TueLast", "Upelly - old fire festival"}},
+ {{"01", "31", "Honoring the Valkyries"}},
+ {{"02", "02", "1st Cross-Quarter Day"}},
+ {{"02", "02", "Imbolg / Imbolc (other Celtic names) / Brighid / Oimelc"}},
+ {{"02", "11", "The Day the Birds Begin to Sing"}},
+ {{"02", "14", "Festival of Vali"}},
+ {{"03", "02", "Day of the Crows"}},
+ {{"03", "13", "Burgsonndeg - festival of rebirth of the sun and the approach of spring"}},
+ {{"03", "17", "Celebration of Trefuilnid Treochar (St.Patrick's day)"}},
+ {{"03", "18", "Sheela's Day"}},
+ {{"03", "19", "1st Quarter Day - Spring (Vernal) Equinox"}},
+ {{"03", "20", "Festival of Iduna"}},
+ {{"03", "21", "Ostara / Eostre (Saxon goddess of Spring)"}},
+ {{"04", "30", "May Eve / Walpurgisnacht (witches' Sabbath) / Walpurgis Night (after St. Walpurga)"}},
+ {{"05", "01", "May Day / Beltane / Bealtaine - Celtic bonfire festival"}},
+ {{"05", "04", "2nd Cross-Quarter Day"}},
+ {{"05", "12", "The Cat Parade"}},
+ {{"05", "14", "Midnight Sun Festival"}},
+ {{"05", "18", "Festival of the Horned God Cennunos"}},
+ {{"05", "20", "Festival of Mjollnir, Thor's Hammer"}},
+ {{"05", "24", "Mother's Day, in celebration of the Triple Goddes"}},
+ {{"06", "20", "2nd Quarter Day - Summer Solstice"}},
+ {{"06", "21", "Litha (Norse/Anglo-Saxon for longest day)"}},
+ {{"06", "23", "St. John's Eve - European Midsummer celebration"}},
+ {{"08", "01", "Lugnasad / Lughnasada / Lunasa - Gaelic summer games of Lug (sun-god)"}},
+ {{"08", "02", "Lady Godiva Day"}},
+ {{"08", "04", "Loch mo Naire"}},
+ {{"08", "05", "3rd Cross-Quarter Day"}},
+ {{"08", "10", "Puck Faire"}},
+ {{"08", "14", "Day of the Burryma"}},
+ {{"08", "17", "Odin's Ordeal"}},
+ {{"08", "23", "Feast of Ilmatar"}},
+ {{"08", "28", "Frey Faxi"}},
+ {{"08", "29", "Festival of Urda"}},
+ {{"09", "21", "3rd Quarter Day - Fall (Autumnal) Equinox"}},
+ {{"10", "08", "Day of Remembrance for Erik the Red"}},
+ {{"10", "09", "Leif Erikson Day"}},
+ {{"10", "11", "Old Lady of the Trees"}},
+ {{"10", "14", "Winter Nights - festival celebrating the harvest"}},
+ {{"10", "18", "Great Horn Faire"}},
+ {{"10", "24", "Feast of the Spirits of the Air"}},
+ {{"10", "27", "Allan Apple Day"}},
+ {{"10", "31", "Hallowmas / Allhallowmas / Allhallows"}},
+ {{"11", "01", "Samhain - Celtic feast of departing Sun & new year"}},
+ {{"11", "05", "4th Cross-Quarter Day"}},
+ {{"12", "06", "Festival of Nicolas, an aspect of Odin, leader of the hunt"}},
+ {{"12", "09", "Yule Cleansing - The Danish fetch water for brewing the Yule-Ale"}},
+ {{"12", "13", "Wodan's Jag - the Wild Hunt of Odin and his Army"}},
+ {{"12", "18", "Festival of Epona"}},
+ {{"12", "20", "4th Quarter Day - Winter Solstice"}},
+ {{"12", "21", "Festival of Beiwe / Nertha / Alban Athuan"}},
+ {{"12", "21", "Yule (Norse for wheel) - Germanic 12-day feast"}}
+}};
std::string getHoliday(int month, int day);
#endif /* !_calendar_pagan_ */
diff --git a/cardsdeck.cpp b/cardsdeck.cpp
index f4cf8b0..baade85 100644
--- a/cardsdeck.cpp
+++ b/cardsdeck.cpp
@@ -1,143 +1,143 @@
#include "cardsdeck.h"
CardsDeck::CardsDeck(TextureHolder *textures, sf::Font *gameFont, Command *command)
{
commandManager=command;
std::array<std::array<int,2>,4> cardsPos = {
{
- {1087,95}, {1225, 95}, {1225, 277}, {1087, 277}
+ {{1087,95}}, {{1225, 95}}, {{1225, 277}}, {{1087, 277}}
}
};
this->textures = textures;
for (int i=0;i<=3;i++)
{
// spriteCardBases[i].setTexture(this->textures->textureCardBases[i]);
spriteCardBases[i].setPosition(cardsPos[i][0],cardsPos[i][1]);
textPileTitle[i].setFont(*gameFont);
textPileTitle[i].setCharacterSize(16);
textPileTitle[i].setPosition(cardsPos[i][0]+10,cardsPos[i][1]+100);
for (unsigned int j=0;j<efc::cardsDistribution.size();j++)
{
int cardTypeInt = efc::cardsDistribution[j];
cardsList[i].cardsPile[j].cardType = efc::cardsTypes[cardTypeInt];
cardsList[i].cardsPile[j].cardTypeInt = cardTypeInt;
spriteCardBases[i].setTexture(this->textures->cardsTextures[i][cardTypeInt]);
}
}
reloadCards();
}
void CardsDeck::reloadCards(){
for (int i=0;i<=3;i++)
{
cardsList[i].shufflePile();
setTitles(i);
}
}
void CardsDeck::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
for (int i=0;i<=3;i++)
{
if ((cardsList[i].invisibleLeft==0.0f) and (cardsList[i].active))
{
target.draw(spriteCardBases[i], states);
target.draw(textPileTitle[i], states);
}
}
}
void CardsDeck::setTitles(int number)
{
int cardTypeInt = getCardTypeInt(number);
textPileTitle[number].setString(efc::cardsTypes[cardTypeInt]);
// int val = getCardTypeInt(number);
spriteCardBases[number].setTexture(textures->cardsTextures[number][cardTypeInt]);
}
void CardsDeck::setFonts(sf::Font *gameFont)
{
for (int i=0;i<=3;i++)
{
textPileTitle[i].setFont(*gameFont);
}
}
void CardsDeck::nextCard(int pileNumber)
{
if (cardsList[pileNumber].active)
{
cardsList[pileNumber].invisibleLeft = 0.75f;
unsigned int currentCard = getCurrentCard(pileNumber);
if (currentCard>=efc::cardsDistribution.size()-1)
{
cardsList[pileNumber].active = false;
commandManager->removeAllCardElement(pileNumber);
} else
{
currentCard += 1;
if (currentCard>3)
currentCard = 0;
cardsList[pileNumber].currentCard = currentCard;
setTitles(pileNumber);
}
}
// setSprites(pileNumber);
}
int CardsDeck::getCurrentCard(int pileNumber)
{
int currentCard = cardsList[pileNumber].currentCard;
return currentCard;
}
std::string CardsDeck::getTitle(int pileNumber)
{
std::string currentText = efc::cardsTypes[getCardTypeInt(pileNumber)];
return currentText;
}
int CardsDeck::getCardTypeInt(int pileNumber)
{
int result = cardsList[pileNumber].cardsPile[getCurrentCard(pileNumber)].cardTypeInt;
return result;
}
void CardsDeck::update(sf::Time deltaTime)
{
for (int i=0;i<=3;i++)
{
if (cardsList[i].invisibleLeft>0.0f)
{
cardsList[i].invisibleLeft -= deltaTime.asSeconds();
}
if (cardsList[i].invisibleLeft<0.0f)
{
cardsList[i].invisibleLeft = 0.0f;
}
}
}
diff --git a/cardslist.h b/cardslist.h
index d2e82eb..ce4ce0d 100644
--- a/cardslist.h
+++ b/cardslist.h
@@ -1,45 +1,45 @@
#ifndef CARDSLIST_H
#define CARDSLIST_H
#include <vector>
#include <iostream> // std::cout
#include <algorithm> // std::shuffle
#include <random> // std::default_random_engine
#include <chrono> // std::chrono::system_clock
#include "card.h"
namespace efc {
- const static std::array<int,32> cardsDistribution = {
+ const static std::array<int,32> cardsDistribution = {{
0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,
- };
- const static std::array<int,2> cardsDistributionDebug = {
+ }};
+ const static std::array<int,2> cardsDistributionDebug = {{
2,3
- };
+ }};
const static int PILE_SIZE = efc::cardsDistribution.size();
}
class CardsList
{
public:
CardsList(); // To create an array of CardsList
explicit CardsList(int element);
// int amount;
// std::vector<Card*> sd;
/*!
* \brief element Number of the element
*/
std::array<Card, efc::PILE_SIZE> cardsPile;
int currentCard;
int element; /*!< Number of the element */
float invisibleLeft;
bool active;
void shufflePile();
};
#endif // CARDSLIST_H
diff --git a/data.cpp b/data.cpp
index f2fe8a7..a4023b6 100644
--- a/data.cpp
+++ b/data.cpp
@@ -1,127 +1,127 @@
-#include <data.h>
+#include "data.h"
namespace efc {
std::string seasonsNames[4] = {"winter", "spring", "summer", "fall"};
// This array defines fields occupied by the river
int terrainArray[24] = {
8, 24, 40, 56, 72, 88,
113, 114, 115, 116, 117, 118,
138, 139, 140, 141, 142, 143,
167, 183, 199, 215, 231, 247
};
/*
* 0
* 16
* 32
* 48
* 64
* 80
* 96
* 112
* 128
* 144
* 160
* 176
* 192
*/
std::array<std::array<int,2>,256> boards = {
{
- {-1,1}, {0,2}, {1,3}, {2,4}, {3,5}, {4,21}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {11,26}, {12,10}, {13,11}, {14,12}, {15,13}, {-1,14},
- {-1,-1}, {18,33}, {19,17}, {20,18}, {21,19}, {5,20}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {10, 27,}, {26,28}, {27,29}, {28,30}, {29,46}, {-1,-1},
- {33,48}, {17,32}, {-1,-1}, {51,36}, {35,37}, {36,38}, {37,54}, {-1,-1}, {-1,-1}, {-1,-1}, {43,58}, {44,42}, {60,43}, {-1,-1}, {30,47}, {46,63},
- {32,49}, {48,50}, {49,51}, {50,35}, {-1,-1}, {54,69}, {38,53}, {-1,-1}, {-1,-1}, {58,73}, {42,57}, {-1,-1}, {61,44}, {62,60}, {63,61}, {47,62},
- {65,80}, {66,64}, {67,65}, {68,66}, {69,67}, {53,68}, {-1,-1}, {-1,-1}, {-1,-1}, {57,74}, {73,75}, {74,76}, {75,77}, {76,78}, {77,79}, {78,95},
- {64,81}, {80,97}, {-1,-1}, {99,84}, {83,85}, {84,101}, {-1,-1}, {-1,-1}, {-1,-1}, {90,105}, {91,89}, {92,90}, {108,91}, {-1,-1}, {95,110}, {79,94},
- {-1,-1}, {81,98}, {97,99}, {98,83}, {-1,-1}, {85,102}, {101,118}, {-1,-1}, {105,120}, {89,104}, {-1,-1}, {-1,-1}, {109,92}, {110,108}, {94,109}, {-1,-1},
- {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {102, 119},{118,-2}, {104,-2}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1},
- {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1} , {151,-2}, {137,-2}, {153,136}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1},
- {-1,-1}, {161,146}, {145,147}, {146,163}, {-1,-1}, {-1,-1}, {166,151}, {150,135} ,{-1,-1}, {154,137}, {170,153}, {-1,-1}, {157,172}, {158,156}, {174,157}, {-1,-1},
- {176,161},{160,145}, {-1,-1}, {147,164}, {163,165}, {164,166}, {165,150}, {-1,-1}, {-1,-1}, {-1,-1}, {171,154}, {172,170}, {156,171}, {-1,-1}, {175,158}, {191,174},
- {177,160},{178,176}, {179,177}, {180,178}, {181,179}, {182,180}, {198,181}, {-1,-1}, {-1,-1}, {-1,-1}, {202,187}, {186,188}, {187,189}, {188,190}, {189,191}, {190,175},
- {208,193},{192,194}, {193,195}, {194,211}, {-1,-1}, {213,198}, {197,182}, {-1,-1}, {-1,-1}, {217,202}, {201,186}, {-1,-1}, {205,220}, {206,204}, {207,205}, {223,206},
- {209,192},{225,208}, {-1,-1}, {195,212}, {211,213}, {212,197}, {-1,-1}, {-1,-1}, {-1,-1}, {218,201}, {219,217}, {220,218}, {204,219}, {-1,-1}, {238,223}, {222,207},
- {-1,-1}, {226,209}, {227,225}, {228,226}, {229,227}, {245,228}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {250,235}, {234,236}, {235,237}, {236,238}, {237,222}, {-1,-1},
- {-1,241}, {240,242},{241,243}, {242,244}, {243,245}, {244,229}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {251,234}, {252,250}, {253,251}, {254,252}, {255,253}, {-1,254},
+ {{-1,1}}, {{0,2}}, {{1,3}}, {{2,4}}, {{3,5}}, {{4,21}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{11,26}}, {{12,10}}, {{13,11}}, {{14,12}}, {{15,13}}, {{-1,14}},
+ {{-1,-1}}, {{18,33}}, {{19,17}}, {{20,18}}, {{21,19}}, {{5,20}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{10, 27,}}, {{26,28}}, {{27,29}}, {{28,30}}, {{29,46}}, {{-1,-1}},
+ {{33,48}}, {{17,32}}, {{-1,-1}}, {{51,36}}, {{35,37}}, {{36,38}}, {{37,54}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{43,58}}, {{44,42}}, {{60,43}}, {{-1,-1}}, {{30,47}}, {{46,63}},
+ {{32,49}}, {{48,50}}, {{49,51}}, {{50,35}}, {{-1,-1}}, {{54,69}}, {{38,53}}, {{-1,-1}}, {{-1,-1}}, {{58,73}}, {{42,57}}, {{-1,-1}}, {{61,44}}, {{62,60}}, {{63,61}}, {{47,62}},
+ {{65,80}}, {{66,64}}, {{67,65}}, {{68,66}}, {{69,67}}, {{53,68}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{57,74}}, {{73,75}}, {{74,76}}, {{75,77}}, {{76,78}}, {{77,79}}, {{78,95}},
+ {{64,81}}, {{80,97}}, {{-1,-1}}, {{99,84}}, {{83,85}}, {{84,101}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{90,105}}, {{91,89}}, {{92,90}}, {{108,91}}, {{-1,-1}}, {{95,110}}, {{79,94}},
+ {{-1,-1}}, {{81,98}}, {{97,99}}, {{98,83}}, {{-1,-1}}, {{85,102}}, {{101,118}}, {{-1,-1}}, {{105,120}}, {{89,104}}, {{-1,-1}}, {{-1,-1}}, {{109,92}}, {{110,108}}, {{94,109}}, {{-1,-1}},
+ {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{102, 119}},{{118,-2}}, {{104,-2}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}},
+ {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}} , {{151,-2}}, {{137,-2}}, {{153,136}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}},
+ {{-1,-1}}, {{161,146}}, {{145,147}}, {{146,163}}, {{-1,-1}}, {{-1,-1}}, {{166,151}}, {{150,135}} ,{{-1,-1}}, {{154,137}}, {{170,153}}, {{-1,-1}}, {{157,172}}, {{158,156}}, {{174,157}}, {{-1,-1}},
+ {{176,161}},{{160,145}}, {{-1,-1}}, {{147,164}}, {{163,165}}, {{164,166}}, {{165,150}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{171,154}}, {{172,170}}, {{156,171}}, {{-1,-1}}, {{175,158}}, {{191,174}},
+ {{177,160}},{{178,176}}, {{179,177}}, {{180,178}}, {{181,179}}, {{182,180}}, {{198,181}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{202,187}}, {{186,188}}, {{187,189}}, {{188,190}}, {{189,191}}, {{190,175}},
+ {{208,193}},{{192,194}}, {{193,195}}, {{194,211}}, {{-1,-1}}, {{213,198}}, {{197,182}}, {{-1,-1}}, {{-1,-1}}, {{217,202}}, {{201,186}}, {{-1,-1}}, {{205,220}}, {{206,204}}, {{207,205}}, {{223,206}},
+ {{209,192}},{{225,208}}, {{-1,-1}}, {{195,212}}, {{211,213}}, {{212,197}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{218,201}}, {{219,217}}, {{220,218}}, {{204,219}}, {{-1,-1}}, {{238,223}}, {{222,207}},
+ {{-1,-1}}, {{226,209}}, {{227,225}}, {{228,226}}, {{229,227}}, {{245,228}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{250,235}}, {{234,236}}, {{235,237}}, {{236,238}}, {{237,222}}, {{-1,-1}},
+ {{-1,241}}, {{240,242}},{{241,243}}, {{242,244}}, {{243,245}}, {{244,229}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{251,234}}, {{252,250}}, {{253,251}}, {{254,252}}, {{255,253}}, {{-1,254}},
},
};
std::array<std::array<int,numberSteps>,4> occupiedFields =
{
{
- {1,2,3,4,5,17,18,19,20,21,32,33,35,36,37,38,48,49,50,51,53,54,64,65,66,67,68,69,80,81,83,84,85,97,98,99,101,102,118},
- {10,11,12,13,14,26,27,28,29,30,42,43,44,46,47,57,58,60,61,62,63,73,74,75,76,77,78,79,89,90,91,92,94,95,104,105,108,109,110},
- {145,146,147,150,151,160,161,163,164,165,166,176,177,178,179,180,181,182,192,193,194,195,197,198,208,209,211,212,213,225,226,227,228,229,241,242,243,244,245},
- {137,153,154,156,157,158,170,171,172,174,175,186,187,188,189,190,191,201,202,204,205,206,207,217,218,219,220,222,223,234,235,236,237,238,250,251,252,253,254}
+ {{1,2,3,4,5,17,18,19,20,21,32,33,35,36,37,38,48,49,50,51,53,54,64,65,66,67,68,69,80,81,83,84,85,97,98,99,101,102,118}},
+ {{10,11,12,13,14,26,27,28,29,30,42,43,44,46,47,57,58,60,61,62,63,73,74,75,76,77,78,79,89,90,91,92,94,95,104,105,108,109,110}},
+ {{145,146,147,150,151,160,161,163,164,165,166,176,177,178,179,180,181,182,192,193,194,195,197,198,208,209,211,212,213,225,226,227,228,229,241,242,243,244,245}},
+ {{137,153,154,156,157,158,170,171,172,174,175,186,187,188,189,190,191,201,202,204,205,206,207,217,218,219,220,222,223,234,235,236,237,238,250,251,252,253,254}}
}
};
sf::Color playersColors[4] = {
sf::Color(122, 185,246,255),
sf::Color(144, 226,106,255),
sf::Color(255, 163,142,255),
sf::Color(250, 255,117,255),
};
std::array<std::array<int,3>,efc::diamondsNumber> DIAMONDS_SETUP =
{
{
- {0,0,-1},{0,0,-1},
- {1,0,-1},{1,0,-1},
- {2,0,-1},{2,0,-1},
- {3,0,-1},{3,0,-1},
- {4,0,-1},{4,0,-1},{4,0,-1},{4,0,-1},{4,0,-1},{4,0,-1},
- {0,0,-1},{0,0,-1},
- {1,0,-1},{1,0,-1},
- {2,0,-1},{2,0,-1},
- {3,0,-1},{3,0,-1},
- {4,0,-1},{4,0,-1},{4,0,-1},{4,0,-1},{4,0,-1},{4,0,-1},
-
- {0,1,-1},{0,1,-1},
- {1,1,-1},{1,1,-1},
- {2,1,-1},{2,1,-1},
- {3,1,-1},{3,1,-1},
- {4,1,-1},{4,1,-1},{4,1,-1},{4,1,-1},{4,1,-1},{4,1,-1},
- {0,1,-1},{0,1,-1},
- {1,1,-1},{1,1,-1},
- {2,1,-1},{2,1,-1},
- {3,1,-1},{3,1,-1},
- {4,1,-1},{4,1,-1},{4,1,-1},{4,1,-1},{4,1,-1},{4,1,-1},
-
-
-
- {0,3,-1},{0,3,-1},
- {1,3,-1},{1,3,-1},
- {2,3,-1},{2,3,-1},
- {3,3,-1},{3,3,-1},
- {4,3,-1},{4,3,-1},{4,3,-1},{4,3,-1},{4,3,-1},{4,3,-1},
- {0,3,-1},{0,3,-1},
- {1,3,-1},{1,3,-1},
- {2,3,-1},{2,3,-1},
- {3,3,-1},{3,3,-1},
- {4,3,-1},{4,3,-1},{4,3,-1},{4,3,-1},{4,3,-1},{4,3,-1},
-
-
- {0,2,-1},{0,2,-1},
- {1,2,-1},{1,2,-1},
- {2,2,-1},{2,2,-1},
- {3,2,-1},{3,2,-1},
- {4,2,-1},{4,2,-1},{4,2,-1},{4,2,-1},{4,2,-1},{4,2,-1},
- {0,2,-1},{0,2,-1},
- {1,2,-1},{1,2,-1},
- {2,2,-1},{2,2,-1},
- {3,2,-1},{3,2,-1},
- {4,2,-1},{4,2,-1},{4,2,-1},{4,2,-1},{4,2,-1},{4,2,-1},
+ {{0,0,-1}},{{0,0,-1}},
+ {{1,0,-1}},{{1,0,-1}},
+ {{2,0,-1}},{{2,0,-1}},
+ {{3,0,-1}},{{3,0,-1}},
+ {{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},
+ {{0,0,-1}},{{0,0,-1}},
+ {{1,0,-1}},{{1,0,-1}},
+ {{2,0,-1}},{{2,0,-1}},
+ {{3,0,-1}},{{3,0,-1}},
+ {{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},
+
+ {{0,1,-1}},{{0,1,-1}},
+ {{1,1,-1}},{{1,1,-1}},
+ {{2,1,-1}},{{2,1,-1}},
+ {{3,1,-1}},{{3,1,-1}},
+ {{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},
+ {{0,1,-1}},{{0,1,-1}},
+ {{1,1,-1}},{{1,1,-1}},
+ {{2,1,-1}},{{2,1,-1}},
+ {{3,1,-1}},{{3,1,-1}},
+ {{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},
+
+
+
+ {{0,3,-1}},{{0,3,-1}},
+ {{1,3,-1}},{{1,3,-1}},
+ {{2,3,-1}},{{2,3,-1}},
+ {{3,3,-1}},{{3,3,-1}},
+ {{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},
+ {{0,3,-1}},{{0,3,-1}},
+ {{1,3,-1}},{{1,3,-1}},
+ {{2,3,-1}},{{2,3,-1}},
+ {{3,3,-1}},{{3,3,-1}},
+ {{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},
+
+
+ {{0,2,-1}},{{0,2,-1}},
+ {{1,2,-1}},{{1,2,-1}},
+ {{2,2,-1}},{{2,2,-1}},
+ {{3,2,-1}},{{3,2,-1}},
+ {{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},
+ {{0,2,-1}},{{0,2,-1}},
+ {{1,2,-1}},{{1,2,-1}},
+ {{2,2,-1}},{{2,2,-1}},
+ {{3,2,-1}},{{3,2,-1}},
+ {{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},
}
} ;
}
diff --git a/playerhud.cpp b/playerhud.cpp
index 9c35779..3ae80e0 100644
--- a/playerhud.cpp
+++ b/playerhud.cpp
@@ -1,265 +1,265 @@
#include "playerhud.h"
#include "textureholder.h"
#include "boardelem.h"
std::set<int> Player::getTerrainSet(){
std::set<int> terrain;
for (int i: efc::terrainArray)
{
terrain.insert(i);
}
return terrain;
}
std::set<int> Player::getBusy(){
std::set<int> busyTiles;
for (std::pair<int, efc::BoardElem> i: elems.items_map)
{
busyTiles.insert(i.first);
}
return busyTiles;
}
std::set<int> Player::getNeighbours(){
std::set<int> neighbours;
for (std::pair<int, efc::BoardElem> i: elems.items_map)
{
std::set<int> terrain = getTerrainSet();
std::set<int> neighboursVector(efc::getNeighbours(i.second.pos));
for (int j: neighboursVector)
{
if ((elems.items_map.count(j) == 0) && (terrain.count(j)==0))
{
neighbours.insert(j);
}
}
}
return neighbours;
}
void Player::updateTxt(){
txtCash.setString(std::to_string(cash));
}
void Player::updatePlayer(){
updateTxt();
}
Player::Player():
frozenLeft(0),
reachedPortal(false),
reachedPortalFirst(false),
human(false)
{
pos = 0;
cash = 0;
energy = 0;
food = 0;
faith = 0;
active = false;
done = false;
tileSize = 0;
textures = nullptr;
number = 0;
// setSpriteAI();
}
void Player::setActive(bool newState){
active = newState;
elems.active = newState;
for (auto&& i: characters)
{
i.active = newState;
}
}
Player::Player(TextureHolder *textures, sf::Font *gameFont, int playerNumber):
reachedPortal(false),
reachedPortalFirst(false),
human(false)
{
number = playerNumber;
frozenLeft = 0;
done = false;
active = false;
this->textures = textures;
// Character character(this->textures, pos);
characters.push_back(Character (this->textures, playerNumber));
// efc::BoardElem startElem(textures, efc::startPlayers[pos],444);
// startElem.setColor(efc::playersColors[pos]);
// elems.items.push_back(startElem);
// elems.items_map.insert({efc::startPlayers[pos], startElem});
// this->faceSize = faceSize;
// spriteFace.setTexture(textures->textureFaces);
this->pos = playerNumber;
// symbol.setTexture(this->textures->textureSymbols);
// sf::IntRect symbolsRect[4] = {sf::IntRect(0,0,255,255), sf::IntRect(256,0,512,255), sf::IntRect(0,255, 255, 512), sf::IntRect(255,255,512, 512)};
// symbol.setTextureRect(symbolsRect[pos]);
// symbol.setScale(sf::Vector2f(0.2f, 0.20f));
// symbol.setColor(sf::Color(25, 25, 25, 105));
// symbol.setPosition(60, (pos*100)+40);
food = 0;
cash = 0;
energy = 0;
faith = 0;
txtCash.setFont(*gameFont);
txtCash.setCharacterSize(20);
txtFood.setFont(*gameFont);
txtEnergy.setFont(*gameFont);
txtFaith.setFont(*gameFont);
txtNextRound.setFont(*gameFont);
txtNextRound.setString("End Turn");
txtNextRound.setCharacterSize(12);
txtNextRound.setPosition(40,(playerNumber*100)+10);
int posX1 = 82;
int posX2 = 962;
int posY1 = 22;
int posY2 = 720;
std::array<std::array<int,2>,4> textPos =
{
{
- {{posX1,posY1}}, {posX2,posY1},
- {{posX1,posY2}}, {posX2, posY2}
+ {{posX1,posY1}}, {{posX2,posY1}},
+ {{posX1,posY2}}, {{posX2, posY2}}
}
};
txtCash.setPosition(textPos[playerNumber][0],textPos[playerNumber][1] );
buttons.insert({"end_turn",rectangle});
setSpriteAI();
}
std::string Player::getElem(sf::Vector2f mousePosition) {
std::string result = "";
sf::Vector2f hoverPos = getPosition();
for (std::pair<std::string, sf::RectangleShape> i: buttons)
{
sf::FloatRect spriteBounds = i.second.getLocalBounds();
sf::FloatRect closeRect;
closeRect.left = i.second.getPosition().x;
closeRect.top = i.second.getPosition().y;
closeRect.width = spriteBounds.width;
closeRect.height = spriteBounds.height;
if (closeRect.contains(mousePosition.x - hoverPos.x,mousePosition.y - hoverPos.y))
{
return i.first;
}
}
return result;
}
void Player::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
target.draw(txtCash, states);
}
void Player::play()
{
for (auto&& i: characters)
{
i.play();
}
}
void Player::update(sf::Time deltaTime)
{
updateTxt();
if (frozenLeft==0)
{
for (auto&& i: characters)
{
sf::Vector2f movement(0.f, 0.f);
if (i.currentAnimationIndex==efc::DIR_LEFT)
movement = sf::Vector2f (-10.f, 0.f);
else if (i.currentAnimationIndex==efc::DIR_RIGHT)
movement = sf::Vector2f (10.f, 0.f);
else if (i.currentAnimationIndex==efc::DIR_UP)
movement = sf::Vector2f (0.f, -10.f);
else if (i.currentAnimationIndex==efc::DIR_DOWN)
movement = sf::Vector2f (0.f, 10.f);
i.update(deltaTime);
}
} else{
characters[0].currentAnimationIndex=efc::DIR_DOWN;
}
}
std::array<int,2> Player::getMovements(int diceResult)
{
return characters[0].getMovements(diceResult);
}
void Player::setFigurePos(int pos)
{
characters[0].setBoardPosition(pos);
}
void Player::restartPlayer(){
food = 0;
cash = 0;
energy = 0;
faith = 0;
}
void Player::setHuman(bool newHuman)
{
human = newHuman;
setSpriteAI();
}
void Player::swapHuman()
{
if (human)
{
setHuman(false);
return;
} else {
setHuman(true);
return;
}
}
void Player::setSpriteAI()
{
if (human)
spriteAI.setTexture(textures->textureButtonHuman);
else
spriteAI.setTexture(textures->textureButtonCpu);
std::array<std::array<int,2>,4> spriteHumanPos =
{
{
{{220,450}}, {{1050,450}},
{{140,600}}, {{1110, 600}}
}
};
sf::Vector2f spriteHumanPosNew(spriteHumanPos[number][0],spriteHumanPos[number][1]);
spriteAI.setPosition(spriteHumanPosNew);
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Jun 17, 10:34 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70109
Default Alt Text
(32 KB)

Event Timeline