Page MenuHomePhabricator (Chris)

No OneTemporary

Size
30 KB
Referenced Files
None
Subscribers
None
diff --git a/CREDITS.md b/CREDITS.md
index 7647f7e..cc126d8 100644
--- a/CREDITS.md
+++ b/CREDITS.md
@@ -1,38 +1,42 @@
Artwork
=======
*Fantasy book* http://opengameart.org/content/fantasy-book
by yd, Public Domain CC0[^cc0].
*Zw tileset* http://opengameart.org/content/zwischenwelt-tileset
by hagish, Public Domain CC0[^cc0].
*Public domain portraits* http://opengameart.org/content/public-domain-portraits
by qubodup, Public Domain CC0[^cc0].
*Cans in the wind in a garden in Ukraine* http://www.freesound.org/people/felix.blume/sounds/139008/
by felix.blume, This work is licensed under the Creative Commons 0 License[^cc0].
*Menu click effect*, http://www.freesound.org/people/broumbroum/sounds/50561/
by broumbroum, This work is licensed under the Creative Commons 0 License[^cc0].
[^cc0]:Definition of Creative Commons 0 License can be found here: http://creativecommons.org/publicdomain/zero/1.0/
*8 Bit The Hero * http://opengameart.org/content/8-bit-the-hero
bye ShwiggityShwag, This work is licensed under the Creative Commons 0 License[^cc0].
*Andy's Report* http://opengameart.org/content/andys-report-8bit-and-piano-ver
by megupets, This work is licensed under the Creative Commons 0 License[^cc0].
*Ancient symbols* https://openclipart.org/user-detail/cinemacookie
*Dices* https://www.freesound.org/people/qubodup/sounds/189321/
by qubodup
+
+*Collect Done * https://www.freesound.org/people/suntemple/sounds/241809/
+
+by suntemple
diff --git a/assets/audio/done.ogg b/assets/audio/done.ogg
new file mode 100644
index 0000000..103888e
Binary files /dev/null and b/assets/audio/done.ogg differ
diff --git a/game.cpp b/game.cpp
index 1d85643..25e4598 100644
--- a/game.cpp
+++ b/game.cpp
@@ -1,594 +1,616 @@
#include "game.h"
namespace efc {
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);
groupHud.setFont(&gameFont);
groupHud.setSeason(currentSeason);
groupHud.setRoundName(roundNumber);
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[2] = playerHud3;
players[3] = playerHud4;
players[0].setActive(true);
setCurrentNeighbours();
}
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/VCR_OSD_MONO_1.001.ttf"))
{
std::exit(1);
}
if (!menuFont.loadFromFile("assets/fnt/VCR_OSD_MONO_1.001.ttf"))
{
std::exit(1);
}
menuTxt.setFont(menuFont);
menuTxt.setCharacterSize(120);
menuTxt.setString(gameTitle);
menuTxt.setColor(sf::Color(55, 255, 35, 85));
int width = menuTxt.getLocalBounds().width;
int height = menuTxt.getLocalBounds().height;
menuTxt.setPosition(400-(width/2),300-(height/2)-150);
// menuTxt.setScale(0.5, 0.5);
}
void Game::showMenu()
{
menuBackground.setTexture(textures.textureMenu);
musicMenu.play();
musicMenu.setLoop(true);
currentState = state_menu;
}
void Game::hideMenu()
{
musicMenu.stop();
}
void Game::showGameBoard()
{
musicGame.setVolume(20);
musicGame.play();
musicGame.setLoop(true);
currentState = state_game;
}
void Game::hideGameBoard()
{
musicGame.play();
}
Game::Game():
window(sf::VideoMode(800, 600), "Pagan Board"),
viewTiles(sf::FloatRect(0, 0, 524, 458)),
viewGui(sf::FloatRect(00, 00, 800, 600)),
viewFull(sf::FloatRect(00, 00, 800, 600)),
selector(efc::TILE_SIZE),
guiSelectBuilding(&textures),
turn(0),
gameTitle(" PAgAN\nBOaRD "),
roundDice(players),
roundNumber(1),
guiRoundDice(&textures)
{
if (!textureBackground.loadFromFile("assets/img/background.png"))
std::exit(1);
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)};
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 guiStartPos[4][2] = {
{borderLeft+3,borderTop+2},
{800 - guiWidth - borderRight - gWidth-4,borderTop+2},
{borderLeft+3,600-gHeight-borderBottom-4} ,
{800 - guiWidth - borderRight - gWidth-4, 600-gHeight-borderBottom-4}};
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;
spriteBackgroundDark.setTexture(textures.backgroundDark);
spriteBackgroundDark.setPosition(568,000);
// spriteBackgroundDark.setColor(sf::Color(55,55,55,155));
spriteBackground.setTexture(textureBackground);
guiRoundDice.active = true;
showPlayerBoardElems = false;
if (!musicGame.openFromFile("assets/audio/game.ogg"))
std::exit(1);
if (!musicBackground.openFromFile("assets/audio/wind.ogg"))
std::exit(1);
if (!musicMenu.openFromFile("assets/audio/menu.ogg"))
std::exit(1);
musicBackground.play();
musicBackground.setLoop(true);
if (!sfxClickBuffer.loadFromFile("assets/audio/click.ogg"))
std::exit(1);
sfxClick.setBuffer(sfxClickBuffer);
+
+ if (!sfxDoneBuffer.loadFromFile("assets/audio/done.ogg"))
+ std::exit(1);
+ sfxDone.setBuffer(sfxDoneBuffer);
+
window.setVerticalSyncEnabled(true);
Hover hover;
GuiWindow guiWindow(&textures);
std::srand (time(NULL));
loadAssets();
viewTiles.setViewport(sf::FloatRect(0.04f,0.060f, 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
initBoard();
showMenu();
// run the main loop
while (window.isOpen())
{
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>400) || (localPosition.x<0) || (localPosition.y>400) || (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)
{
if (currentState==state_game)
{
resultCommand = players[turn].getElem(localPositionGui);
command(resultCommand);
if (currentNeighbours.find(mousePos) != currentNeighbours.end())
{
if ((!guiSelectBuilding.active) && (showPlayerBoardElems))
{
float hover_x =localPositionFull.x;
float hover_y = localPositionFull.y;
if (localPosition.y > 290)
hover_y = hover_y - 100;
if (localPosition.x > 240)
hover_x = hover_x - 150;
if (hover_x>250)
hover_x = 249.0f;
if (hover_x<0)
hover_x = 1.0f;
if (hover_y>300)
hover_y = 299.0f;
if (hover_y<0)
hover_y = 1.0f;
selectedPos = mousePos;
std::cout << hover_x << " " << hover_y << std::endl;
guiSelectBuilding.setPosition(guiStartPos[turn][0],guiStartPos[turn][1]);
guiSelectBuilding.active = true;
sfxClick.play();
currentState = state_gui_elem;
}
break;
}
// nextPlayer();
}
if (currentState==state_gui_elem)
{
resultCommand = guiSelectBuilding.getElem(localPositionFull);
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)
{
hideMenu();
showGameBoard();
}
if (currentState==state_gui_end_round)
{
resultCommand = guiRoundDice.getElem(localPosition);
command(resultCommand);
}
}
}
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);
}
}
render();
}
}
void Game::nextRound() {
turn = 0;
std::string result = roundDice.drawRound();
roundNumber += 1;
std::cout << "END OF ROUND " << roundNumber << " " << result << std::endl;
month++;
if (month==13)
month=1;
if (month%4==0)
currentSeason++;
if (currentSeason>3)
currentSeason=0;
command(result);
}
void Game::nextPlayer(){
players[turn].updatePlayer();
turn++;
if (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();
std::cout << roundNumber << " " << roundNumber % 16 << std::endl;
groupHud.setRoundName(roundNumber);
groupHud.setSeason(currentSeason);
groupHud.setMonthName(month%4);
}
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::update()
{
}
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);
drawPlayersGui();
window.setView(viewTiles);
}
void Game::render()
{
window.clear();
if (currentState==state_game)
{
window.setView(viewFull);
window.draw(spriteBackgroundDark);
window.setView(viewTiles);
drawBaseGame();
} else if (currentState==state_gui_elem) {
window.setView(viewFull);
window.draw(spriteBackgroundDark);
drawBaseGame();
window.setView(viewFull);
window.draw(guiSelectBuilding);
} else if (currentState==state_menu) {
window.draw(menuBackground);
window.draw(menuTxt);
window.draw(groupHud);
// window.setView(viewFull);
// window.draw(spriteBackgroundDark);
} else if (currentState==state_gui_end_round){
window.setView(viewFull);
window.draw(spriteBackgroundDark);
drawBaseGame();
window.draw(guiRoundDice);
// window.setView(viewFull);
// window.draw(spriteBackgroundDark);
}
window.setView(viewFull);
// window.draw(spriteBackgroundDark);
window.draw(spriteBackground);
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);
std::cout << "SUB RESULT " << subResult << std::endl;
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));
int cashUpd = textures.tilesDescription[buildingType][0];
+ int cashCost = textures.tilesDescription[buildingType][1];
int foodUpd = textures.tilesDescription[buildingType][2];
+ int foodCost = textures.tilesDescription[buildingType][3];
int enrgUpd = textures.tilesDescription[buildingType][4];
+ int enrgCost = textures.tilesDescription[buildingType][5];
std::string descTxt = textures.tilesTxt[buildingType];
- guiSelectBuilding.setDescriptionTxt("Cash:" + std::to_string(cashUpd) +"\n"+descTxt);
+
+ char priceTxtChar [100];
+ int cx = snprintf ( priceTxtChar, 100, "Price: cash: %2d food: %2d energy: %2d \n", cashUpd, foodUpd, enrgUpd);
+ std::string priceTxt = priceTxtChar;
+
+
+ char costTxtChar [100];
+ cx = snprintf ( costTxtChar, 100, "Cost: cash: %2d food: %2d energy: %2d \n", cashCost, foodCost, enrgCost);
+ std::string costTxt = costTxtChar;
+
+ // std::string priceTxt = "Price: cash:" + std::to_string(cashUpd) + " food: " + std::to_string(foodUpd) + " energy: " + std::to_string(enrgUpd);
+ // std::string costTxt = "Cost: cash:" + std::to_string(cashCost) + " food: " + std::to_string(foodCost) + " energy: " + std::to_string(enrgCost);
+
+
+ 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;
- sfxClick.play();
+ sfxDone.play();
}
}
}
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 faabad2..2d72eb2 100644
--- a/game.h
+++ b/game.h
@@ -1,119 +1,124 @@
#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"
namespace efc {
class Game
{
public:
Game();
sf::RenderWindow window;
sf::View viewTiles;
private:
void initBoard();
void loadAssets();
void drawPlayersGui();
void drawSquares();
void drawMenu();
sf::Vector2f getMousePos();
enum states {
state_init,
state_menu,
state_game,
state_gui_elem,
state_select_building,
state_gui_end_round,
state_quit
};
states currentState;
sf::Texture textureBackground;
sf::Sprite spriteBackground;
sf::Sprite spriteBackgroundDark;
sf::Texture textureTiles;
sf::Texture textureFaces;
sf::Font gameFont;
sf::Font menuFont;
sf::Text menuTxt;
std::string gameTitle;
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;
int turn;
void update();
void render();
sf::View viewGui;
Selector selector;
sf::View viewFull;
RoundDice roundDice;
int roundNumber;
GuiChooseBuilding guiSelectBuilding;
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 = 0;
};
}
#endif // GAME_H
diff --git a/guichoosebuilding.cpp b/guichoosebuilding.cpp
index be4a839..e7e1a35 100644
--- a/guichoosebuilding.cpp
+++ b/guichoosebuilding.cpp
@@ -1,86 +1,86 @@
#include "guichoosebuilding.h"
#include "tilemap.h"
GuiChooseBuilding::GuiChooseBuilding(TextureHolder *textures)
:GuiWindow(textures),
textureTiles(textures->textureTiles)
{
// this->textureTiles = &textures->textureGui;
// std::cout << "constructor" <<std::endl;
addBuilding("elem_651", 651);
addBuilding("elem_442", 442);
addBuilding("elem_585", 585);
addBuilding("elem_1100", 1100);
description = "Description";
guiElemTxt.setFont(guiElemFont);
- guiElemTxt.setCharacterSize(10);
+ guiElemTxt.setCharacterSize(16);
guiElemTxt.setColor(sf::Color(255,255,255,200));
updateDescription();
guiElemTxt.move(2,50);
descriptionActive = false;
rectangle.setSize(sf::Vector2f(400,200));
bgdDark.setTextureRect((sf::IntRect)rectangle.getLocalBounds());
spriteClose.setPosition(sf::Vector2f(rectangle.getLocalBounds().width-16,0));
}
void GuiChooseBuilding::updateDescription() {
guiElemTxt.setString(description);
}
void GuiChooseBuilding::setDescriptionTxt(std::string newDescription) {
description = newDescription;
updateDescription();
}
void GuiChooseBuilding::addBuilding(std::string name, int pos){
sf::Sprite newBuilding;
newBuilding.setTexture(textureTiles);
newBuilding.setTextureRect(efc::transPosIntoRect(pos));
sf::Vector2f mod((buildings.size()*efc::TILE_SIZE)+4*(buildings.size()+1)+4,efc::TILE_SIZE);
newBuilding.move(mod);
buildings.insert({name, newBuilding});
// std::cout << "size " << buildings.size() <<std::endl;
}
void GuiChooseBuilding::draw(sf::RenderTarget& target, sf::RenderStates states) const{
if (active==true)
{
sf::RenderStates states2 = states;
states2.transform *= getTransform();
GuiWindow::draw(target, states);
for (std::pair<std::string, sf::Sprite> i: buildings)
{
target.draw(i.second, states2);
}
if (descriptionActive)
target.draw(guiElemTxt, states2);
}
}
std::string GuiChooseBuilding::getElem(sf::Vector2f mousePosition) {
std::string result = GuiWindow::getElem(mousePosition);
if (result=="close_gui")
return result;
sf::Vector2f hoverPos = getPosition();
for (std::pair<std::string, sf::Sprite> i: buildings)
{
sf::FloatRect spriteBounds = i.second.getLocalBounds();
sf::FloatRect closeRect;
closeRect.left = i.second.getPosition().x;
closeRect.top = i.second.getPosition().y;
closeRect.width = spriteBounds.width;
closeRect.height = spriteBounds.height;
if (closeRect.contains(mousePosition.x - hoverPos.x,mousePosition.y - hoverPos.y))
{
return i.first;
}
}
return result;
}
diff --git a/guiwindow.cpp b/guiwindow.cpp
index c053d26..83e223a 100644
--- a/guiwindow.cpp
+++ b/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/VCR_OSD_MONO_1.001.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(16);
+ guiTitleTxt.setCharacterSize(18);
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/VCR_OSD_MONO_1.001.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/textureholder.cpp b/textureholder.cpp
index d6917c8..d0bff95 100644
--- a/textureholder.cpp
+++ b/textureholder.cpp
@@ -1,80 +1,80 @@
#include "textureholder.h"
TextureHolder::TextureHolder()
{
// textureTiles.setSmooth(true);
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 (!backgroundDark.loadFromFile("assets/img/background_dark.png"))
std::exit(1);
if (!textureMenu.loadFromFile("assets/img/menu.jpg"))
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."});
- tilesTxt.insert({442, "Granary, increases food\nresources."});
- tilesTxt.insert({585, "Marketplace, generates cash"});
- tilesTxt.insert({1100, "Monasterium, brings you luck"});
+ 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..."});
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Feb 2, 9:07 PM (1 d, 19 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55573
Default Alt Text
(30 KB)

Event Timeline