Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
55 KB
Referenced Files
None
Subscribers
None
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0a21f1..dd6b72f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,64 +1,68 @@
#Change this if you need to target a specific CMake version
cmake_minimum_required(VERSION 3.1)
set (CMAKE_CXX_STANDARD 11)
# To unify version handling
file (STRINGS "version.txt" DEERPORTAL_VERSION)
string(REGEX MATCH "^([0-9]+)" DEERPORTAL_VERSION_MAJOR ${DEERPORTAL_VERSION})
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\2" DEERPORTAL_VERSION_MINOR ${DEERPORTAL_VERSION})
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+.*)" "\\3" DEERPORTAL_VERSION_PATCH ${DEERPORTAL_VERSION})
MESSAGE( STATUS "DEERPORTAL_VERSION: " ${DEERPORTAL_VERSION} )
MESSAGE( STATUS "DEERPORTAL_VERSION_MAJOR: " ${DEERPORTAL_VERSION_MAJOR} )
MESSAGE( STATUS "DEERPORTAL_VERSION_MINOR: " ${DEERPORTAL_VERSION_MINOR} )
MESSAGE( STATUS "DEERPORTAL_VERSION_PATCH: " ${DEERPORTAL_VERSION_PATCH} )
# Enable debug symbols by default
# must be done before project() statement
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
endif()
# (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release)
project(myproject)
#target_compile_definitions(DeerPortal PRIVATE FOO=1 BAR=1)
add_definitions(-DDEERPORTAL_VERSION="${DEERPORTAL_VERSION}.${CMAKE_BUILD_TYPE}")
# Set version information in a config.h file
# configure_file(
# "${PROJECT_SOURCE_DIR}/config.h.in"
# "${PROJECT_BINARY_DIR}/config.h"
# )
include_directories("${PROJECT_BINARY_DIR}")
include_directories(${YOUR_DIRECTORY})
# Define sources and executable
set(EXECUTABLE_NAME "DeerPortal")
file( GLOB SRCS src/*.cpp src/*.h )
add_executable(${EXECUTABLE_NAME} ${SRCS})
# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
#Find any version 2.X of SFML
#See the FindSFML.cmake file for additional details and instructions
find_package(SFML 2 REQUIRED network audio graphics window system)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
endif()
set_target_properties(${EXECUTABLE_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_FRAMEWORK_IDENTIFIER org.cmake.ExecutableTarget
RESOURCE "${RESOURCE_FILES}"
)
# Install target
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)
+set (ASSETS_BASE_PATH share/games/deerportal)
+add_definitions(-DBASE_PATH="${CMAKE_INSTALL_PREFIX}")
+add_definitions(-DASSETS_PATH="${CMAKE_INSTALL_PREFIX}/${ASSETS_BASE_PATH}/")
+
install(DIRECTORY assets DESTINATION share/games/deerportal)
# CPack packaging
include(InstallRequiredSystemLibraries)
# set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR "${DEERPORTAL_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${DEERPORTAL_VERSION_MINOR}.${DEERPORTAL_VERSION_PATCH}")
include(CPack)
diff --git a/scripts/jenkins-testing.sh b/scripts/jenkins-testing.sh
index 442104a..46ae57d 100644
--- a/scripts/jenkins-testing.sh
+++ b/scripts/jenkins-testing.sh
@@ -1,4 +1,5 @@
+#!/bin/sh
xdotool search --name Deerportal.*
WINDOWID=`xdotool search --name Deerportal.*`
-xdotool click --window $WINDOWID 1
+xdotool click --window "$WINDOWID" 1
diff --git a/snapcraft.yaml b/snapcraft.yaml
index 4ed20d4..d139475 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -1,30 +1,13 @@
name: deerportal
-version: "0.7.2.dev"
-summary: DeerPortal game
-description: Some description for the game
+version: "0.7.2-pre-snap"
+summary: Deer POrtal" snap
+description: Board game where you need to transfer yourself into the Deer God
grade: stable
confinement: strict
apps:
deerportal:
- command: desktop-launch DeerPortal
-
- plugs:
- - x11
- - opengl
- - pulseaudio
- - desktop
- - desktop-legacy
- - unity7
-
+ command: DeerPortal
parts:
- deer-portal:
+ source-deerportal:
plugin: cmake
- source: https://github.com/deerportal/deerportal.git
- source-branch: cmake-tests
- source-depth: 1
- build-packages:
- - libsfml-dev
- - libgl1-mesa-dri
- - libopenal-dev
-
- after: [desktop-gtk3]
+ source: https://github.com/deerportal/deerportal/archive/v0.7.2-pre-snap.tar.gz
\ No newline at end of file
diff --git a/src/bubble.cpp b/src/bubble.cpp
index dc91b0e..f3182fa 100644
--- a/src/bubble.cpp
+++ b/src/bubble.cpp
@@ -1,41 +1,41 @@
#include <cmath>
#include <array>
#include "bubble.h"
Bubble::Bubble():
state(BubbleState::DICE),
timeCounter(0),
posY(0)
{
spritesBubbles = {{spriteDice, spriteFootSteps}};
- if (!textureDice.loadFromFile("assets/img/bubble_dice.png"))
+ if (!textureDice.loadFromFile(ASSETS_PATH"assets/img/bubble_dice.png"))
std::exit(1);
- if (!textureFootSteps.loadFromFile("assets/img/bubble_footsteps.png"))
+ if (!textureFootSteps.loadFromFile(ASSETS_PATH"assets/img/bubble_footsteps.png"))
std::exit(1);
spritesBubbles[0].setTexture(textureDice);
spritesBubbles[1].setTexture(textureFootSteps);
}
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/src/game.cpp b/src/game.cpp
index 4fabb5a..760f10a 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1,1178 +1,1178 @@
#include "game.h"
#include "particle.h"
#include "calendar.h"
#include <algorithm>
namespace DP {
int initScreenX = 1360;
int initScreenY = 768;
int currentSeason = 1;
int month = 0;
/*!
* \brief The ResultTable struct contains data for the end of the game screen.
*/
struct ResultTable
{
int playerNumber;
int playerResult;
bool reachedPortal;
bool reachedPortalFirst;
ResultTable(int number,int result, bool portal, bool portalFirst) :
playerNumber(number), playerResult(result), reachedPortal(portal), reachedPortalFirst(portalFirst) {}
bool operator < (const ResultTable& otherResult) const
{
if ((playerResult!=otherResult.playerResult) || ((reachedPortal==false) && (otherResult.reachedPortal==false)))
return (playerResult > otherResult.playerResult);
else if (reachedPortalFirst==true){
return true;
} else
{
return false;
}
;
}
};
/*!
* \brief Game::setTxtEndGameAmount orders the results text for the end of the game.
*/
void Game::setTxtEndGameAmount(){
std::string elementNames[4] = {"Water","Earth", "Fire", "Air"};
int width=1360;
// int height = 768;
// int startHeight = 100;
int separator = 40;
std::array<ResultTable, 4> results = {
{
ResultTable(0,players[0].cash, players[0].reachedPortal,players[0].reachedPortalFirst),
ResultTable(1,players[1].cash, players[1].reachedPortal,players[1].reachedPortalFirst),
ResultTable(2,players[2].cash, players[2].reachedPortal,players[2].reachedPortalFirst),
ResultTable(3,players[3].cash, players[3].reachedPortal,players[3].reachedPortalFirst)
}
};
std::vector < ResultTable > resultsVector;
txtSurvivors.clear();
txtLoosers.clear();
for (int i=0;i<4;i++)
{
resultsVector.push_back(results[i]);
};
std::sort(resultsVector.begin(), resultsVector.end());
txtWinner.setFont(gameFont);
txtWinner.setCharacterSize(40);
for (int i=0;i<4;i++)
{
int playerNumber = resultsVector[i].playerNumber;
std::string elementName = elementNames[playerNumber];
sf::Text tmpText;
tmpText.setFont(gameFont);
tmpText.setCharacterSize(25);
tmpText.setString(elementName+ " " + std::to_string(players[playerNumber].cash));
sf::FloatRect rectTxt = tmpText.getLocalBounds();
if (players[playerNumber].reachedPortal==true)
{
int counter = txtSurvivors.size();
tmpText.setPosition((1360/2)-(rectTxt.width/2),200+(counter*separator));
txtSurvivors.push_back(tmpText);
} else
{
int counter = txtLoosers.size();
tmpText.setPosition((width/2)-(rectTxt.width/2),540+(counter*separator));
txtLoosers.push_back(tmpText);
}
}
if (txtSurvivors.size()>0)
{
txtWinner.setString("Winner: " + txtSurvivors[0].getString());
txtSurvivors.erase(txtSurvivors.begin()+0);
}
txtWinner.setCharacterSize(40);
sf::FloatRect rectTxt = txtWinner.getLocalBounds();
txtWinner.setPosition((1360/2)-(rectTxt.width/2),120);
}
void Game::initBoard()
{
time_t t = time(0);
struct tm * now = localtime( & t );
int month = now->tm_mon + 1;
int day = now->tm_mday;
paganHolidayString = getHoliday(month, day);
paganHolidayTxt.setString(paganHolidayString);
sfxClick.setBuffer(sfxClickBuffer);
sfxDone.setBuffer(sfxDoneBuffer);
spriteBackgroundDark.setTexture(textures.backgroundDark);
spriteBackgroundDark.setPosition(0,0);
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);
cardsDeck.setFonts(&gameFont);
spriteBigDiamond.setTexture(textures.textureBigDiamond);
spriteBigDiamond.setPosition(474,342);
spriteBigDiamond.setColor(sf::Color (255, 255, 255,196));
restartGame();
launchNextPlayer();
endGameTxt.setFont(gameFont);
endGameTxt.setString("End of the Game");
endGameTxt.setCharacterSize(30);
sf::FloatRect ss = endGameTxt.getLocalBounds();
endGameTxt.setPosition((1360/2)-(ss.width/2),60);
setTxtEndGameAmount();
bubble.setPosition(players[turn].characters[0].getPosition().x-30,
players[turn].characters[0].getPosition().y-45);
txtSurvivorsLabel.setString("Survivors");
txtSurvivorsLabel.setFont(gameFont);
txtSurvivorsLabel.setCharacterSize(30);
sf::FloatRect rectSurvivors = txtSurvivorsLabel.getLocalBounds();
txtSurvivorsLabel.setPosition((1360/2)-(rectSurvivors.width/2),200);
txtLoosersLabel.setString("Digested by The Elements");
txtLoosersLabel.setFont(gameFont);
txtLoosersLabel.setCharacterSize(30);
sf::FloatRect rectLoosers = txtLoosersLabel.getLocalBounds();
txtLoosersLabel.setPosition((1360/2)-(rectLoosers.width/2),500);
credits.setTxt(0);
}
/*!
* \brief Game::restartGame sets all the variables to the default value
*/
void Game::restartGame()
{
Player playerHud1(&textures, &gameFont,0);
Player playerHud2(&textures, &gameFont,1);
Player playerHud3(&textures, &gameFont,2);
Player playerHud4(&textures, &gameFont,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);
for (int i=0;i<4;i++)
{
players[i].restartPlayer();
players[i].reachedPortal = false;
boardDiamonds.reorder(i);
bubble.setPosition(players[i].characters[0].getPosition().x-30,
players[i].characters[0].getPosition().y-45);
players[i].done=false;
}
numberFinishedPlayers = 0;
turn = 0;
currentSeason = 1;
roundNumber = 1;
month = 0;
cardsDeck.reloadCards();
deerModeActive = false;
deerModeCounter = 16;
}
void Game::setCurrentNeighbours ()
{
currentNeighbours = players[turn].getNeighbours();
}
/*!
* \brief Game::loadAssets
*/
void Game::loadAssets()
{
- if (!gameFont.loadFromFile("assets/fnt/metal-mania.regular.ttf"))
+ if (!gameFont.loadFromFile(ASSETS_PATH"assets/fnt/metal-mania.regular.ttf"))
{
std::exit(1);
}
- if (!menuFont.loadFromFile("assets/fnt/metal-macabre.regular.ttf"))
+ if (!menuFont.loadFromFile(ASSETS_PATH"assets/fnt/metal-macabre.regular.ttf"))
{
std::exit(1);
}
menuBackground.setTexture(textures.textureMenu);
spriteDeerGod.setTexture(textures.textureDeerGod);
- if (!shaderBlur.loadFromFile("assets/shaders/blur.frag", sf::Shader::Fragment))
+ if (!shaderBlur.loadFromFile(ASSETS_PATH"assets/shaders/blur.frag", sf::Shader::Fragment))
std::exit(1);
- if (!shaderPixel.loadFromFile("assets/shaders/pixelate.frag", sf::Shader::Fragment))
+ if (!shaderPixel.loadFromFile(ASSETS_PATH"assets/shaders/pixelate.frag", sf::Shader::Fragment))
std::exit(1);
- if (!shaderDark.loadFromFile("assets/shaders/dark.frag", sf::Shader::Fragment))
+ if (!shaderDark.loadFromFile(ASSETS_PATH"assets/shaders/dark.frag", sf::Shader::Fragment))
std::exit(1);
- if (!textureBackgroundArt.loadFromFile("assets/img/background_land.png"))
+ if (!textureBackgroundArt.loadFromFile(ASSETS_PATH"assets/img/background_land.png"))
std::exit(1);
- if (!musicGame.openFromFile("assets/audio/game.ogg"))
+ if (!musicGame.openFromFile(ASSETS_PATH"assets/audio/game.ogg"))
std::exit(1);
- // if (!musicBackground.openFromFile("assets/audio/wind2.ogg"))
+ // if (!musicBackground.openFromFile(ASSETS_PATH"assets/audio/wind2.ogg"))
// std::exit(1);
- if (!musicMenu.openFromFile("assets/audio/menu.ogg"))
+ if (!musicMenu.openFromFile(ASSETS_PATH"assets/audio/menu.ogg"))
std::exit(1);
- if (!sfxClickBuffer.loadFromFile("assets/audio/click.ogg"))
+ if (!sfxClickBuffer.loadFromFile(ASSETS_PATH"assets/audio/click.ogg"))
std::exit(1);
- if (!sfxDoneBuffer.loadFromFile("assets/audio/done.ogg"))
+ if (!sfxDoneBuffer.loadFromFile(ASSETS_PATH"assets/audio/done.ogg"))
std::exit(1);
- // if (!textureBackground.loadFromFile("assets/img/background.png"))
+ // if (!textureBackground.loadFromFile(ASSETS_PATH"assets/img/background.png"))
// std::exit(1);
spriteBackgroundArt.setTexture(textureBackgroundArt);
menuTxt.setFont(gameFont);
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);
paganHolidayTxt.setFont(gameFont);
paganHolidayTxt.setCharacterSize(20);
paganHolidayTxt.setPosition(20,20);
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()
{
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();
currentState = state_setup_players;
// currentState = state_lets_begin;
}
void Game::endGame()
{
musicGame.stop();
currentState = state_end_game;
downTimeCounter = 0;
numberFinishedPlayers = 4;
setTxtEndGameAmount();
// musicBackground.stop();
}
void Game::throwDiceMove() {
// Throw a dice action
diceResultPlayer = roundDice.throwDiceSix();
players[turn].characters[0].diceResult=diceResultPlayer;
currentState = state_game;
bubble.state = BubbleState::MOVE;
nextRotateElem.reset();
prevRotateElem.reset();
}
/*!
* \brief Game::playerMakeMove move the player into the position on the map
* \param mousePos
*/
void Game::playerMakeMove(int mousePos) {
players[turn].setFigurePos(mousePos);
commandManager.processField(mousePos);
const int *possibleExit = std::find(std::begin(DP::endPlayers),
std::end(DP::endPlayers), mousePos);
if (possibleExit != DP::endPlayers+4) {
players[turn].done=true;
players[turn].reachedPortal=true;
commandManager.removeAllItems(turn);
if (numberFinishedPlayers == 0)
{
players[turn].reachedPortalFirst=true;
int turnover = (rand() % 2)+5;
players[turn].cash += turnover;
players[turn].updatePlayer();
startDeerMode();
}
sfx.soundPortal.play();
numberFinishedPlayers += 1;
if (numberFinishedPlayers > 3)
{
endGame();
return;
}
}
nextPlayer();
return;
}
int Game::mostDiamonds() const
{
std::array<int,4> results = {{players[0].cash,players[1].cash,players[2].cash,players[3].cash}};
auto minmax = std::minmax_element(std::begin(results), std::end(results));
int maxResult = *(minmax.second);
int result = 0;
int pos = -1;
for (int i=0; i<4;i++)
{
if (players[i].cash == maxResult)
{
result += 1;
pos = i;
}
};
if (result==1)
{
return pos;
}
return -1;
}
/*!
* \brief Game::handleLeftClick
* \param pos
* \param posFull
* \param mousePos
*/
void Game::handleLeftClick(sf::Vector2f pos,sf::Vector2f posFull, int mousePos) {
if (currentState==state_game)
{
if (players[turn].human)
{
std::array<int,2> movements = players[turn].getMovements(diceResultPlayer);
if ((mousePos==movements[0]) || (mousePos==movements[1]))
{
playerMakeMove(mousePos);
}
}
}
if (currentState==state_setup_players)
{
for (int i=0;i<4;i++)
{
sf::IntRect spriteHumanRect(players[i].spriteAI.getGlobalBounds());
if (spriteHumanRect.intersects(sf::IntRect(posFull.x, posFull.y, 1, 1)))
{
players[i].swapHuman();
}
}
sf::IntRect startGameRect(580,640,180,80);
if (startGameRect.intersects(sf::IntRect(posFull.x, posFull.y, 1, 1)))
{
bigDiamondActive = true;
banner.setText("start game");
currentState=state_roll_dice;
launchNextPlayer();
return;
}
}
else if (currentState==state_roll_dice)
{
if (players[turn].human){
sf::IntRect diceRect(roundDice.spriteDice.getGlobalBounds());
if (diceRect.intersects(sf::IntRect(posFull.x, posFull.y, 1, 1)))
{
throwDiceMove();
}
}
}
if (currentState==state_menu)
{
downTimeCounter = 0;
hideMenu();
showGameBoard();
return;
}
if (currentState==state_gui_end_round)
{
std::string resultCommand = guiRoundDice.getElem(pos);
command(resultCommand);
}
if (currentState==state_lets_begin)
{
if (downTimeCounter>1)
{
currentState = state_roll_dice;
restartGame();
launchNextPlayer();
return;
}
}
if (currentState==state_end_game)
{
if (downTimeCounter>2)
{
currentState = state_menu;
musicMenu.play();
restartGame();
return ;
// restartGame();
}
}
}
Game::Game(bool newTestMode):
screenSize(DP::initScreenX,DP::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(DP::TILE_SIZE),
character(&textures, 3),
gameTitle("deerportal"),
roundDice(players),
roundNumber(1),
guiRoundDice(&textures),
boardDiamonds(&textures),
window(sf::VideoMode(DP::initScreenX, DP::initScreenY), "Deerportal - game about how human can be upgraded to the Deer"),
turn(0),
oscilator(-1),
oscilatorInc(true),
particleSystem( 430, 230),
commandManager(*this),
cardsDeck(&textures, &menuFont,&commandManager),
banner(&gameFont),
bigDiamondActive(false),
credits(&gameFont),
cpuTimeThinkingInterval(1.0f),
deerModeCounter(4),
deerModeActive(false),
gameVersion()
{
testMode = newTestMode;
// TODO: perhaps get rid of the particles at all...
particleSystem.setDissolve( true );
particleSystem.setDissolutionRate( 10 );
particleSystem.setShape( DP::CIRCLE );
particleSystem.fuel( 1000 );
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();
- gameVersion.setString("version: " + std::string(DEERPORTAL_VERSION));
+ gameVersion.setString("version: " + std::string(DEERPORTAL_VERSION)+"-"+std::string(BASE_PATH));
gameVersion.setFont(gameFont);
gameVersion.setPosition(10,10);
gameVersion.setColor(sf::Color::White);
gameVersion.setCharacterSize(15);
initBoard();
renderTexture.clear(sf::Color::Black);
renderTexture.draw(textLoading);
renderTexture.display();
showMenu();
// run the main loop
if (testMode){
std::exit(0);
}
while (window.isOpen())
{
sf::Time frameTime = frameClock.restart();
// handle events
sf::Event event;
float xpos = 320.0f;
float ypos = 240.0f;
float xgrv = 0.0f;
float ygrv = 0.0f;
while (window.pollEvent(event))
{
switch (event.type) {
case sf::Event::Closed:
window.close(); break;
case sf::Event::KeyPressed:
if(event.key.code == sf::Keyboard::Escape )
window.close();
if( sf::Keyboard::isKeyPressed( sf::Keyboard::Space ) )
particleSystem.fuel( 200/* * window.getFrameTime() */);
if( sf::Keyboard::isKeyPressed( sf::Keyboard::A ) )
particleSystem.setPosition( --xpos, ypos );
if( sf::Keyboard::isKeyPressed( sf::Keyboard::D ) )
particleSystem.setPosition( ++xpos, ypos );
if( sf::Keyboard::isKeyPressed( sf::Keyboard::W ) )
particleSystem.setPosition( xpos, --ypos );
if( sf::Keyboard::isKeyPressed( sf::Keyboard::S ) )
particleSystem.setPosition( xpos, ++ypos );
if( sf::Keyboard::isKeyPressed( sf::Keyboard::Left ) )
particleSystem.setGravity( --xgrv * 0.1f, ygrv * 0.1f);
if( sf::Keyboard::isKeyPressed( sf::Keyboard::Right ) )
particleSystem.setGravity( ++xgrv * 0.1f, ygrv * 0.1f );
if( sf::Keyboard::isKeyPressed( sf::Keyboard::Up ) )
particleSystem.setGravity( xgrv * 0.1f, --ygrv * 0.1f );
if( sf::Keyboard::isKeyPressed( sf::Keyboard::Down ) )
particleSystem.setGravity( xgrv * 0.1f, ++ygrv * 0.1f );
if( sf::Keyboard::isKeyPressed( sf::Keyboard::G ) )
particleSystem.setGravity( 0.0f, 0.0f );
if( sf::Keyboard::isKeyPressed( sf::Keyboard::P ) )
particleSystem.setPosition( 320.0f, 240.0f );
break;
default:
break;
}
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 / DP::TILE_SIZE;
int mousePosY = (int)localPosition.y / DP::TILE_SIZE;
int mousePos = DP::transCords(sf::Vector2i(mousePosX, mousePosY));
if(event.type == sf::Event::Closed)
window.close();
// Showing mouse hover
if (currentState==state_game)
{
if ((localPosition.x>DP::TILE_SIZE*DP::BOARD_SIZE) || (localPosition.x<0) || (localPosition.y>DP::TILE_SIZE*DP::BOARD_SIZE) || (localPosition.y<0))
{
showPlayerBoardElems = false;
} else {
showPlayerBoardElems = true;
}
}
if ((localPosition.x>=0) && (localPosition.y>=0) && (localPosition.x<=DP::BOARD_SIZE*DP::TILE_SIZE) && (localPosition.y<=DP::BOARD_SIZE*DP::TILE_SIZE))
{
selector.setPosition((int) (localPosition.x / DP::TILE_SIZE)*DP::TILE_SIZE, ((int) localPosition.y / DP::TILE_SIZE)*DP::TILE_SIZE);
}
/*!
* Handling mouse click
*/
if (event.type == sf::Event::MouseButtonReleased)
{
if (event.mouseButton.button == sf::Mouse::Left)
handleLeftClick(localPosition,
localPositionFull, mousePos);
}
}
update(frameTime);
render(frameTime.asSeconds());
}
}
void Game::update(sf::Time frameTime) {
banner.update(frameTime);
credits.update(frameTime);
runningCounter += frameTime.asSeconds();
cpuTimeThinking -= frameTime.asSeconds();
if (oscilatorInc)
{
oscilator += frameTime.asSeconds();
} else {
oscilator -= frameTime.asSeconds();
}
if (oscilator<-1)
oscilatorInc = true;
if (oscilator>1)
oscilatorInc = false;
float modifier = sin(oscilator/2.5)*30.0f;
spriteBigDiamond.setPosition(474,342+modifier);
if (currentState==state_roll_dice)
{
if ((cpuTimeThinking<0) && (players[turn].human==false))
{
cpuTimeThinking = cpuTimeThinkingInterval;
throwDiceMove();
}
}
if (currentState==state_game)
{
std::array<int,2> currentMovements = players[turn].getMovements(diceResultPlayer);
if ((cpuTimeThinking<0) && (players[turn].human==false))
{
std::vector<int> listRandomPos;
if (currentMovements[0]>-1) {
listRandomPos.push_back(currentMovements[0]);
}
if (currentMovements[1]>-1) {
listRandomPos.push_back(currentMovements[1]);
}
unsigned int sizeRndPos = listRandomPos.size();
if (sizeRndPos==0) {
} else if (sizeRndPos==1) {
playerMakeMove(listRandomPos[0]);
} else if (sizeRndPos==2) {
if (deerModeActive)
{
playerMakeMove(listRandomPos[1]);
} else
{
if (players[turn].reachPortalMode == true)
{
playerMakeMove(listRandomPos[1]);
}
else
{
if (boardDiamonds.ifFieldIsEmpty(listRandomPos[1])==false)
{
playerMakeMove(listRandomPos[1]);
return;
}
if (boardDiamonds.ifFieldIsEmpty(listRandomPos[0])==false)
{
playerMakeMove(listRandomPos[0]);
return;
}
if ((boardDiamonds.ifFieldIsEmpty(listRandomPos[0])==false) && (boardDiamonds.ifFieldIsEmpty(listRandomPos[1])==false))
{
playerMakeMove(listRandomPos[1]);
return;
}
int randPos = rand() % 2;
playerMakeMove(listRandomPos[randPos]);
};
}
}
}
if (currentMovements[0]>-1)
{
prevRotateElem.spriteRotate.setPosition(players[turn].characters[0].leftChar.getPosition());
prevRotateElem.spriteRotate.move(10,20);
// Modificator to fit on the bigger view
prevRotateElem.spriteRotate.move(-202,-76);
prevRotateElem.update(frameTime);
prevRotateElem.setColor();
}
if (currentMovements[1]>-1)
{
nextRotateElem.spriteRotate.setPosition(players[turn].characters[0].rightChar.getPosition());
nextRotateElem.spriteRotate.move(10,20);
// Modificator to fit on the bigger view
nextRotateElem.spriteRotate.move(-202,-76);
nextRotateElem.update(frameTime);
nextRotateElem.setColor();
}
}
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>5)
{
currentState = state_roll_dice;
bubble.state = BubbleState::DICE;
}
}
if (currentState==state_end_game)
{
downTimeCounter += frameTime.asSeconds();
}
bubble.update(frameTime);
}
/*!
* \brief Game::nextRound is happening each every 4 months
*/
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();
launchNextPlayer();
}
/*!
* \brief Game::nextPlayer calculates which player should play
*/
void Game::nextPlayer(){
// End of game - we don't calculate more players
if (currentState==state_end_game)
{
return;
}
// End of game - we don't calculate more players
if (numberFinishedPlayers==4)
{
endGame();
return ;
}
// Update old player
players[turn].updatePlayer();
if (turn>2)
{
nextRound();
return;
}
turn++;
launchNextPlayer();
}
void Game::launchNextPlayer(){
if (deerModeActive)
{
deerModeCounter -= 1;
}
if (deerModeCounter<0)
{
endGame();
return ;
}
// Just control
if (players[turn].done==true)
{
nextPlayer();
return;
}
// Frozen player
if (players[turn].frozenLeft>0)
{
players[turn].frozenLeft -= 1;
nextPlayer();
return;
}
// Here we process new player
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);
if (deerModeActive==false)
{
groupHud.setSeason(currentSeason);
groupHud.setMonthName(month%4);
} else
{
groupHud.setDeerModeActive();
int number = (deerModeCounter/4);
if (deerModeCounter<16)
number += 1;
if (number<0)
{
endGame();
return;
}
groupHud.setDeerModeCounter(number);
}
currentState = state_roll_dice;
bubble.state = BubbleState::DICE;
roundDice.setColor(turn);
bubble.setPosition(players[turn].characters[0].getPosition().x-30,
players[turn].characters[0].getPosition().y-45);
cpuTimeThinking = cpuTimeThinkingInterval;
if (mostDiamonds()==turn)
{
players[turn].reachPortalMode = true;
} else {
players[turn].reachPortalMode = false;
}
}
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);
for (int i=0;i<4;i++)
{
renderTexture.draw(players[i].elems);
}
drawSquares();
renderTexture.setView(viewGui);
renderTexture.setView(viewTiles);
renderTexture.setView(viewTiles); // Yeah Katia's inspiration
shaderBlur.setParameter("blur_radius", sin(runningCounter*0.01f) );
// renderTexture.draw(gameBackground);
renderTexture.setView(viewFull);
// renderTexture.draw(spriteBackgroundArt, &shaderDark);
// spriteBackgroundArt.setColor(sf::Color(255, 255, 255, 208));
shaderBlur.setParameter("blur_radius", 0.01);
// shaderBlur.setParameter("blur_radius", sin(runningCounter*0.01) );
// shaderBlur.setParameter("blur_radius", sin(runningCounter*0.01) );
shaderPixel.setParameter("pixel_threshold", sin(runningCounter* 0.005f));
renderTexture.draw(spriteBackgroundArt);
spriteBackgroundArt.setColor(sf::Color(255, 255, 255));
shaderBlur.setParameter("blur_radius", sin(runningCounter* 0.05f)/2);
renderTexture.draw(cardsDeck);
if (currentState==state_roll_dice)
{
spriteBackgroundArt.setColor(sf::Color(255, 255, 255));
shaderBlur.setParameter("blur_radius", sin(runningCounter* 0.5f)/4);
renderTexture.draw(roundDice.spriteDice);
}
else
renderTexture.draw(roundDice.spriteDice);
renderTexture.setView(viewTiles);
drawSquares();
}
void Game::drawCharacters(){
if (currentState==state_game)
{
std::array<int,2> currentMovements = players[turn].characters[0].getMovements(diceResultPlayer);
if (currentMovements[1]>-1)
{
if (nextRotateElem.active)
renderTexture.draw(nextRotateElem);
}
if (currentMovements[0]>-1)
{
if (prevRotateElem.active)
renderTexture.draw(prevRotateElem);
}
}
renderTexture.setView(viewFull);
shaderBlur.setParameter("blur_radius", 0.005f);
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);
}
}
}
/*!
* \brief Game::render main function responsible for drawing all elements
* \param deltaTime
*/
void Game::render(float deltaTime)
{
window.clear();
renderTexture.clear();
if ((currentState==state_game) or (currentState==state_roll_dice))
{
renderTexture.setView(viewFull);
renderTexture.draw(spriteBackgroundDark);
renderTexture.setView(viewTiles);
drawBaseGame();
renderTexture.setView(viewFull);
renderTexture.draw(groupHud);
renderTexture.setView(viewTiles);
drawCharacters();
renderTexture.draw(boardDiamonds);
renderTexture.draw(bubble);
renderTexture.setView(viewFull);
drawPlayersGui();
renderTexture.setView(viewFull);
} else if (currentState==state_setup_players) {
renderTexture.setView(viewFull);
renderTexture.draw(spriteDeerGod);
for (int i=0;i<4;i++)
{
renderTexture.draw(players[i].spriteAI);
}
} else if (currentState==state_gui_elem) {
renderTexture.setView(viewFull);
shaderBlur.setParameter("blur_radius", 2);
renderTexture.draw(spriteBackgroundDark, &shaderBlur);
drawBaseGame();
drawCharacters();
renderTexture.setView(viewFull);
renderTexture.draw(groupHud);
} else if (currentState==state_menu) {
// shaderBlur.setParameter("blur_radius", 15);
renderTexture.draw(menuBackground);
// // renderTexture.draw(menuTxt, &shaderBlur);
// renderTexture.draw(menuTxt);
renderTexture.draw(paganHolidayTxt);
renderTexture.draw(gameVersion);
renderTexture.draw(credits);
} else if (currentState==state_lets_begin) {
renderTexture.setView(viewFull);
shaderBlur.setParameter("blur_radius", 4);
renderTexture.draw(spriteBackgroundDark, &shaderBlur);
renderTexture.setView(viewTiles);
drawBaseGame();
drawCharacters();
renderTexture.draw(boardDiamonds, &shaderBlur);
renderTexture.setView(viewFull);
drawPlayersGui();
renderTexture.draw(spriteLestBegin,&shaderBlur);
} else if (currentState==state_gui_end_round){
renderTexture.setView(viewFull);
renderTexture.draw(spriteBackgroundDark);
drawBaseGame();
shaderBlur.setParameter("blur_radius", 0.05f);
renderTexture.draw(guiRoundDice, &shaderBlur);
renderTexture.setView(viewFull);
renderTexture.draw(groupHud);
}
else if (currentState==state_end_game){
renderTexture.setView(viewFull);
renderTexture.draw(spriteBackgroundDark);
renderTexture.draw(spriteLestBegin,&shaderBlur);
renderTexture.draw(endGameTxt);
// for (int i=0;i<4;i++){
// if (players[i].reachedPortal)
// renderTexture.draw(endGameTxtAmount[i]);
// }
renderTexture.draw(txtWinner);
renderTexture.draw(txtSurvivorsLabel);
for (unsigned int i=0; i<txtSurvivors.size();i++) {
renderTexture.draw(txtSurvivors[i]);
}
renderTexture.draw(txtLoosersLabel);
for (unsigned int i=0; i<txtLoosers.size();i++) {
renderTexture.draw(txtLoosers[i]);
}
}
if (bigDiamondActive)
renderTexture.draw(spriteBigDiamond);
if (banner.active)
renderTexture.draw(banner);
renderTexture.display();
renderSprite.setTexture(renderTexture.getTexture());
shaderBlur.setParameter("blur_radius", sin(deltaTime)*0.015f);
shaderBlur.setParameter("blur_radius", 0.0003f);
window.draw(renderSprite, &shaderBlur);
particleSystem.remove();
particleSystem.update();
particleSystem.render();
window.draw( particleSystem.getSprite() );
window.display();
}
void Game::command(std::string command){
if (command.compare("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();
}
/*!
* \brief Game::startDeerMode launches last episode of the game
*/
void Game::startDeerMode() {
deerModeActive = true;
deerModeCounter = 16;
banner.setText("deer mode");
bigDiamondActive = false;
sfx.soundDeerMode.play();
}
}
diff --git a/src/guiwindow.cpp b/src/guiwindow.cpp
index f7db47c..f41073d 100644
--- a/src/guiwindow.cpp
+++ b/src/guiwindow.cpp
@@ -1,80 +1,80 @@
#include "guiwindow.h"
void GuiWindow::setTitle(std::string newTitle) {
title = newTitle;
guiTitleTxt.setString(title);
}
GuiWindow::GuiWindow(TextureHolder *textures)
{
// spriteClose.setTexture(textures->textureGui);
// spriteClose.setTextureRect(sf::IntRect(0,0,16,16));
// spriteClose.move(sf::Vector2f(150-16,0));
- if (!guiElemFont.loadFromFile("assets/fnt/metal-macabre.regular.ttf"))
+ if (!guiElemFont.loadFromFile(ASSETS_PATH"assets/fnt/metal-macabre.regular.ttf"))
{
std::exit(1);
};
bgdDark.setTexture(textures->backgroundDark);
// bgdDark.setColor(sf::Color(160, 160, 160, 200));
bgdDark.setTextureRect((sf::IntRect)rectangle.getLocalBounds());
title = "Choose building:";
guiTitleTxt.setFont(guiElemFont);
guiTitleTxt.setCharacterSize(58);
guiTitleTxt.setColor(sf::Color(255,255,255,200));
guiTitleTxt.move(2,0);
guiTitleTxt.setString(title);
setPosition(150, 100);
}
GuiWindow::GuiWindow(){
- if (!guiElemFont.loadFromFile("assets/fnt/metal-macabre.regular.ttf"))
+ if (!guiElemFont.loadFromFile(ASSETS_PATH"assets/fnt/metal-macabre.regular.ttf"))
{
std::exit(1);
};
setPosition(150, 100);
}
//void GuiWindow::setTextureHolder(TextureHolder *textures)
//{
//// spriteClose.setTexture(textures->textureGui);
//}
void GuiWindow::init(){
}
void GuiWindow::draw(sf::RenderTarget& target, sf::RenderStates states) const{
sf::RenderStates states2 = states;
states2.transform *= getTransform();
Hover::draw(target, states);
target.draw(bgdDark, states2);
target.draw(spriteClose, states2);
target.draw(guiTitleTxt, states2);
}
std::string GuiWindow::getElem(sf::Vector2f mousePosition)
{
sf::Vector2f hoverPos = getPosition();
sf::FloatRect spriteBounds = spriteClose.getLocalBounds();
sf::FloatRect closeRect;
closeRect.left = spriteClose.getPosition().x;
closeRect.top = spriteClose.getPosition().y;
closeRect.width = spriteBounds.width;
closeRect.height = spriteBounds.height;
if (closeRect.contains(mousePosition.x - hoverPos.x,mousePosition.y - hoverPos.y))
{
return "close_gui";
}
else
return "";
}
diff --git a/src/rotateelem.cpp b/src/rotateelem.cpp
index f21e8fb..5ec5ca8 100644
--- a/src/rotateelem.cpp
+++ b/src/rotateelem.cpp
@@ -1,60 +1,60 @@
#include "rotateelem.h"
RotateElem::RotateElem():
timeCounter(0),
active(true)
{
- if (!textureRotate.loadFromFile("assets/img/rotate.png"))
+ if (!textureRotate.loadFromFile(ASSETS_PATH"assets/img/rotate.png"))
std::exit(1);
spriteRotate.setTexture(textureRotate);
spriteRotate.scale(0.7f,0.7f);
spriteRotate.setOrigin(32, 32);
}
void RotateElem::draw(sf::RenderTarget& target, sf::RenderStates states) const{
states.transform *= getTransform();
target.draw(spriteRotate, states);
}
void RotateElem::update(sf::Time deltaTime)
{
float speed;
speed = 0.05f/deltaTime.asSeconds();
spriteRotate.rotate(1.0f*speed);
timeCounter += deltaTime.asSeconds();
if (timeCounter>0.40f)
if (timeCounter>0.40f)
{
if (active)
{
active = false;
} else {
active = true;
};
timeCounter = 0;
}
}
void RotateElem::setColor()
{
// spriteRotate.setColor(DP::playersColors[playerNumber]);
spriteRotate.setColor(sf::Color::White);
}
void RotateElem::reset()
{
active = true;
timeCounter = 0;
}
diff --git a/src/rounddice.cpp b/src/rounddice.cpp
index 4d211a6..07d14a8 100644
--- a/src/rounddice.cpp
+++ b/src/rounddice.cpp
@@ -1,68 +1,68 @@
#include "rounddice.h"
RoundDice::RoundDice(Player (&players)[4])
{
playersHud = players;
diceResult = 1;
diceResultSix = 6;
diceSize = 150;
- if (!sfxDiceBuffer.loadFromFile("assets/audio/dice.ogg"))
+ if (!sfxDiceBuffer.loadFromFile(ASSETS_PATH"assets/audio/dice.ogg"))
std::exit(1);
- if (!textureDice.loadFromFile("assets/img/diceWhite.png"))
+ if (!textureDice.loadFromFile(ASSETS_PATH"assets/img/diceWhite.png"))
std::exit(1);
spriteDice.setTexture(textureDice);
sfxDice.setBuffer(sfxDiceBuffer);
sfxDice.setVolume(12);
spriteDice.setPosition(1140,550);
setDiceTexture();
}
void RoundDice::setDiceTexture(){
sf::IntRect diceRect(diceSize*diceResultSix, 0, diceSize, diceSize);
spriteDice.setTextureRect(diceRect);
}
void RoundDice::setColor(int playerNumber){
sf::Color color(DP::playersColors[playerNumber]);
spriteDice.setColor(color);
}
void RoundDice::setDiceTexture(int diceResult){
this->diceResultSix = diceResult;
setDiceTexture();
}
std::string RoundDice::drawRound(){
throwDice();
if (diceResult<33)
{
return "end_of_round_extra_grow";
} else if (diceResult<66)
{
return "end_of_round_extra_energy";
} else
{
// eventExtraCash();
return "end_of_round_extra_cash";
}
return "end_of_round_"+std::to_string(diceResult);
}
int RoundDice::throwDice(){
sfxDice.play();
int result = rand()%100;
diceResult = result;
return result;
}
int RoundDice::throwDiceSix(){
sfxDice.play();
int result = rand()%6;
diceResultSix = result;
setDiceTexture();
// return 26;
return result+1;
}
diff --git a/src/soundfx.cpp b/src/soundfx.cpp
index 67017b0..d54739c 100644
--- a/src/soundfx.cpp
+++ b/src/soundfx.cpp
@@ -1,53 +1,53 @@
#include "soundfx.h"
SoundFX::SoundFX()
{
- if (!soundCollectBuffer.loadFromFile("assets/audio/collect.ogg"))
+ if (!soundCollectBuffer.loadFromFile(ASSETS_PATH"assets/audio/collect.ogg"))
exit(-1);
- if (!soundCardBuffer.loadFromFile("assets/audio/card.ogg"))
+ if (!soundCardBuffer.loadFromFile(ASSETS_PATH"assets/audio/card.ogg"))
exit(-1);
- if (!bufferDeerMode.loadFromFile("assets/audio/dp-deermode.ogg"))
+ if (!bufferDeerMode.loadFromFile(ASSETS_PATH"assets/audio/dp-deermode.ogg"))
exit(-1);
- if (!bufferMeditation.loadFromFile("assets/audio/dp-meditation.ogg"))
+ if (!bufferMeditation.loadFromFile(ASSETS_PATH"assets/audio/dp-meditation.ogg"))
exit(-1);
- if (!bufferPortal.loadFromFile("assets/audio/dp-ok.ogg"))
+ if (!bufferPortal.loadFromFile(ASSETS_PATH"assets/audio/dp-ok.ogg"))
exit(-1);
soundCollect.setBuffer(soundCollectBuffer);
soundCollect.setVolume(20);
soundCard.setBuffer(soundCardBuffer);
// soundCollect.setVolume(20);
- if (!soundLetsBeginBuffer.loadFromFile("assets/audio/letsbegin.ogg"))
+ if (!soundLetsBeginBuffer.loadFromFile(ASSETS_PATH"assets/audio/letsbegin.ogg"))
exit(-1);
soundLetsBegin.setBuffer(soundLetsBeginBuffer);
soundLetsBegin.setVolume(20);
soundPortal.setBuffer(bufferPortal);
soundPortal.setVolume(20);
soundDeerMode.setBuffer(bufferDeerMode);
soundDeerMode.setVolume(40);
soundMeditation.setBuffer(bufferMeditation);
soundMeditation.setVolume(20);
}
void SoundFX::playCollect()
{
soundCollect.play();
}
void SoundFX::playCard()
{
soundCard.play();
}
void SoundFX::playLetsBegin()
{
// std::cout << "playing.... begin lets" << std::endl;
soundLetsBegin.play();
}
diff --git a/src/textureholder.cpp b/src/textureholder.cpp
index 727eaa7..d87ce8b 100644
--- a/src/textureholder.cpp
+++ b/src/textureholder.cpp
@@ -1,154 +1,154 @@
#include <iostream>
#include "textureholder.h"
namespace DP {
std::set<int> getTerrainSet() {
std::set<int> terrain;
for (int i: DP::terrainArray)
{
terrain.insert(i);
}
return terrain;
}
}
TextureHolder::TextureHolder()
{
// "stop", "card", "diamond", "diamond x 2"
std::string cardsImages[4][4] = {
{"card-water-stop.small.png", "card-water-remove-card.small.png","card-water-diam.small.png", "card-water-2-diam.small.png" },
{"card-earth-stop.small.png", "card-earth-remove-card.small.png","card-earth-diam.small.png", "card-earth-2-diam.small.png"},
{"card-fire-stop.small.png", "card-fire-remove-card.small.png","card-fire-diam.small.png", "card-fire-2-diam.small.png"},
{"card-air-stop.small.png", "card-air-remove-card.small.png", "card-air-diam.small.png", "card-air-2-diam.small.png" }
};
for (int i=0;i<4;i++)
{
for (int j=0;j<4;j++)
{
- if(!cardsTextures[i][j].loadFromFile("assets/img/cards/"+cardsImages[i][j]))
+ if(!cardsTextures[i][j].loadFromFile(ASSETS_PATH"assets/img/cards/"+cardsImages[i][j]))
{
// std::cout << "assets/img/cards/" << cardsImages[i][j];
std::exit(1);
} else {
// std::cout << "assets/img/cards/" << cardsImages[i][j] << " ok " << i << " " << j << " " << std::endl;
}
}
}
- if (!textureCardBases[0].loadFromFile("assets/img/card-water-2-diam_m.png"))
+ if (!textureCardBases[0].loadFromFile(ASSETS_PATH"assets/img/card-water-2-diam_m.png"))
std::exit(1);
- if (!textureCardBases[1].loadFromFile("assets/img/card-earth-2-diam_m.png"))
+ if (!textureCardBases[1].loadFromFile(ASSETS_PATH"assets/img/card-earth-2-diam_m.png"))
std::exit(1);
- if (!textureCardBases[2].loadFromFile("assets/img/card-fire-2-diam_m.png"))
+ if (!textureCardBases[2].loadFromFile(ASSETS_PATH"assets/img/card-fire-2-diam_m.png"))
std::exit(1);
- if (!textureCardBases[3].loadFromFile("assets/img/card-air-2-diam_m.png"))
+ if (!textureCardBases[3].loadFromFile(ASSETS_PATH"assets/img/card-air-2-diam_m.png"))
std::exit(1);
-// if (!textureGameBackground.loadFromFile("assets/img/game-ackground.png"))
+// if (!textureGameBackground.loadFromFile(ASSETS_PATH"assets/img/game-ackground.png"))
// std::exit(1);
-// if (!textureTiles.loadFromFile("assets/img/zw-tilesets/_MAP.png"))
+// if (!textureTiles.loadFromFile(ASSETS_PATH"assets/img/zw-tilesets/_MAP.png"))
// std::exit(1);
-// if (!textureFaces.loadFromFile("assets/img/faces.jpg"))
+// if (!textureFaces.loadFromFile(ASSETS_PATH"assets/img/faces.jpg"))
// std::exit(1);
-// if (!textureGui.loadFromFile("assets/img/gui.png"))
+// if (!textureGui.loadFromFile(ASSETS_PATH"assets/img/gui.png"))
// std::exit(1);
-// if (!textureSymbols.loadFromFile("assets/img/symbols.png"))
+// if (!textureSymbols.loadFromFile(ASSETS_PATH"assets/img/symbols.png"))
// std::exit(1);
-// if (!textureSeasons.loadFromFile("assets/img/seasons.png"))
+// if (!textureSeasons.loadFromFile(ASSETS_PATH"assets/img/seasons.png"))
// std::exit(1);
- if (!textureCharacters.loadFromFile("assets/img/characters-new.png"))
+ if (!textureCharacters.loadFromFile(ASSETS_PATH"assets/img/characters-new.png"))
std::exit(1);
- if (!backgroundDark.loadFromFile("assets/img/background_dark.png"))
+ if (!backgroundDark.loadFromFile(ASSETS_PATH"assets/img/background_dark.png"))
std::exit(1);
- if (!textureBoardDiamond.loadFromFile("assets/img/board_diamonds.png"))
+ if (!textureBoardDiamond.loadFromFile(ASSETS_PATH"assets/img/board_diamonds.png"))
std::exit(1);
- if (!textureMenu.loadFromFile("assets/img/dp_intro_menu.png"))
+ if (!textureMenu.loadFromFile(ASSETS_PATH"assets/img/dp_intro_menu.png"))
std::exit(1);
- if (!textureLetsBegin.loadFromFile("assets/img/letsbegin.png"))
+ if (!textureLetsBegin.loadFromFile(ASSETS_PATH"assets/img/letsbegin.png"))
std::exit(1);
- if (!textureButtonCpu.loadFromFile("assets/img/button-cpu.png"))
+ if (!textureButtonCpu.loadFromFile(ASSETS_PATH"assets/img/button-cpu.png"))
std::exit(1);
- if (!textureButtonHuman.loadFromFile("assets/img/button-human.png"))
+ if (!textureButtonHuman.loadFromFile(ASSETS_PATH"assets/img/button-human.png"))
std::exit(1);
- if (!textureDeerGod.loadFromFile("assets/img/deer-god.png"))
+ if (!textureDeerGod.loadFromFile(ASSETS_PATH"assets/img/deer-god.png"))
std::exit(1);
- if (!textureBigDiamond.loadFromFile("assets/img/diamond-big.png"))
+ if (!textureBigDiamond.loadFromFile(ASSETS_PATH"assets/img/diamond-big.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/version.txt b/version.txt
index c7d2522..762b19e 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.7.2-dev
+0.7.3-snap-prepare

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jun 15, 11:42 PM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
72371
Default Alt Text
(55 KB)

Event Timeline