Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
16 KB
Referenced Files
None
Subscribers
None
diff --git a/assets/img/cards/card-air-2-diam.small.png b/assets/img/cards/card-air-2-diam.small.png
new file mode 100644
index 0000000..20cd538
Binary files /dev/null and b/assets/img/cards/card-air-2-diam.small.png differ
diff --git a/assets/img/cards/card-air-diam.small.png b/assets/img/cards/card-air-diam.small.png
new file mode 100644
index 0000000..bbee228
Binary files /dev/null and b/assets/img/cards/card-air-diam.small.png differ
diff --git a/assets/img/cards/card-air-remove-card.small.png b/assets/img/cards/card-air-remove-card.small.png
new file mode 100644
index 0000000..bd528b2
Binary files /dev/null and b/assets/img/cards/card-air-remove-card.small.png differ
diff --git a/assets/img/cards/card-air-stop.small.png b/assets/img/cards/card-air-stop.small.png
new file mode 100644
index 0000000..83a83e0
Binary files /dev/null and b/assets/img/cards/card-air-stop.small.png differ
diff --git a/assets/img/cards/card-earth-2-diam.small.png b/assets/img/cards/card-earth-2-diam.small.png
new file mode 100644
index 0000000..0c7e567
Binary files /dev/null and b/assets/img/cards/card-earth-2-diam.small.png differ
diff --git a/assets/img/cards/card-earth-diam.small.png b/assets/img/cards/card-earth-diam.small.png
new file mode 100644
index 0000000..7353720
Binary files /dev/null and b/assets/img/cards/card-earth-diam.small.png differ
diff --git a/assets/img/cards/card-earth-remove-card.small.png b/assets/img/cards/card-earth-remove-card.small.png
new file mode 100644
index 0000000..faffc81
Binary files /dev/null and b/assets/img/cards/card-earth-remove-card.small.png differ
diff --git a/assets/img/cards/card-earth-stop.small.png b/assets/img/cards/card-earth-stop.small.png
new file mode 100644
index 0000000..5aeaef5
Binary files /dev/null and b/assets/img/cards/card-earth-stop.small.png differ
diff --git a/assets/img/cards/card-fire-2-diam.small.png b/assets/img/cards/card-fire-2-diam.small.png
new file mode 100644
index 0000000..6c8510b
Binary files /dev/null and b/assets/img/cards/card-fire-2-diam.small.png differ
diff --git a/assets/img/cards/card-fire-diam.small.png b/assets/img/cards/card-fire-diam.small.png
new file mode 100644
index 0000000..14ea24f
Binary files /dev/null and b/assets/img/cards/card-fire-diam.small.png differ
diff --git a/assets/img/cards/card-fire-remove-card.small.png b/assets/img/cards/card-fire-remove-card.small.png
new file mode 100644
index 0000000..49cc0fd
Binary files /dev/null and b/assets/img/cards/card-fire-remove-card.small.png differ
diff --git a/assets/img/cards/card-fire-stop.small.png b/assets/img/cards/card-fire-stop.small.png
new file mode 100644
index 0000000..9728b54
Binary files /dev/null and b/assets/img/cards/card-fire-stop.small.png differ
diff --git a/assets/img/cards/card-water-2-diam.small.png b/assets/img/cards/card-water-2-diam.small.png
new file mode 100644
index 0000000..5e6c2c6
Binary files /dev/null and b/assets/img/cards/card-water-2-diam.small.png differ
diff --git a/assets/img/cards/card-water-diam.small.png b/assets/img/cards/card-water-diam.small.png
new file mode 100644
index 0000000..373438d
Binary files /dev/null and b/assets/img/cards/card-water-diam.small.png differ
diff --git a/assets/img/cards/card-water-remove-card.small.png b/assets/img/cards/card-water-remove-card.small.png
new file mode 100644
index 0000000..97711d5
Binary files /dev/null and b/assets/img/cards/card-water-remove-card.small.png differ
diff --git a/assets/img/cards/card-water-stop.small.png b/assets/img/cards/card-water-stop.small.png
new file mode 100644
index 0000000..0d42b00
Binary files /dev/null and b/assets/img/cards/card-water-stop.small.png differ
diff --git a/card.h b/card.h
index e51917b..adbf0e2 100644
--- a/card.h
+++ b/card.h
@@ -1,15 +1,16 @@
#ifndef CARD_H
#define CARD_H
#include <string>
class Card
{
public:
Card();
int id;
int elementNumber;
int amount;
std::string cardType;
+ int cardTypeInt;
};
#endif // CARD_H
diff --git a/cardsdeck.cpp b/cardsdeck.cpp
index c8be54b..a7e9242 100644
--- a/cardsdeck.cpp
+++ b/cardsdeck.cpp
@@ -1,101 +1,134 @@
#include "cardsdeck.h"
CardsDeck::CardsDeck(TextureHolder *textures, sf::Font *gameFont)
{
std::array<std::array<int,2>,4> cardsPos = {
{
{1087,95}, {1225, 95}, {1225, 277}, {1087, 277}
}
};
this->textures = textures;
for (int i=0;i<=3;i++)
{
- spriteCardBases[i].setTexture(this->textures->textureCardBases[i]);
+// spriteCardBases[i].setTexture(this->textures->textureCardBases[i]);
spriteCardBases[i].setPosition(cardsPos[i][0],cardsPos[i][1]);
textPileTitle[i].setFont(*gameFont);
textPileTitle[i].setCharacterSize(10);
textPileTitle[i].setPosition(cardsPos[i][0]+10,cardsPos[i][1]+100);
- for (int j=0;j<efc::PILE_SIZE;j++)
+ for (int j=0;j<3;j++)
{
+ std::cout << j << std::endl;
+
cardsList[i].cardsPile[j].cardType = efc::cardsTypes[j];
+ cardsList[i].cardsPile[j].cardTypeInt = j;
+ spriteCardBases[i].setTexture(this->textures->cardsTextures[i][j]);
+
}
- setTitles();
+
cardsList[i].shufflePile();
+ nextCard(i);
+
+// setTitles();
+
+
}
}
void CardsDeck::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
for (int i=0;i<=3;i++)
{
if (cardsList[i].invisibleLeft==0.0f)
{
target.draw(spriteCardBases[i], states);
target.draw(textPileTitle[i], states);
}
}
}
-void CardsDeck::setTitles()
+void CardsDeck::setTitles(int number)
{
- for (int i=0;i<=3;i++)
- {
- textPileTitle[i].setString(getTitle(i));
- }
+
+ textPileTitle[number].setString(efc::cardsTypes[number]);
+ int val = cardsList[number].currentCard;
+ std::cout <<number<< " << hjehe >> " << getTitle(number) << " " << val << std::endl;
+
+ spriteCardBases[number].setTexture(textures->cardsTextures[number][val]);
+
+}
+
+void CardsDeck::setSprites(int number)
+{
+// for (int i=0;i<=3;i++)
+// {
+// int val = getCardTypeInt(i);
+// std::string title = getTitle(i);
+// std::cout <<i<< " << hjehe >> " << val << std::endl;
+
+// sf::Texture tmpText = textures->cardsTextures[i][val];
+// spriteCardBases[i].setTexture(tmpText);
+// }
}
void CardsDeck::setFonts(sf::Font *gameFont)
{
for (int i=0;i<=3;i++)
{
textPileTitle[i].setFont(*gameFont);
}
}
void CardsDeck::nextCard(int pileNumber)
{
cardsList[pileNumber].invisibleLeft = 0.75f;
int currentCard = getCurrentCard(pileNumber);
currentCard += 1;
- if (currentCard>efc::PILE_SIZE-1)
+ std::cout << currentCard << " ccard" << std::endl;
+ if ((currentCard>3) || (currentCard<0))
currentCard = 0;
cardsList[pileNumber].currentCard = currentCard;
- setTitles();
+ setTitles(pileNumber);
+// setSprites(pileNumber);
}
int CardsDeck::getCurrentCard(int pileNumber)
{
int currentCard = cardsList[pileNumber].currentCard;
return currentCard;
}
std::string CardsDeck::getTitle(int pileNumber)
{
- std::string currentText = cardsList[pileNumber].cardsPile[getCurrentCard(pileNumber)].cardType;
+ std::string currentText = efc::cardsTypes[getCardTypeInt(pileNumber)];
return currentText;
}
+int CardsDeck::getCardTypeInt(int pileNumber)
+{
+ int result = cardsList[pileNumber].cardsPile[getCurrentCard(pileNumber)].cardTypeInt;
+ return result;
+}
void CardsDeck::update(sf::Time deltaTime)
{
for (int i=0;i<=3;i++)
{
if (cardsList[i].invisibleLeft>0.0f)
{
cardsList[i].invisibleLeft -= deltaTime.asSeconds();
}
if (cardsList[i].invisibleLeft<0.0f)
{
cardsList[i].invisibleLeft = 0.0f;
}
}
}
diff --git a/cardsdeck.h b/cardsdeck.h
index ec61eba..da28c8e 100644
--- a/cardsdeck.h
+++ b/cardsdeck.h
@@ -1,34 +1,40 @@
#ifndef CARDSDECK_H
#define CARDSDECK_H
#include <array>
#include <SFML/Graphics.hpp>
#include <iostream>
#include "textureholder.h"
#include "cardslist.h"
namespace efc {
const static std::array<std::string, efc::PILE_SIZE> cardsTypes = {
"stop", "card", "diamond", "diamond x 2"
};
+
+
}
class CardsDeck: public sf::Drawable, public sf::Transformable
{
public:
CardsDeck(TextureHolder *textures, sf::Font *gameFont);
std::array<CardsList, 4> cardsList;
std::array<sf::Sprite, 4> spriteCardBases;
std::array<sf::Text, 4> textPileTitle;
TextureHolder *textures;
void draw(sf::RenderTarget &target, sf::RenderStates states) const;
- void setTitles();
+// void setTitles();
+ void setSprites(int number);
void setFonts(sf::Font *gameFont);
void nextCard(int pileNumber);
int getCurrentCard(int pileNumber);
std::string getTitle(int pileNumber);
void update(sf::Time deltaTime);
+ int getCardTypeInt(int pileNumber);
+ void setTitles(int number);
};
#endif // CARDSDECK_H
+
diff --git a/cardslist.h b/cardslist.h
index 381c4b3..d43b6f5 100644
--- a/cardslist.h
+++ b/cardslist.h
@@ -1,38 +1,38 @@
#ifndef CARDSLIST_H
#define CARDSLIST_H
#include <vector>
#include <array>
#include <iostream> // std::cout
#include <algorithm> // std::shuffle
#include <random> // std::default_random_engine
#include <chrono> // std::chrono::system_clock
#include "card.h"
namespace efc {
const static int PILE_SIZE = 4;
}
class CardsList
{
public:
CardsList(); // To create an array of CardsList
CardsList(int element);
int amount;
// std::vector<Card*> sd;
/*!
* \brief element Number of the element
*/
- std::array<Card, efc::PILE_SIZE> cardsPile;
+ std::array<Card, 4> cardsPile;
int currentCard;
int element; /*!< Number of the element */
float invisibleLeft;
void shufflePile();
};
#endif // CARDSLIST_H
diff --git a/textureholder.cpp b/textureholder.cpp
index 866b612..f455fe2 100644
--- a/textureholder.cpp
+++ b/textureholder.cpp
@@ -1,133 +1,141 @@
+#include <iostream>
#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()
{
+ // "stop", "card", "diamond", "diamond x 2"
+
std::string cardsImages[4][4] = {
- {"card-air-2-diam.png", "card-air-diam.png", "card-air-remove-card.png", "card-air-stop.png"},
- {"card-earth-2-diam.png","card-earth-diam.png","card-earth-remove-card.png","card-earth-stop.png"},
- {"card-fire-2-diam.png", "card-fire-diam.png","card-fire-remove-card.png", "card-fire-stop.png"},
- {"card-water-2-diam.png", "card-water-diam.png","card-water-remove-card.png","card-water-stop.png"}
+ {"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]))
{
+ 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"))
std::exit(1);
if (!textureCardBases[1].loadFromFile("assets/img/card-earth-2-diam_m.png"))
std::exit(1);
if (!textureCardBases[2].loadFromFile("assets/img/card-fire-2-diam_m.png"))
std::exit(1);
if (!textureCardBases[3].loadFromFile("assets/img/card-air-2-diam_m.png"))
std::exit(1);
// if (!textureGameBackground.loadFromFile("assets/img/game-ackground.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 90ca370..caafa41 100644
--- a/textureholder.h
+++ b/textureholder.h
@@ -1,49 +1,49 @@
#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;
sf::Texture textureCardBase0;
sf::Texture textureCardBase1;
sf::Texture textureCardBase2;
sf::Texture textureCardBase3;
std::array<sf::Texture, 4> textureCardBases;
std::map<int, std::map<int, int>> tilesDescription;
std::map<int, std::string> tilesTxt;
- sf::Texture cardsTextures[4][4];
+ std::array<std::array<sf::Texture,4>,4> cardsTextures;
};
#endif // TEXTUREHOLDER_H

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 16, 12:08 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70968
Default Alt Text
(16 KB)

Event Timeline