Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F132115
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
41 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/calendar.pagan b/calendar.pagan
new file mode 100644
index 0000000..8c2dba4
--- /dev/null
+++ b/calendar.pagan
@@ -0,0 +1,73 @@
+/*
+ * Pagan
+ *
+ * $OpenBSD: calendar.pagan,v 1.2 2002/03/20 22:53:40 mickey Exp $
+ */
+
+#ifndef _calendar_pagan_
+#define _calendar_pagan_
+#include <iostream>
+
+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"}}};
+
+
+
+#endif /* !_calendar_pagan_ */
diff --git a/character.cpp b/character.cpp
index 6b86596..f1dd554 100644
--- a/character.cpp
+++ b/character.cpp
@@ -1,315 +1,320 @@
#include "character.h"
/*!
* \brief Character::getMovements
* \return
*/
std::array<int,2> Character::getMovements(int howFar)
{
std::array<int,2> myArray;
if (howFar==7)
{
return std::array<int,2> {-1,-1};
}
if (active==true)
{
// std::cout << "howfar: " <<howFar <<std::endl;
int indexRight = boardPosition;
for (int i=boardPosition;i<=boardPosition+howFar-1;i++)
{
moveRight = indexRight;
if (indexRight==-1)
break;
indexRight = efc::boards[indexRight][1];
// std::cout << " howfar" << howFar << " index R" << indexRight
// << " move L " << moveLeft << " move R " << moveRight << " dice " << diceResult
// << std::endl;
if (indexRight==-2)
{
indexRight = moveRight;
break;
}
if (indexRight==-1)
break;
}
moveRight = indexRight;
int indexLeft = boardPosition;
for (int i=boardPosition;i>=boardPosition-howFar+1;i--)
{
moveLeft = indexLeft;
if (indexLeft==-1)
break;
indexLeft = efc::boards[indexLeft][0];
// std::cout << " howfar" << howFar << " index l " << indexLeft
// << " move L " << moveLeft << " move R " << moveRight << " dice " << diceResult
// << std::endl;
if (indexLeft==-2)
{
indexLeft = moveLeft;
break;
}
if (indexLeft==-1)
break;
}
moveLeft = indexLeft;
myArray = {moveLeft,moveRight};
}
else
{
myArray = {-1,-1};
}
// std::cout << "howfar: " <<howFar << std::endl;
return myArray;
}
void Character::setBoardPosition(int playerNumber)
{
Elem::setBoardPosition(playerNumber);
move(0,-20);
}
void Character::setDir(int direction)
{
if (direction==efc::DIR_LEFT)
currentAnimation = &walkingAnimationLeft;
}
void Character::setDir()
{
setDir(currentAnimationIndex);
}
void Character::setDirIndex(int direction)
{
currentAnimationIndex = direction;
}
void Character::play()
{
// animatedSprite.play(*currentAnimation);
animatedSprite.play(animations[currentAnimationIndex]);
sf::Vector2f a(getPosition());
sf::Vector2i position(efc::getCords(a));
// std::cout << a.x << " " << a.y << " "
// << position.x << " " << position.y << " pos > "
// << getBoardPosition() << std::endl;
}
Character::Character(TextureHolder *textures, int playerNumber):
animatedSprite(sf::seconds(0.2), true, false),
nextRedirect(0.f)
{
drawMovements = false;
this->textures = textures;
int offset = playerNumber*16;
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));
walkingAnimationDown.setSpriteSheet(textures->textureCharacters);
walkingAnimationDown.addFrame(sf::IntRect(offset, 0, 16, 24));
walkingAnimationDown.addFrame(sf::IntRect(offset, 24, 16, 24));
walkingAnimationRight.setSpriteSheet(textures->textureCharacters);
walkingAnimationRight.addFrame(sf::IntRect(offset, 48, 16, 24));
walkingAnimationRight.addFrame(sf::IntRect(offset, 72, 16, 24));
walkingAnimationLeft.setSpriteSheet(textures->textureCharacters);
walkingAnimationLeft.addFrame(sf::IntRect(offset, 96, 16, 24));
walkingAnimationLeft.addFrame(sf::IntRect(offset, 120, 16, 24));
walkingAnimationUp.setSpriteSheet(textures->textureCharacters);
walkingAnimationUp.addFrame(sf::IntRect(offset, 144, 16, 24));
walkingAnimationUp.addFrame(sf::IntRect(offset, 168, 16, 24));
currentAnimation = &walkingAnimationRight;
leftChar.setTexture(textures->textureCharacters);
leftChar.setTextureRect(sf::IntRect(offset, 96, 16, 24));
rightChar.setTexture(textures->textureCharacters);
rightChar.setTextureRect(sf::IntRect(offset, 48, 16, 24));
leftChar.scale(0.75,0.75);
rightChar.scale(0.75,0.75);
+// 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();
// sf::Vector2f positions[4] = {
// sf::Vector2f(0, 0),
// sf::Vector2f(20, 40),
// sf::Vector2f(20, 240),
// sf::Vector2f(40, 240)
// };
std::array<int, 4> boardPositions{0,15,255-15,255};
// std::cout << "define " << playerNumber << std::endl;
setBoardPosition(boardPositions[playerNumber]);
}
void Character::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
target.draw(animatedSprite, states);
if ((active==true) && (drawMovements==true))
{
if (moveLeft>-1)
{
target.draw(leftChar);
}
if (moveRight>-1)
{
target.draw(rightChar);
}
}
}
void Character::update(sf::Time deltaTime)
{
sf::Vector2f a(getPosition());
sf::Vector2i position(efc::getCords(a));
nextRedirect -= deltaTime.asSeconds();
if (nextRedirect<0)
{
int number = rand() % 2;
if ((currentAnimationIndex==efc::DIR_LEFT) || (currentAnimationIndex==efc::DIR_RIGHT))
{
if (number==0){
setDirIndex(efc::DIR_DOWN);
setDir();
} else if (number==1)
{
setDirIndex(efc::DIR_UP);
setDir();
}
} else if ((currentAnimationIndex==efc::DIR_UP) || (currentAnimationIndex==efc::DIR_DOWN))
{
if (number==0){
setDirIndex(efc::DIR_LEFT);
setDir();
} else if (number==1)
{
setDirIndex(efc::DIR_RIGHT);
setDir();
}
}
nextRedirect = rand() % 4;
}
if (currentAnimationIndex==efc::DIR_UP)
{
if (position.y<2)
{
setDirIndex(efc::DIR_DOWN);
setDir();
}
} else if (currentAnimationIndex==efc::DIR_DOWN)
{
if (position.y>efc::BOARD_SIZE-1)
{
setDirIndex(efc::DIR_UP);
setDir();
}
} else if (currentAnimationIndex==efc::DIR_LEFT)
{
if (position.x<2)
{
setDirIndex(efc::DIR_RIGHT);
setDir();
}
} else if (currentAnimationIndex==efc::DIR_RIGHT)
{
if (position.x>efc::BOARD_SIZE-1)
{
setDirIndex(efc::DIR_LEFT);
setDir();
}
}
animatedSprite.update(deltaTime);
std::array<int,2> movements(getMovements(diceResult));
// int left = movements[0];
// int right = movements[1];
if (active==true)
{
if (moveLeft>-1)
{
// sf::Vector2i cordsLeft(efc::transPosition(moveLeft));
sf::Vector2i neededCords(efc::transPosition(moveLeft));
sf::Vector2f newPos(efc::getScreenPos(neededCords));
leftChar.setPosition(newPos.x+efc::TILE_SIZE/4,newPos.y);
+
}
if (moveRight>-1)
{
// sf::Vector2i cordsRight(efc::transPosition(moveRight));
sf::Vector2i neededCords(efc::transPosition(moveRight));
sf::Vector2f newPos(efc::getScreenPos(neededCords));
rightChar.setPosition(newPos.x+efc::TILE_SIZE/4,newPos.y);
+
}
// std::cout << " dice " << diceResult<< moveLeft << " " << moveRight << std::endl;
}
}
sf::FloatRect Character::getLocalBounds() const
{
return sf::FloatRect(0.f, 0.f, 0, 0);
}
sf::FloatRect Character::getGlobalBounds() const
{
return getTransform().transformRect(getLocalBounds());
}
diff --git a/deerportal.pro b/deerportal.pro
index 2e7e14d..0d8a51a 100644
--- a/deerportal.pro
+++ b/deerportal.pro
@@ -1,88 +1,88 @@
TEMPLATE = app
CONFIG += console
CONFIG += release
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += c++11
SOURCES += main.cpp \
game.cpp \
tilemap.cpp \
selector.cpp \
playerhud.cpp \
boardelem.cpp \
boardelems.cpp \
textureholder.cpp \
hover.cpp \
guiwindow.cpp \
purchaseguielem.cpp \
rounddice.cpp \
guirounddice.cpp \
grouphud.cpp \
animation.cpp \
animatedsprite.cpp \
character.cpp \
data.cpp \
rotateelem.cpp \
boarddiamond.cpp \
boarddiamondseq.cpp \
elem.cpp \
soundfx.cpp \
card.cpp \
pile.cpp \
cardslist.cpp \
command.cpp \
cardsdeck.cpp
LIBS += -lsfml-window -lsfml-system -lsfml-graphics -lsfml-audio
DESTDIR = debian/deerportal/opt/deerportal/
assets.path = /opt/deerportal/assets
assets.files = assets/*
desktop.path = /usr/share/applications
desktop.files = deerportal.desktop
icon.path = /usr/share/icons/hicolor/512x512/apps
icon.files = assets/img/deerportal.png
INSTALLS += assets
INSTALLS += desktop
INSTALLS += icon
HEADERS += \
game.h \
tilemap.h \
selector.h \
playerhud.h \
boardelem.h \
boardelems.h \
textureholder.h \
hover.h \
guiwindow.h \
purchaseguielem.h \
- guichoosebuilding.h \
elemsdescription.h \
rounddice.h \
guirounddice.h \
grouphud.h \
data.h \
animation.h \
animatedsprite.h \
character.h \
rotateelem.h \
boarddiamond.h \
boarddiamondseq.h \
elem.h \
soundfx.h \
card.h \
pile.h \
cardslist.h \
command.h \
cardsdeck.h
+ calendar.pagan
OTHER_FILES += \
CREDITS.md
QMAKE_CXXFLAGS += -std=gnu++0x -Wpedantic
CONFIG += c++11
diff --git a/game.cpp b/game.cpp
index 20b7e79..a0b3f01 100644
--- a/game.cpp
+++ b/game.cpp
@@ -1,683 +1,693 @@
#include "game.h"
namespace efc {
int initScreenX = 1360;
int initScreenY = 768;
int currentSeason = 1;
int month = 0;
void Game::initBoard()
{
sfxClick.setBuffer(sfxClickBuffer);
sfxDone.setBuffer(sfxDoneBuffer);
// spriteBackground.setTexture(textureBackground);
spriteBackgroundDark.setTexture(textures.backgroundDark);
spriteBackgroundDark.setPosition(0,0);
// gameBackground.setTexture(textures.textureGameBackground);
spriteLestBegin.setTexture(textures.textureLetsBegin);
viewTiles.setViewport(sf::FloatRect(0.15f,0.1f, 1.0f, 1.0f));
viewGui.setViewport(sf::FloatRect(0.806f,0.066f, 1, 1));
groupHud.setFont(&gameFont);
groupHud.setSeason(currentSeason);
groupHud.setRoundName(roundNumber);
// sf::IntRect seasonsRect[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)};
// sf::Sprite season1;
// season1.setTexture(textures.textureSeasons);
// season1.setTextureRect(seasonsRect[0]);
// season1.setPosition(0,400);
// season1.scale(sf::Vector2f(0.25f, 0.25f));
// season1.move(37.5, 30.5);
// season1.setColor(sf::Color(0,255,0,80));
// seasons[0] = season1;
// sf::Sprite season2;
// season2.setTexture(textures.textureSeasons);
// season2.setTextureRect(seasonsRect[1]);
// season2.setPosition(0,400);
// season2.scale(sf::Vector2f(0.25f, 0.25f));
// season2.move(37.5, 30.5);
// season2.setColor(sf::Color(200,200,50,80));
// seasons[1] = season2;
// sf::Sprite season3;
// season3.setTexture(textures.textureSeasons);
// season3.setTextureRect(seasonsRect[2]);
// season3.setPosition(0,400);
// season3.scale(sf::Vector2f(0.25f, 0.25f));
// season3.move(37.5, 30.5);
// season3.setColor(sf::Color(90,90,255,80));
// seasons[2] = season3;
// sf::Sprite season4;
// season4.setTexture(textures.textureSeasons);
// season4.setTextureRect(seasonsRect[3]);
// season4.setPosition(0,400);
// season4.scale(sf::Vector2f(0.25f, 0.25f));
// season4.move(37.5, 30.5);
// season4.setColor(sf::Color(255,0,0,80));
// seasons[3] = season4;
// Initialization of the players
cardsDeck.setFonts(&menuFont);
PlayerHud playerHud1(&textures, &gameFont, 32,0);
PlayerHud playerHud2(&textures, &gameFont, 32,1);
PlayerHud playerHud3(&textures, &gameFont, 32,2);
PlayerHud playerHud4(&textures, &gameFont, 32,3);
players[0] = playerHud1;
players[1] = playerHud2;
players[3] = playerHud3;
players[2] = playerHud4;
players[0].setActive(true);
setCurrentNeighbours();
diceResultPlayer = 6;
players[turn].characters[0].diceResult = diceResultPlayer;
roundDice.setColor(turn);
}
void Game::setCurrentNeighbours ()
{
currentNeighbours = players[turn].getNeighbours();
}
void Game::loadAssets()
{
if (!gameFont.loadFromFile("assets/fnt/metal-mania.regular.ttf"))
{
std::exit(1);
}
if (!menuFont.loadFromFile("assets/fnt/metal-macabre.regular.ttf"))
{
std::exit(1);
}
if (!shaderBlur.loadFromFile("assets/shaders/blur.frag", sf::Shader::Fragment))
std::exit(1);
if (!shaderPixel.loadFromFile("assets/shaders/pixelate.frag", sf::Shader::Fragment))
std::exit(1);
if (!shaderDark.loadFromFile("assets/shaders/dark.frag", sf::Shader::Fragment))
std::exit(1);
if (!textureBackgroundArt.loadFromFile("assets/img/background_land.png"))
std::exit(1);
if (!musicGame.openFromFile("assets/audio/game.ogg"))
std::exit(1);
// if (!musicBackground.openFromFile("assets/audio/wind2.ogg"))
// std::exit(1);
if (!musicMenu.openFromFile("assets/audio/menu.ogg"))
std::exit(1);
if (!sfxClickBuffer.loadFromFile("assets/audio/click.ogg"))
std::exit(1);
if (!sfxDoneBuffer.loadFromFile("assets/audio/done.ogg"))
std::exit(1);
// if (!textureBackground.loadFromFile("assets/img/background.png"))
// std::exit(1);
spriteBackgroundArt.setTexture(textureBackgroundArt);
menuTxt.setFont(menuFont);
menuTxt.setCharacterSize(60);
menuTxt.setString(gameTitle);
int width = menuTxt.getLocalBounds().width;
int height = menuTxt.getLocalBounds().height;
menuTxt.setPosition(1050-(width/2),750-(height/2)-150);
menuTxt.setColor(sf::Color(255, 255, 255, 85));
cardsDeck.setFonts(&gameFont);
for (int i=0;i<4;i++)
{
playersSprites[i].setTexture(textureBackgroundArt);
playersSprites[i].setTextureRect(sf::IntRect(playersSpritesCords[i][0],
playersSpritesCords[i][1], 280, 280));
playersSprites[i].setPosition(playersSpritesCords[i][0], playersSpritesCords[i][1]);
}
}
void Game::showMenu()
{
// musicBackgroun/*d*/.play();
// musicBackground.setLoop(true);
// menuBackground.setTexture(textures.textureMenu);
// musicBackground.setVolume(7);
musicMenu.play();
musicMenu.setLoop(true);
currentState = state_menu;
}
void Game::hideMenu()
{
musicMenu.stop();
}
void Game::showGameBoard()
{
// musicGame.setVolume(20);
musicGame.play();
musicGame.setLoop(true);
sfx.playLetsBegin();
std::cout << "lets begin" << std::endl;
currentState = state_lets_begin;
}
void Game::endGame()
{
currentState = state_end_game;
// musicBackground.stop();
}
void Game::handleLeftClick(sf::Vector2f pos,
sf::Vector2f posGui, sf::Vector2f posFull, int mousePos) {
if (currentState==state_game)
{
std::array<int,2> movements = players[turn].getMovements(diceResultPlayer);
if ((mousePos==movements[0]) || (mousePos==movements[1]))
{
players[turn].setFigurePos(mousePos);
commandManager.processField(mousePos);
const int *possibleExit = std::find(std::begin(efc::endPlayers),
std::end(efc::endPlayers), mousePos);
if (possibleExit != efc::endPlayers+4) {
players[turn].done=true;
numberFinishedPlayers += 1;
if (numberFinishedPlayers > 3)
endGame();
} else {
// std::cerr << "Not found" << std::endl;
}
nextPlayer();
}
// std::string resultCommand = players[turn].getElem(posGui);
// command(resultCommand);
commandManager.processGui(posGui);
}
else if (currentState==state_roll_dice)
{
sf::IntRect diceRect(roundDice.spriteDice.getGlobalBounds());
if (diceRect.intersects(sf::IntRect(posFull.x, posFull.y, 1, 1)))
{
diceResultPlayer = roundDice.throwDiceSix();
players[turn].characters[0].diceResult=diceResultPlayer;
currentState=state_game;
}
}
if (currentState==state_menu)
{
downTimeCounter = 0;
// std::cout << " AA " <<downTimeCounter << std::endl;
hideMenu();
showGameBoard();
}
if (currentState==state_gui_end_round)
{
std::string resultCommand = guiRoundDice.getElem(pos);
command(resultCommand);
}
}
void Game::hideGameBoard()
{
musicGame.play();
}
Game::Game():
screenSize(efc::initScreenX,efc::initScreenY),
viewFull(sf::FloatRect(00, 00, screenSize.x, screenSize.y)),
viewGui(sf::FloatRect(00, 00, screenSize.x, screenSize.y)),
viewTiles(sf::FloatRect(0, 0, 1360, 768)),
selector(efc::TILE_SIZE),
character(&textures, 3),
gameTitle("deerportal"),
roundDice(players),
roundNumber(1),
guiRoundDice(&textures),
boardDiamonds(&textures),
window(sf::VideoMode(efc::initScreenX, efc::initScreenY), "Deerportal - game about how human can be upgraded to the Deer"),
turn(0),
commandManager(*this),
cardsDeck(&textures, &menuFont)
{
playersSpritesCords[0][0] = 202;
playersSpritesCords[0][1] = 76;
playersSpritesCords[1][0] = 562;
playersSpritesCords[1][1] = 76;
playersSpritesCords[3][0] = 202;
playersSpritesCords[3][1] = 436;
playersSpritesCords[2][0] = 562;
playersSpritesCords[2][1] = 436;
textLoading.setString("loading...");
textLoading.setFont(menuFont);
textLoading.setPosition(200,200);
textLoading.setColor(sf::Color::White);
textLoading.setCharacterSize(10);
renderTexture.create(1360,768);
renderTexture.clear(sf::Color::White);
renderTexture.draw(textLoading);
renderTexture.display();
renderSprite.setTexture(renderTexture.getTexture());
numberFinishedPlayers = 0;
sf::Clock frameClock;
guiRoundDice.active = true;
showPlayerBoardElems = false;
window.setVerticalSyncEnabled(true);
std::srand (time(NULL));
window.clear(sf::Color(55,55,55));
renderTexture.draw(textLoading);
window.display();
loadAssets();
textLoading.setFont(menuFont);
textLoading.setPosition(200,200);
textLoading.setColor(sf::Color::White);
textLoading.setCharacterSize(10);
renderTexture.clear(sf::Color::Black);
renderTexture.draw(textLoading);
window.display();
initBoard();
renderTexture.clear(sf::Color::Black);
renderTexture.draw(textLoading);
renderTexture.display();
showMenu();
// run the main loop
while (window.isOpen())
{
sf::Time frameTime = frameClock.restart();
std::string resultCommand = "";
// handle events
sf::Event event;
while (window.pollEvent(event))
{
sf::Vector2i localPositionTmp = sf::Mouse::getPosition(window);
sf::Vector2f localPosition = window.mapPixelToCoords(localPositionTmp,viewTiles);
sf::Vector2f localPositionGui = window.mapPixelToCoords(localPositionTmp,viewGui);
sf::Vector2f localPositionFull = window.mapPixelToCoords(localPositionTmp,viewFull);
int mousePosX = (int)localPosition.x / efc::TILE_SIZE;
int mousePosY = (int)localPosition.y / efc::TILE_SIZE;
int mousePos = efc::transCords(sf::Vector2i(mousePosX, mousePosY));
if(event.type == sf::Event::Closed)
window.close();
// if (currentState==state_gui_elem)
// {
// resultCommand = guiSelectBuilding.getElem(localPositionFull);
// showPlayerBoardElems = false;
// if (resultCommand.find("elem_")==0)
// command(resultCommand);
// else
// command("hide_gui_elem_description");
// }
// Showing mouse hover
if (currentState==state_game)
{
if ((localPosition.x>efc::TILE_SIZE*efc::BOARD_SIZE) || (localPosition.x<0) || (localPosition.y>efc::TILE_SIZE*efc::BOARD_SIZE) || (localPosition.y<0))
{
showPlayerBoardElems = false;
} else {
showPlayerBoardElems = true;
}
}
if ((localPosition.x>=0) && (localPosition.y>=0) && (localPosition.x<=efc::BOARD_SIZE*efc::TILE_SIZE) && (localPosition.y<=efc::BOARD_SIZE*efc::TILE_SIZE))
{
selector.setPosition((int) (localPosition.x / efc::TILE_SIZE)*efc::TILE_SIZE, ((int) localPosition.y / efc::TILE_SIZE)*efc::TILE_SIZE);
}
/*!
* Handling mouse click
*/
if (event.type == sf::Event::MouseButtonReleased)
{
if (event.mouseButton.button == sf::Mouse::Left)
handleLeftClick(localPosition, localPositionGui,
localPositionFull, mousePos);
}
}
update(frameTime);
render(frameTime.asSeconds());
}
}
void Game::update(sf::Time frameTime) {
runningCounter += frameTime.asSeconds();
if (currentState==state_game)
{
std::array<int,2> currentMovements = players[turn].getMovements(diceResultPlayer);
if (currentMovements[0]>-1)
{
prevRotateElem.spriteRotate.setPosition(players[turn].characters[0].leftChar.getPosition());
prevRotateElem.spriteRotate.move(4,16);
prevRotateElem.update(frameTime);
prevRotateElem.setColor(turn);
}
if (currentMovements[1]>-1)
{
nextRotateElem.spriteRotate.setPosition(players[turn].characters[0].rightChar.getPosition());
nextRotateElem.spriteRotate.move(4,16);
nextRotateElem.update(frameTime);
nextRotateElem.setColor(turn);
}
}
cardsDeck.update(frameTime);
for (int i=0;i<4;i++)
{
players[i].play();
players[i].update(frameTime);
}
if (currentState==state_lets_begin)
{
downTimeCounter += frameTime.asSeconds();
spriteLestBegin.setColor(sf::Color(255,255,255,255-(downTimeCounter*35)));
if (downTimeCounter>6)
{
currentState = state_roll_dice;
}
}
}
void Game::nextRound() {
turn = 0;
std::string result = roundDice.drawRound();
roundNumber += 1;
month++;
if (month==13)
month=1;
if (month%4==0)
currentSeason++;
if (currentSeason>3)
currentSeason=0;
if (players[turn].done==true)
nextPlayer();
}
void Game::nextPlayer(){
if (numberFinishedPlayers==4)
{
std::cout << "Everybody Finished!!!" << std::endl;
endGame();
}
if (turn<4)
players[turn].updatePlayer();
else
nextRound();
turn++;
if ((players[turn].done==true) && (turn<4))
{
std::cout << "Player " << turn << " is done" << std::endl;
nextPlayer();
}
if ((turn==4) || (turn>4))
{
nextRound();
}
if (players[turn].frozenLeft>0)
{
players[turn].frozenLeft -= 1;
nextPlayer();
}
selector.changeColor(turn);
for (int i=0;i<4;i++)
{
if (i==turn)
{
players[i].setActive(true);
currentNeighbours = players[i].getNeighbours();
}
else
players[i].setActive(false);
}
sfxClick.play();
diceResultPlayer = 6;
roundDice.setDiceTexture(diceResultPlayer);
players[turn].characters[0].diceResult = diceResultPlayer;
groupHud.setRoundName(roundNumber);
groupHud.setSeason(currentSeason);
groupHud.setMonthName(month%4);
currentState = state_roll_dice;
roundDice.setColor(turn);
}
void Game::drawPlayersGui(){
for (int i=0;i<4;i++)
{
renderTexture.draw(players[i]);
}
}
void Game::drawSquares() {
if (showPlayerBoardElems)
{
renderTexture.draw(selector);
}
}
void Game::drawBaseGame()
{
renderTexture.setView(viewTiles);
// window.draw(map);
for (int i=0;i<4;i++)
{
renderTexture.draw(players[i].elems);
}
drawSquares();
renderTexture.setView(viewGui);
renderTexture.setView(viewTiles);
}
void Game::drawCharacters(float deltaTime){
renderTexture.setView(viewTiles); // Yeah Katia's inspiration
shaderBlur.setParameter("blur_radius", sin(runningCounter*0.01) );
renderTexture.draw(gameBackground);
renderTexture.setView(viewFull);
renderTexture.draw(spriteBackgroundArt, &shaderDark);
spriteBackgroundArt.setColor(sf::Color(255, 255, 255, 208));
shaderBlur.setParameter("blur_radius", 0.5);
// shaderBlur.setParameter("blur_radius", sin(runningCounter*0.01) );
// shaderBlur.setParameter("blur_radius", sin(runningCounter*0.01) );
- shaderPixel.setParameter("pixel_threshold", 0.05);
+ shaderPixel.setParameter("pixel_threshold", sin(runningCounter* 0.05));
renderTexture.draw(spriteBackgroundArt);
spriteBackgroundArt.setColor(sf::Color(255, 255, 255));
+ shaderBlur.setParameter("blur_radius", sin(runningCounter* 0.05)/2);
for (int i=0;i<4;i++)
{
+
+ sf::RectangleShape rectangle(sf::Vector2f(284, 284));
+ rectangle.setPosition(playersSpritesCords[i][0]-2,playersSpritesCords[i][1]-2);
+ rectangle.setFillColor(sf::Color(0, 0, 0,55));
+ renderTexture.draw(rectangle);
if (turn==i)
renderTexture.draw(playersSprites[i]);
else
- renderTexture.draw(playersSprites[i], &shaderDark);
+ renderTexture.draw(playersSprites[i], &shaderBlur);
+
+
+
}
renderTexture.draw(cardsDeck);
renderTexture.draw(roundDice.spriteDice);
renderTexture.setView(viewTiles);
drawSquares();
if (currentState==state_game)
{
std::array<int,2> currentMovements = players[turn].characters[0].getMovements(diceResultPlayer);
if (currentMovements[1]>-1)
renderTexture.draw(nextRotateElem);
if (currentMovements[0]>-1)
renderTexture.draw(prevRotateElem);
}
renderTexture.setView(viewFull);
+ shaderBlur.setParameter("blur_radius", 0.005);
for (int i=0;i<4;i++)
{
for (auto&& j: players[i].characters)
{
if (currentState==state_game)
j.drawMovements = true;
else
j.drawMovements = false;
- renderTexture.draw(j);
+ renderTexture.draw(j, &shaderBlur);
}
}
}
void Game::render(float deltaTime)
{
window.clear();
renderTexture.clear();
if (currentState==state_game)
{
renderTexture.setView(viewFull);
shaderBlur.setParameter("blur_radius", 2);
renderTexture.draw(spriteBackgroundDark, &shaderBlur);
renderTexture.setView(viewTiles);
drawBaseGame();
drawCharacters(deltaTime);
renderTexture.draw(boardDiamonds);
renderTexture.setView(viewFull);
drawPlayersGui();
renderTexture.setView(viewFull);
renderTexture.draw(groupHud);
} else if (currentState==state_roll_dice) {
renderTexture.setView(viewFull);
shaderBlur.setParameter("blur_radius", 2);
renderTexture.draw(spriteBackgroundDark, &shaderBlur);
renderTexture.setView(viewTiles);
drawBaseGame();
drawCharacters(deltaTime);
renderTexture.draw(boardDiamonds);
renderTexture.setView(viewFull);
drawPlayersGui();
renderTexture.setView(viewFull);
renderTexture.draw(groupHud);
} else if (currentState==state_gui_elem) {
renderTexture.setView(viewFull);
shaderBlur.setParameter("blur_radius", 2);
renderTexture.draw(spriteBackgroundDark, &shaderBlur);
drawBaseGame();
drawCharacters(deltaTime);
// window.draw(guiSelectBuilding);
renderTexture.setView(viewFull);
renderTexture.draw(groupHud);
} else if (currentState==state_menu) {
shaderBlur.setParameter("blur_radius", 15);
renderTexture.draw(menuTxt, &shaderBlur);
renderTexture.draw(menuTxt);
// window.draw(menuTxt);
} else if (currentState==state_lets_begin) {
renderTexture.setView(viewFull);
shaderBlur.setParameter("blur_radius", 2);
renderTexture.draw(spriteBackgroundDark, &shaderBlur);
renderTexture.setView(viewTiles);
drawBaseGame();
drawCharacters(deltaTime);
renderTexture.draw(boardDiamonds);
renderTexture.setView(viewFull);
drawPlayersGui();
renderTexture.draw(spriteLestBegin);
} else if (currentState==state_gui_end_round){
renderTexture.setView(viewFull);
renderTexture.draw(spriteBackgroundDark);
drawBaseGame();
renderTexture.draw(guiRoundDice);
renderTexture.setView(viewFull);
renderTexture.draw(groupHud);
}
renderTexture.display();
renderSprite.setTexture(renderTexture.getTexture());
shaderBlur.setParameter("blur_radius", sin(deltaTime)*0.015);
shaderBlur.setParameter("blur_radius", 0.0003);
window.draw(renderSprite, &shaderBlur);
window.display();
}
void Game::command(std::string command){
// if (command=="close_gui")
// {
// guiSelectBuilding.active = false;
// currentState=state_game;
// sfxClick.play();
// }
// if (command=="hide_gui_elem_description")
// {
// if (currentState==state_gui_elem) {
// guiSelectBuilding.descriptionActive = false;
// }
// }
if (command.find("end_of_round")==0)
{
std::string subResult = command.substr(13);
guiRoundDice.active = true;
guiRoundDice.setTitle(subResult);
currentState = state_gui_end_round;
}
if (command=="end_turn")
nextPlayer();
}
sf::Vector2f Game::getMousePos(){
sf::Vector2i mousePosTmp(sf::Mouse::getPosition(window));
sf::Vector2f mousePosition(window.mapPixelToCoords(mousePosTmp,viewTiles));
return mousePosition;
}
}
diff --git a/game.h b/game.h
index 335f4f9..772a818 100644
--- a/game.h
+++ b/game.h
@@ -1,202 +1,202 @@
#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 "command.h"
#include "tilemap.h"
#include "selector.h"
#include "playerhud.h"
#include "textureholder.h"
#include "hover.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 "cardsdeck.h"
-
+#include "calendar.pagan"
//class Command;
namespace efc {
extern int initScreenX;
extern int initScreenY;
class Game
{
public:
sf::Vector2i screenSize;
sf::View viewFull;
sf::View viewGui;
sf::View viewTiles;
private:
Selector selector;
Character character;
std::string gameTitle;
RoundDice roundDice;
int roundNumber;
GuiRoundDice guiRoundDice;
public:
Game();
BoardDiamondSeq boardDiamonds;
sf::RenderWindow window;
sf::RenderTexture renderTexture;
sf::Sprite renderSprite;
PlayerHud players[4];
SoundFX sfx;
public:
int turn;
private:
void initBoard();
void loadAssets();
void drawPlayersGui();
void drawSquares();
void drawMenu();
float runningCounter;
sf::Sprite playersSprites[4] ;
sf::Vector2f getMousePos();
int playersSpritesCords[4][2];
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;
sf::Shader shaderBlur;
sf::Shader shaderPixel;
sf::Shader shaderDark;
TileMap map;
int mapSize;
int level[256];
int levelElems[256];
TextureHolder textures;
std::set<int> currentNeighbours;
void command(std::string command);
int selectedPos;
void update(sf::Time frameTime);
void render(float deltaTime);
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(float deltaTime);
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();
float downTimeCounter;
Command commandManager;
sf::Text textLoading;
public:
CardsDeck cardsDeck;
};
}
#endif // GAME_H
diff --git a/pagan_board.pro b/pagan_board.pro
index 00e4ac8..146dbd7 100644
--- a/pagan_board.pro
+++ b/pagan_board.pro
@@ -1,82 +1,83 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += c++11
SOURCES += main.cpp \
game.cpp \
tilemap.cpp \
selector.cpp \
playerhud.cpp \
boardelem.cpp \
boardelems.cpp \
textureholder.cpp \
hover.cpp \
guiwindow.cpp \
purchaseguielem.cpp \
rounddice.cpp \
guirounddice.cpp \
grouphud.cpp \
animation.cpp \
animatedsprite.cpp \
character.cpp \
data.cpp \
rotateelem.cpp \
boarddiamond.cpp \
boarddiamondseq.cpp \
elem.cpp \
soundfx.cpp \
card.cpp \
pile.cpp \
cardslist.cpp \
command.cpp \
cardsdeck.cpp
LIBS += -lsfml-window -lsfml-system -lsfml-graphics -lsfml-audio
DESTDIR = ../build_release_pagan_board
assets.path = $${DESTDIR}/assets
assets.files = assets/*
INSTALLS += assets
HEADERS += \
game.h \
tilemap.h \
selector.h \
playerhud.h \
boardelem.h \
boardelems.h \
textureholder.h \
hover.h \
guiwindow.h \
purchaseguielem.h \
elemsdescription.h \
rounddice.h \
guirounddice.h \
grouphud.h \
data.h \
animation.h \
animatedsprite.h \
character.h \
rotateelem.h \
boarddiamond.h \
boarddiamondseq.h \
elem.h \
soundfx.h \
card.h \
pile.h \
cardslist.h \
command.h \
- cardsdeck.h
+ cardsdeck.h \
+ calendar.pagan
OTHER_FILES += \
CREDITS.md
QMAKE_CXXFLAGS += -std=gnu++0x -Wpedantic
DISTFILES += \
assets/shaders/blur.frag \
assets/shaders/pixelate.frag \
assets/shaders/dark.frag
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jun 16, 12:28 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
71300
Default Alt Text
(41 KB)
Attached To
Mode
R82 deerportal
Attached
Detach File
Event Timeline