Page MenuHomePhabricator (Chris)

No OneTemporary

Size
15 KB
Referenced Files
None
Subscribers
None
diff --git a/CREDITS.md b/CREDITS.md
index 27e727b..e5e3da1 100644
--- a/CREDITS.md
+++ b/CREDITS.md
@@ -1,32 +1,34 @@
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
diff --git a/assets/img/Ancient-Sacred-Symbols-2.xcf b/assets/img/Ancient-Sacred-Symbols-2.xcf
new file mode 100644
index 0000000..4e411b2
Binary files /dev/null and b/assets/img/Ancient-Sacred-Symbols-2.xcf differ
diff --git a/assets/img/Ancient-Sacred-Symbols-22.xcf b/assets/img/Ancient-Sacred-Symbols-22.xcf
new file mode 100644
index 0000000..72f8d76
Binary files /dev/null and b/assets/img/Ancient-Sacred-Symbols-22.xcf differ
diff --git a/assets/img/Ancient-Sacred-Symbols-3.xcf b/assets/img/Ancient-Sacred-Symbols-3.xcf
new file mode 100644
index 0000000..b39fd1d
Binary files /dev/null and b/assets/img/Ancient-Sacred-Symbols-3.xcf differ
diff --git a/assets/img/Ancient-Sacred-Symbols-33.xcf b/assets/img/Ancient-Sacred-Symbols-33.xcf
new file mode 100644
index 0000000..60fd3ac
Binary files /dev/null and b/assets/img/Ancient-Sacred-Symbols-33.xcf differ
diff --git a/assets/img/background_dark.png b/assets/img/background_dark.png
new file mode 100644
index 0000000..0c61919
Binary files /dev/null and b/assets/img/background_dark.png differ
diff --git a/assets/img/symbol00.png b/assets/img/symbol00.png
new file mode 100644
index 0000000..22588da
Binary files /dev/null and b/assets/img/symbol00.png differ
diff --git a/assets/img/symbol01.png b/assets/img/symbol01.png
new file mode 100644
index 0000000..9d0e974
Binary files /dev/null and b/assets/img/symbol01.png differ
diff --git a/assets/img/symbol02.png b/assets/img/symbol02.png
new file mode 100644
index 0000000..fefff4f
Binary files /dev/null and b/assets/img/symbol02.png differ
diff --git a/assets/img/symbols.png b/assets/img/symbols.png
new file mode 100644
index 0000000..6be9bbf
Binary files /dev/null and b/assets/img/symbols.png differ
diff --git a/playerhud.cpp b/playerhud.cpp
index 26bb9d2..73461eb 100644
--- a/playerhud.cpp
+++ b/playerhud.cpp
@@ -1,238 +1,254 @@
#include "playerhud.h"
#include "textureholder.h"
#include "boardelem.h"
bool PlayerHud::addElem(int pos, int type) {
int price = textures->tilesDescription[type][0];
if (price<=cash)
{
efc::BoardElem startElem(textures, pos,type);
startElem.setColor(efc::playersColors[this->pos]);
elems.items.push_back(startElem);
elems.items_map.insert({pos, startElem});
cash -= price;
updateTxt();
return true;
}
return false;
}
std::set<int> PlayerHud::getTerrainSet(){
std::set<int> terrain;
for (int i: efc::terrain)
{
// std::cout << i << std::endl;
terrain.insert(i);
}
return terrain;
}
std::set<int> PlayerHud::getNeighbours(){
std::set<int> neighbours;
for (std::pair<int, efc::BoardElem> i: elems.items_map)
{
std::set<int> terrain = getTerrainSet();
std::set<int> neighboursVector(efc::getNeighbours(i.second.pos));
for (int j: neighboursVector)
{
if ((elems.items_map.count(j) == 0) && (terrain.count(j)==0))
{
// std::cout << j << " " << terrain.count(j) << std::endl;
neighbours.insert(j);
}
}
}
// // Fill in s1 and s2 with values
// std::set<int> result;
// std::set_difference(neighbours.begin(), neighbours.end(), terrain.begin(), terrain.end(),
// std::inserter(result, result.end()));
// for (int i: result)
// {
// std::cout << i << std::endl;
// }
return neighbours;
}
void PlayerHud::updateTxt(){
txtCash.setString( "Cash: " + std::to_string(cash));
txtFood.setString( "Food: " + std::to_string(food));
txtEnergy.setString("Enrg: " + std::to_string(energy));
txtFaith.setString( "Gods: " + std::to_string(faith));
}
void PlayerHud::updatePlayer(){
for (const efc::BoardElem &i: elems.items)
{
int cashUpd = textures->tilesDescription[i.type][1];
int foodUpd = textures->tilesDescription[i.type][3];
int enrgUpd = textures->tilesDescription[i.type][5];
int faithUpd = textures->tilesDescription[i.type][7];
cash += cashUpd;
energy += enrgUpd;
food += foodUpd;
faith += faithUpd;
updateTxt();
}
}
PlayerHud::PlayerHud()
{
}
void PlayerHud::setActive(bool newState){
active = newState;
elems.active = newState;
}
PlayerHud::PlayerHud(TextureHolder *textures, int faceNumber, sf::Font *gameFont, int faceSize, int pos)
{
active = false;
this->textures = textures;
efc::BoardElem startElem(textures, startPlayers[pos],444);
startElem.setColor(efc::playersColors[pos]);
elems.items.push_back(startElem);
elems.items_map.insert({startPlayers[pos], startElem});
this->faceSize = faceSize;
spriteFace.setTexture(textures->textureFaces);
this->pos = pos;
+
+ symbol.setTexture(this->textures->textureSymbols);
+
+
+ sf::IntRect symbolsRect[4] = {sf::IntRect(0,0,255,255), sf::IntRect(256,0,512,255), sf::IntRect(0,255, 255, 512), sf::IntRect(255,255,512, 512)};
+
+
+ symbol.setTextureRect(symbolsRect[pos]);
+ symbol.setScale(sf::Vector2f(0.025f, 0.1f));
+ symbol.setColor(sf::Color(25, 25, 25, 55));
+
+
food = 0;
cash = 20;
energy = 0;
faith = 0;
int x = faceNumber % 10;
int y = (int) faceNumber /10;
txtCash.setFont(*gameFont);
txtFood.setFont(*gameFont);
txtEnergy.setFont(*gameFont);
txtFaith.setFont(*gameFont);
txtNextRound.setFont(*gameFont);
txtNextRound.setString("End Turn");
txtNextRound.setScale(sf::Vector2f(0.25f, 1.f));
txtNextRound.setCharacterSize(10);
txtNextRound.setPosition(9,(pos*100)+10);
+
+ symbol.setPosition(15, (pos*100)+52);
+
txtCash.setPosition(1,(pos*100)+40);
// txtCash.setString("Cash: " + std::to_string(cash));
txtCash.setCharacterSize(10);
txtCash.setScale(sf::Vector2f(0.25f, 1.f));
txtFood.setPosition(1,(pos*100)+55);
// txtFood.setString("Food: " + std::to_string(food));
txtFood.setCharacterSize(10);
txtFood.setScale(sf::Vector2f(0.25f, 1.f));
txtEnergy.setPosition(1,(pos*100)+70);
// txtEnergy.setString("Enrg: " + std::to_string(energy));
txtEnergy.setCharacterSize(10);
txtEnergy.setScale(sf::Vector2f(0.25f, 1.f));
txtFaith.setPosition(1,(pos*100)+85);
// txtEnergy.setString("Enrg: " + std::to_string(energy));
txtFaith.setCharacterSize(10);
txtFaith.setScale(sf::Vector2f(0.25f, 1.f));
updateTxt();
spriteFace.setTextureRect(sf::IntRect(x*faceSize, y*faceSize, faceSize, faceSize));
spriteFace.setScale(sf::Vector2f(0.25f, 1.f));
spriteFace.setPosition(0,pos*100);
rectangle.setSize(sf::Vector2f(this->faceSize, this->faceSize));
rectangle2.setSize(sf::Vector2f(this->faceSize, (this->faceSize*2)+3));
if (pos==0)
{
rectangle.setFillColor(sf::Color(50, 50, 150,168));
rectangle2.setFillColor(sf::Color(100, 100, 150,168));
rectangle.setOutlineColor(sf::Color(0,0,128));
}
else if (pos==1)
{
rectangle.setFillColor(sf::Color(50, 150, 50,168));
rectangle2.setFillColor(sf::Color(100, 150,100,168));
rectangle.setOutlineColor(sf::Color(0,128,0));
}
else if (pos==2)
{
rectangle.setFillColor(sf::Color(150, 50, 50,168));
rectangle2.setFillColor(sf::Color(150, 100,100,168));
rectangle.setOutlineColor(sf::Color(128,0,0));
}
else if (pos==3)
{
rectangle.setFillColor(sf::Color(150, 150, 150,168));
rectangle2.setFillColor(sf::Color(200, 200,200,168));
rectangle.setOutlineColor(sf::Color(128,128,128));
}
rectangle.setOutlineThickness(1);
rectangle.setPosition(0, pos*100);
rectangle2.setPosition(0, (pos*100)+faceSize+1);
buttons.insert({"end_turn",rectangle});
}
std::string PlayerHud::getElem(sf::Vector2f mousePosition) {
std::string result = "";
sf::Vector2f hoverPos = getPosition();
for (std::pair<std::string, sf::RectangleShape> i: buttons)
{
sf::FloatRect spriteBounds = i.second.getLocalBounds();
sf::FloatRect closeRect;
closeRect.left = i.second.getPosition().x;
closeRect.top = i.second.getPosition().y;
closeRect.width = spriteBounds.width;
closeRect.height = spriteBounds.height;
// std::cout << closeRect.left << " " << closeRect.top << " " << closeRect.width << " " << closeRect.height
// << hoverPos.x << " " << hoverPos.y << " OK"
// << std::endl;
if (closeRect.contains(mousePosition.x - hoverPos.x,mousePosition.y - hoverPos.y))
{
return i.first;
}
}
return result;
}
void PlayerHud::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
// // apply the transform
states.transform *= getTransform();
// Color rectangles making the gui on the right side
// sf::RectangleShape rectangle(sf::Vector2f(faceSize, faceSize));
// sf::RectangleShape rectangle2(sf::Vector2f(faceSize, (faceSize*2)+3));
target.draw(rectangle, states);
target.draw(rectangle2, states);
target.draw(txtCash, states);
target.draw(txtFood, states);
target.draw(txtEnergy, states);
target.draw(txtFaith, states);
if (active)
target.draw(txtNextRound, states);
+ target.draw(symbol, states);
target.draw(spriteFace, states);
}
diff --git a/playerhud.h b/playerhud.h
index b492cf2..7f8967d 100644
--- a/playerhud.h
+++ b/playerhud.h
@@ -1,65 +1,68 @@
#ifndef PLAYERHUD_H
#define PLAYERHUD_H
#include <iostream>
#include <set>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include "boardelems.h"
#include "textureholder.h"
#include "elemsdescription.h"
#include "guiwindow.h"
static int startPlayers[4] = {0,15,240,255};
namespace efc {
static sf::Color playersColors[4] = {
sf::Color(20, 20,230,155),
sf::Color(50, 230,50,255),
sf::Color(230, 50,50,255),
sf::Color(150, 150,150,255)
};
}
class PlayerHud : public sf::Drawable, public sf::Transformable
{
public:
PlayerHud();
PlayerHud(TextureHolder *textures, int faceNumber, sf::Font *gameFont, int tileSize, int pos);
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
std::set<int> getNeighbours();
int pos;
int cash;
int energy;
int food;
int faith;
bool active;
BoardElems elems;
void setActive(bool newState);
std::vector<int> properties;
bool addElem(int pos, int type);
void updatePlayer();
std::string getElem(sf::Vector2f mousePosition);
std::map<std::string, sf::RectangleShape> buttons;
void updateTxt();
private:
sf::Sprite spriteFace;
sf::Text txtCash;
sf::Text txtEnergy;
sf::Text txtFood;
sf::Text txtFaith;
sf::Text txtNextRound;
int faceSize;
int tileSize;
TextureHolder *textures;
sf::RectangleShape rectangle;
sf::RectangleShape rectangle2;
+
+ sf::Sprite symbol;
+
std::set<int> getTerrainSet();
};
#endif // PLAYERHUD_H
diff --git a/textureholder.cpp b/textureholder.cpp
index 6f7d1f1..acc6373 100644
--- a/textureholder.cpp
+++ b/textureholder.cpp
@@ -1,69 +1,73 @@
#include "textureholder.h"
TextureHolder::TextureHolder()
{
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 (!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"});
}
diff --git a/textureholder.h b/textureholder.h
index 6debea6..ac51e5b 100644
--- a/textureholder.h
+++ b/textureholder.h
@@ -1,42 +1,47 @@
#ifndef TEXTUREHOLDER_H
#define TEXTUREHOLDER_H
#include <set>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
namespace efc {
static int terrain[24] = {
8, 24, 40, 56, 72, 88,
113, 114, 115, 116, 117, 118,
138, 139, 140, 141, 142, 143,
167, 183, 199, 215, 231, 247
};
static std::set<int> getTerrainSet() {
std::set<int> terrain;
for (int i: efc::terrain)
{
terrain.insert(i);
}
return terrain;
}
}
class TextureHolder
{
public:
TextureHolder();
sf::Texture textureTiles;
sf::Texture textureFaces;
sf::Texture textureGui;
sf::Texture textureMenu;
+ sf::Texture textureSymbols;
+
+ sf::Texture backgroundDark;
+
+
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
Mon, Feb 2, 9:08 PM (1 d, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55576
Default Alt Text
(15 KB)

Event Timeline