Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
34 KB
Referenced Files
None
Subscribers
None
diff --git a/assets/audio/game.ogg b/assets/audio/game.ogg
index 3a986ec..bc47df6 100644
Binary files a/assets/audio/game.ogg and b/assets/audio/game.ogg differ
diff --git a/assets/audio/game.ogg b/assets/audio/game.old.ogg
similarity index 100%
copy from assets/audio/game.ogg
copy to assets/audio/game.old.ogg
diff --git a/assets/audio/letsbegin.wav b/assets/audio/letsbegin.wav
new file mode 100644
index 0000000..f99ae9f
Binary files /dev/null and b/assets/audio/letsbegin.wav differ
diff --git a/assets/audio/menu.ogg b/assets/audio/menu-2.ogg
similarity index 100%
copy from assets/audio/menu.ogg
copy to assets/audio/menu-2.ogg
diff --git a/assets/audio/menu.ogg b/assets/audio/menu.ogg
index eedd851..3fb1b3a 100644
Binary files a/assets/audio/menu.ogg and b/assets/audio/menu.ogg differ
diff --git a/assets/img/background_land.png b/assets/img/background_land.png
index b01a7ac..24ac73d 100644
Binary files a/assets/img/background_land.png and b/assets/img/background_land.png differ
diff --git a/assets/img/letsbegin.png b/assets/img/letsbegin.png
new file mode 100644
index 0000000..5f7d8f4
Binary files /dev/null and b/assets/img/letsbegin.png differ
diff --git a/cardslist.cpp b/cardslist.cpp
new file mode 100644
index 0000000..e6704d6
--- /dev/null
+++ b/cardslist.cpp
@@ -0,0 +1,6 @@
+#include "cardslist.h"
+
+CardsList::CardsList(int elementNumber)
+{
+ amount = 32;
+}
diff --git a/cardslist.h b/cardslist.h
new file mode 100644
index 0000000..be29c4c
--- /dev/null
+++ b/cardslist.h
@@ -0,0 +1,14 @@
+#ifndef CARDSLIST_H
+#define CARDSLIST_H
+
+
+class CardsList
+{
+public:
+ CardsList(int elementNumber);
+ int amount;
+
+
+};
+
+#endif // CARDSLIST_H
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index d1402af..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,6 +0,0 @@
-pagan-board (1.0-1) precise; urgency=low
-
- * Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
-
- -- bluszcz <bluszcz@bluszcz.net> Sat, 06 Feb 20166 21:23:34 +0100
-
diff --git a/debian/control b/debian/control
deleted file mode 100644
index c407c77..0000000
--- a/debian/control
+++ /dev/null
@@ -1,15 +0,0 @@
-Source: pagan-board
-Section: games
-Priority: optional
-Maintainer: Bluszcz <bluszcz@bluszcz.net>
-Build-Depends: debhelper (>= 9), qtbase5-dev, qtbase5-dev-tools, qt5-qmake
-Standards-Version: 3.9.6
-Homepage: https://github.com/bluszcz/pagan-board
-
-Package: pagan-board
-Architecture: any
-Depends: libqt5gui5, libqt5widgets5, libqt5core5a, ${misc:Depends}, ${shlibs:Depends}
-Description: Game
- SFML / Pagan / Board Linux
- Etc etc
-
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 1d3c8af..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/make -f
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/qmake.mk
diff --git a/game.cpp b/game.cpp
index 606ffcc..0b1a161 100644
--- a/game.cpp
+++ b/game.cpp
@@ -1,744 +1,728 @@
#include "game.h"
namespace efc {
int initScreenX = 1360;
int initScreenY = 768;
int currentSeason = 0;
int month = 0;
void Game::initBoard()
{
// Grass tile starts at 342 and has 11 tiles
// int level[256];
// int level[256];
// Structure of the board
/*
{
342, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
80, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 }
*/
// Fill the array
for (int i=0;i<256;i++)
{
int grass = (rand() % 10) + 1;
level[i] = 342 + grass;
level[i] = level[i];
}
// level[0] = 441;
// level[240] = 0;
// level[255] = 0;
// level[15] = 0;
level[8] = 813;
level[24] = 803;
level[40] = 803;
level[56] = 803;
level[72] = 803;
level[88] = 801;
level[167] = 809;
level[183] = 803;
level[199] = 803;
level[215] = 803;
level[231] = 803;
level[247] = 812;
level[112] = 811;
for (int i=113;i<117;i++)
level[i] = 816;
level[117] = 815;
level[138] = 800;
for (int i=139;i<143;i++)
level[i] = 816;
level[143] = 814;
map.load(&textures, sf::Vector2u(efc::TILE_SIZE, efc::TILE_SIZE), level, efc::BOARD_SIZE, efc::BOARD_SIZE);
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.04f,0.060f, 1.0f, 1.0f));
viewTiles.setViewport(sf::FloatRect(0.15f,0.1f, 1.0f, 1.0f));
viewGui.setViewport(sf::FloatRect(0.806f,0.066f, 1, 1));
selector.changeColor(turn); //This is only for the test TODO: remove
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;
PlayerHud playerHud1(&textures, std::rand() % 80, &gameFont, 32,0);
PlayerHud playerHud2(&textures, std::rand() % 30, &gameFont, 32,1);
PlayerHud playerHud3(&textures, std::rand() % 60, &gameFont, 32,2);
PlayerHud playerHud4(&textures, std::rand() % 50, &gameFont, 32,3);
players[0] = playerHud1;
players[1] = playerHud2;
players[3] = playerHud3;
players[2] = playerHud4;
players[0].setActive(true);
setCurrentNeighbours();
// roundDice.throwDiceSix();
diceResultPlayer = 6;
players[turn].characters[0].diceResult = diceResultPlayer;
roundDice.setColor(turn);
}
void Game::setCurrentNeighbours ()
{
currentNeighbours = players[turn].getNeighbours();
}
void Game::loadAssets()
{
if (!textureFaces.loadFromFile("assets/img/faces.jpg"))
std::exit(1);
if (!textureTiles.loadFromFile("assets/img/zw-tilesets/_MAP.png"))
std::exit(1);
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 (!textureBackgroundArt.loadFromFile("assets/img/background_land.png"))
std::exit(1);
spriteBackgroundArt.setTexture(textureBackgroundArt);
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);
-
-
menuTxt.setFont(menuFont);
menuTxt.setCharacterSize(60);
menuTxt.setString(gameTitle);
int width = menuTxt.getLocalBounds().width;
int height = menuTxt.getLocalBounds().height;
menuTxt.setPosition(400-(width/2),300-(height/2)-150);
- menuTxt.setColor(sf::Color(55, 255, 35, 85));
+ menuTxt.setColor(sf::Color(255, 255, 255, 85));
}
-
void Game::showMenu()
{
musicBackground.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.setVolume(20);
musicGame.play();
-
musicGame.setLoop(true);
sfx.playLetsBegin();
std::cout << "lets begin" << std::endl;
- currentState = state_roll_dice;
+ 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);
if (boardDiamonds.ifFieldIsEmpty(mousePos)==false)
{
sfx.playCollect();
if (boardDiamonds.getNumberForField(mousePos)==4)
{
players[turn].cash += 1;
};
std::cout << "cash " << players[turn].cash << " " << " for " << turn << " " << boardDiamonds.getNumberForField(mousePos) << " result" << std::endl;
-
// After this no more visible
boardDiamonds.collectField(mousePos);
}
int *possibleExit = std::find(std::begin(efc::possibleExits),
std::end(efc::possibleExits), mousePos);
if (possibleExit != efc::possibleExits+4) {
// std::cerr << "Found hahahah" << mousePos << std::endl;
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);
}
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;
}
}
else if (currentState==state_gui_elem)
{
std::string resultCommand = guiSelectBuilding.getElem(posFull);
if (resultCommand.find("elem_")==0)
{
std::string resultCommandWrapped = "build_" + resultCommand;
command(resultCommandWrapped);
} else if (resultCommand.find("close_gui")==0)
{ command(resultCommand);}
}
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),
window(sf::VideoMode(efc::initScreenX, efc::initScreenY), "Pagan Board"),
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),
guiSelectBuilding(&textures),
character(&textures, 3),
turn(0),
gameTitle("pagan board"),
roundDice(players),
roundNumber(1),
guiRoundDice(&textures),
boardDiamonds(&textures)
{
- int gWidth = guiSelectBuilding.rectangle.getLocalBounds().width;
- int gHeight = guiSelectBuilding.rectangle.getLocalBounds().height;
- int borderLeft = 31;
- int borderRight = 28;
- int borderTop = 39;
- int borderBottom = 39;
- int guiWidth = 128;
- int guiStartPosTmp[4][2] = {
- {borderLeft+3,borderTop+2},
- {screenSize.x - guiWidth - borderRight - gWidth-4,borderTop+2},
- {borderLeft+3,screenSize.y-gHeight-borderBottom-4} ,
- {screenSize.x - guiWidth - borderRight - gWidth-4,
- screenSize.y-gHeight-borderBottom-4}};
- for (int i=0;i<4;i++)
- {
- for (int j=0;j<4;j++)
- guiStartPos[i][j] = guiStartPosTmp[i][j];
- }
numberFinishedPlayers = 0;
sf::Clock frameClock;
guiRoundDice.active = true;
showPlayerBoardElems = false;
window.setVerticalSyncEnabled(true);
- Hover hover;
- GuiWindow guiWindow(&textures);
+
std::srand (time(NULL));
loadAssets();
initBoard();
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");
}
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;
players[turn].elems.displayNeighbours = false;
} else {
showPlayerBoardElems = true;
players[turn].elems.displayNeighbours = true;
}
}
if (event.type == sf::Event::MouseButtonReleased)
{
if (event.mouseButton.button == sf::Mouse::Left)
handleLeftClick(localPosition, localPositionGui,
localPositionFull, mousePos);
}
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);
}
}
update(frameTime);
render();
}
}
void Game::update(sf::Time frameTime) {
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);
}
}
for (int i=0;i<4;i++)
{
players[i].play();
}
for (int i=0;i<4;i++)
{
players[i].update(frameTime, busyTiles);
}
+ if (currentState==state_lets_begin)
+ {
+ downTimeCounter += frameTime.asSeconds();
+ std::cout << downTimeCounter << std::endl;
+
+ 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();
-
-// command(result);
}
void Game::nextPlayer(){
-// boardDiamonds.reorder();
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();
}
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();
-// roundDice.throwDiceSix();
-// diceResultPlayer = roundDice.throwDiceSix();
- diceResultPlayer = 6;
-
+ diceResultPlayer = 6;
roundDice.setDiceTexture(diceResultPlayer);
-// std::cout << "DEBUG " << turn << " "<< diceResultPlayer << std::endl;
players[turn].characters[0].diceResult = diceResultPlayer;
-// std::cout << roundNumber << " " << roundNumber % 16 << std::endl;
groupHud.setRoundName(roundNumber);
groupHud.setSeason(currentSeason);
groupHud.setMonthName(month%4);
-// setBusyTiles();
currentState = state_roll_dice;
roundDice.setColor(turn);
-
}
void Game::drawPlayersGui(){
for (int i=0;i<4;i++)
{
window.draw(players[i]);
}
-
-// window.draw(seasons[currentSeason]);
}
void Game::drawSquares() {
if (showPlayerBoardElems)
{
window.draw(selector);
}
}
void Game::drawBaseGame()
{
window.setView(viewTiles);
// window.draw(map);
for (int i=0;i<4;i++)
{
window.draw(players[i].elems);
}
drawSquares();
window.setView(viewGui);
window.setView(viewTiles);
}
void Game::drawCharacters(){
// window.setView(viewFull);
window.setView(viewTiles); // Yeah Katia's inspiration
window.draw(gameBackground);
window.setView(viewFull);
window.draw(spriteBackgroundArt);
window.draw(roundDice.spriteDice);
window.setView(viewTiles);
drawSquares();
if (currentState==state_game)
{
std::array<int,2> currentMovements = players[turn].characters[0].getMovements(diceResultPlayer);
if (currentMovements[1]>-1)
window.draw(nextRotateElem);
if (currentMovements[0]>-1)
window.draw(prevRotateElem);
}
for (int i=0;i<4;i++)
{
for (auto&& j: players[i].characters)
{
if (currentState==state_game)
j.drawMovements = true;
else
j.drawMovements = false;
window.draw(j);
}
}
}
void Game::render()
{
window.clear();
if (currentState==state_game)
{
window.setView(viewFull);
window.draw(spriteBackgroundDark);
window.setView(viewTiles);
drawBaseGame();
drawCharacters();
window.draw(boardDiamonds);
window.setView(viewFull);
drawPlayersGui();
+ window.setView(viewFull);
+ window.draw(groupHud);
+
} else if (currentState==state_roll_dice) {
window.setView(viewFull);
window.draw(spriteBackgroundDark);
window.setView(viewTiles);
drawBaseGame();
drawCharacters();
window.draw(boardDiamonds);
window.setView(viewFull);
drawPlayersGui();
+ window.setView(viewFull);
+ window.draw(groupHud);
} else if (currentState==state_gui_elem) {
window.setView(viewFull);
window.draw(spriteBackgroundDark);
drawBaseGame();
drawCharacters();
window.draw(guiSelectBuilding);
+ window.setView(viewFull);
+ window.draw(groupHud);
} else if (currentState==state_menu) {
-
- window.draw(menuBackground);
window.draw(menuTxt);
- window.draw(groupHud);
-
+ } else if (currentState==state_lets_begin) {
+ window.setView(viewFull);
+ window.draw(spriteBackgroundDark);
+ window.setView(viewTiles);
+ drawBaseGame();
+ drawCharacters();
+ window.draw(boardDiamonds);
window.setView(viewFull);
-
+ drawPlayersGui();
+ window.draw(spriteLestBegin);
} else if (currentState==state_gui_end_round){
window.setView(viewFull);
window.draw(spriteBackgroundDark);
drawBaseGame();
window.draw(guiRoundDice);
+ window.setView(viewFull);
+ window.draw(groupHud);
}
- window.setView(viewFull);
- window.draw(groupHud);
+
window.display();
}
void Game::command(std::string command){
// std::cout << command << std::endl;
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.find("elem_")==0)
// {
// if (currentState==state_gui_elem)
// {
// int buildingType = std::stoi(command.substr(5));
// std::string descTxt = textures.tilesTxt[buildingType];
// char priceTxtChar [100];
// std::string priceTxt = priceTxtChar;
// char costTxtChar [100];
// std::string costTxt = costTxtChar;
// guiSelectBuilding.setDescriptionTxt(priceTxt + costTxt + "\n"+descTxt);
// guiSelectBuilding.descriptionActive = true;
// }
// }
if (command=="end_turn")
nextPlayer();
// if (command.find("build_")==0)
// {
// int buildingType = std::stoi(command.substr(11));
// bool purchaseResult = players[turn].addElem(selectedPos, buildingType);
// if (purchaseResult)
// {
// currentState = state_game;
// setCurrentNeighbours();
// guiSelectBuilding.active = false;
// sfxDone.play();
// }
// }
}
sf::Vector2f Game::getMousePos(){
sf::Vector2i mousePosTmp(sf::Mouse::getPosition(window));
sf::Vector2f mousePosition(window.mapPixelToCoords(mousePosTmp,viewTiles));
return mousePosition;
}
void Game::setBusyTiles() {
busyTiles.clear();
for (int i: efc::terrainArray)
{
busyTiles.insert(i);
}
for (int i=0;i<4;i++)
{
for (int j:players[i].getBusy())
{
busyTiles.insert(j);
}
}
-
-
-
-
-
}
}
diff --git a/game.h b/game.h
index d30cde7..9f9481e 100644
--- a/game.h
+++ b/game.h
@@ -1,173 +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"
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;
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;
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);
- int guiStartPos[4][2];
+// int guiStartPos[4][2];
std::set<int> busyTiles;
void setBusyTiles();
int diceResultPlayer;
int numberFinishedPlayers;
RotateElem nextRotateElem;
RotateElem prevRotateElem;
void endGame();
BoardDiamondSeq boardDiamonds;
SoundFX sfx;
+ float downTimeCounter;
+
};
}
#endif // GAME_H
diff --git a/pagan_board.pro b/pagan_board.pro
index c17cbc0..e5e4836 100644
--- a/pagan_board.pro
+++ b/pagan_board.pro
@@ -1,73 +1,75 @@
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 \
guichoosebuilding.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
+ pile.cpp \
+ cardslist.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 \
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
+ pile.h \
+ cardslist.h
OTHER_FILES += \
CREDITS.md
QMAKE_CXXFLAGS += -std=gnu++0x
diff --git a/soundfx.cpp b/soundfx.cpp
index f977feb..6ee8139 100644
--- a/soundfx.cpp
+++ b/soundfx.cpp
@@ -1,23 +1,24 @@
#include "soundfx.h"
SoundFX::SoundFX()
{
if (!soundCollectBuffer.loadFromFile("assets/audio/collect.wav"))
exit(-1);
soundCollect.setBuffer(soundCollectBuffer);
+ soundCollect.setVolume(20);
if (!soundLetsBeginBuffer.loadFromFile("assets/audio/letsbegin.ogg"))
exit(-1);
soundLetsBegin.setBuffer(soundLetsBeginBuffer);
soundLetsBegin.setVolume(20);
}
void SoundFX::playCollect()
{
soundCollect.play();
}
void SoundFX::playLetsBegin()
{
std::cout << "playing.... begin lets" << std::endl;
soundLetsBegin.play();
}
diff --git a/textureholder.cpp b/textureholder.cpp
index 3d1091f..f730b52 100644
--- a/textureholder.cpp
+++ b/textureholder.cpp
@@ -1,99 +1,102 @@
#include "textureholder.h"
namespace efc {
std::set<int> getTerrainSet() {
std::set<int> terrain;
for (int i: efc::terrainArray)
{
terrain.insert(i);
}
return terrain;
};
}
TextureHolder::TextureHolder()
{
if (!textureGameBackground.loadFromFile("assets/img/game-background.png"))
std::exit(1);
if (!textureTiles.loadFromFile("assets/img/zw-tilesets/_MAP.png"))
std::exit(1);
if (!textureFaces.loadFromFile("assets/img/faces.jpg"))
std::exit(1);
if (!textureGui.loadFromFile("assets/img/gui.png"))
std::exit(1);
if (!textureSymbols.loadFromFile("assets/img/symbols.png"))
std::exit(1);
if (!textureSeasons.loadFromFile("assets/img/seasons.png"))
std::exit(1);
if (!textureCharacters.loadFromFile("assets/img/characters.png"))
std::exit(1);
if (!backgroundDark.loadFromFile("assets/img/background_dark.png"))
std::exit(1);
if (!textureBoardDiamond.loadFromFile("assets/img/board_diamonds.png"))
std::exit(1);
if (!textureMenu.loadFromFile("assets/img/background_new.png"))
std::exit(1);
+ if (!textureLetsBegin.loadFromFile("assets/img/letsbegin.png"))
+ std::exit(1);
+
int defaultArray[5][8] = {
//Cash Food Energy Faith
{10, 2, 0, 0, 0, 0, 0, 0}, // base
{10, 1, 2, 0, 0, 5, 0, 0}, // windmill
{15, 0, 0, 2, 2, 0, 0, 0}, // granary
{20, 5, 4, 0, 4, 0, 0, 0}, // marketplace
{5, 0, 2, 0, 0, 0, 0, 2} // monasterium
};
int defaultFields[5] = {443, 651, 442, 585, 1100};
/*
* Array with description of the field
* global rule = even indexes are price, odd - monthly cost
* [0] - price in cash
* [1] - monthly cash cost
* [2] - price - in food
* [3] - monthly food cost
* [4] - price in energy
* [5] - monthly energy cost
* [6] - price in faith
* [7] - monthly cost in faith
*
*/
int counter = 0;
for (int i: defaultFields)
{
std::map<int, int> params;
for (int j=0;j<8;j++)
{
params.insert({j, defaultArray[counter][j]});
}
// params.insert({0, 10});
// params.insert({1, 2});
// params.insert({2, 10});
// params.insert({3, 0});
// params.insert({4, 10});
// params.insert({5, 0});
// params.insert({6, 0});
// params.insert({7, 0});
tilesDescription.insert({i, params});
counter++;
};
tilesTxt.insert({443, "Your base."});
tilesTxt.insert({651, "Windmill, produces energy.\nEnergy is a basic resource in a game,\nneeded by other buildings to running them."});
tilesTxt.insert({442, "Granary, food storehouse.\nFood gives your people ability to live.\nWithout the food your people will face\na death by starvation."});
tilesTxt.insert({585, "Marketplace, generates cash.\nProvides your tribe trading area.\nToday's offer - dog's bone."});
tilesTxt.insert({1100, "Monasterium, increase your faith.\nAs we all know, our world is being ruled\nby four ancient gods..."});
}
diff --git a/textureholder.h b/textureholder.h
index 4577576..1e32d8a 100644
--- a/textureholder.h
+++ b/textureholder.h
@@ -1,37 +1,38 @@
#ifndef TEXTUREHOLDER_H
#define TEXTUREHOLDER_H
#include <set>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "data.h"
namespace efc {
std::set<int> getTerrainSet();
}
class TextureHolder
{
public:
TextureHolder();
sf::Texture textureTiles;
sf::Texture textureFaces;
sf::Texture textureGui;
sf::Texture textureMenu;
sf::Texture textureSymbols;
sf::Texture textureSeasons;
sf::Texture backgroundDark;
sf::Texture textureCharacters;
sf::Texture textureGameBackground;
sf::Texture textureBoardDiamond;
+ sf::Texture textureLetsBegin;
std::map<int, std::map<int, int>> tilesDescription;
std::map<int, std::string> tilesTxt;
};
#endif // TEXTUREHOLDER_H

File Metadata

Mime Type
text/x-diff
Expires
Fri, Jun 19, 8:16 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
71636
Default Alt Text
(34 KB)

Event Timeline