Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F134577
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
16 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a93d46..5f77e13 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,47 +1,48 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.0)
project(deerportal)
find_package(SFML 2.1 COMPONENTS graphics window audio system REQUIRED)
set(SOURCES
animatedsprite.cpp
animation.cpp
boarddiamond.cpp
boarddiamondseq.cpp
boardelem.cpp
boardelems.cpp
bubble.cpp
calendar.cpp
card.cpp
cardsdeck.cpp
cardslist.cpp
character.cpp
command.cpp
data.cpp
elem.cpp
game.cpp
grouphud.cpp
guirounddice.cpp
guiwindow.cpp
hover.cpp
main.cpp
particlesystem.cpp
pile.cpp
playerhud.cpp
rotateelem.cpp
rounddice.cpp
selector.cpp
soundfx.cpp
textureholder.cpp
tilemap.cpp
)
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -static-libgcc -static-libgcc")
endif()
-
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
include_directories(${SFML_INCLUDE_DIR})
add_executable(deerportal ${SOURCES})
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED 11)
target_link_libraries(deerportal ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
diff --git a/animatedsprite.cpp b/animatedsprite.cpp
index 3e951d6..a7a4f4f 100644
--- a/animatedsprite.cpp
+++ b/animatedsprite.cpp
@@ -1,195 +1,196 @@
////////////////////////////////////////////////////////////
//
// Copyright (C) 2014 Maximilian Wagenbach (aka. Foaly) (foaly.f@web.de)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
// This file has been created using Maximilian Wagenbach (aka. Foaly) sources
// further modificated. Thank you Foaly.
#include "animatedsprite.h"
+#include <cmath>
AnimatedSprite::AnimatedSprite(sf::Time frameTime, bool paused, bool looped) :
m_animation(NULL), m_frameTime(frameTime), m_currentFrame(0), m_isPaused(paused), m_isLooped(looped), m_texture(NULL)
{
// setScale(1.9,1.9);
setFrameTime(sf::seconds(0.5f));
setFrameTime(sf::seconds(0.5f));
}
void AnimatedSprite::setAnimation(const Animation& animation)
{
m_animation = &animation;
m_texture = m_animation->getSpriteSheet();
m_currentFrame = 0;
setFrame(m_currentFrame);
}
void AnimatedSprite::setFrameTime(sf::Time time)
{
m_frameTime = time;
}
void AnimatedSprite::play()
{
m_isPaused = false;
}
void AnimatedSprite::play(const Animation& animation)
{
if (getAnimation() != &animation)
setAnimation(animation);
play();
}
void AnimatedSprite::pause()
{
m_isPaused = true;
}
void AnimatedSprite::stop()
{
m_isPaused = true;
m_currentFrame = 0;
setFrame(m_currentFrame);
}
void AnimatedSprite::setLooped(bool looped)
{
m_isLooped = looped;
}
void AnimatedSprite::setColor(const sf::Color& color)
{
// Update the vertices' color
m_vertices[0].color = color;
m_vertices[1].color = color;
m_vertices[2].color = color;
m_vertices[3].color = color;
}
const Animation* AnimatedSprite::getAnimation() const
{
return m_animation;
}
sf::FloatRect AnimatedSprite::getLocalBounds() const
{
sf::IntRect rect = m_animation->getFrame(m_currentFrame);
- float width = static_cast<float>(std::abs(rect.width));
- float height = static_cast<float>(std::abs(rect.height));
+ float width = static_cast<float>(std::fabs(rect.width));
+ float height = static_cast<float>(std::fabs(rect.height));
return sf::FloatRect(0.f, 0.f, width, height);
}
sf::FloatRect AnimatedSprite::getGlobalBounds() const
{
return getTransform().transformRect(getLocalBounds());
}
bool AnimatedSprite::isLooped() const
{
return m_isLooped;
}
bool AnimatedSprite::isPlaying() const
{
return !m_isPaused;
}
sf::Time AnimatedSprite::getFrameTime() const
{
return m_frameTime;
}
void AnimatedSprite::setFrame(std::size_t newFrame, bool resetTime)
{
if (m_animation)
{
//calculate new vertex positions and texture coordiantes
sf::IntRect rect = m_animation->getFrame(newFrame);
m_vertices[0].position = sf::Vector2f(0.f, 0.f);
m_vertices[1].position = sf::Vector2f(0.f, static_cast<float>(rect.height));
m_vertices[2].position = sf::Vector2f(static_cast<float>(rect.width), static_cast<float>(rect.height));
m_vertices[3].position = sf::Vector2f(static_cast<float>(rect.width), 0.f);
float left = static_cast<float>(rect.left) + 0.0001f;
float right = left + static_cast<float>(rect.width);
float top = static_cast<float>(rect.top);
float bottom = top + static_cast<float>(rect.height);
m_vertices[0].texCoords = sf::Vector2f(left, top);
m_vertices[1].texCoords = sf::Vector2f(left, bottom);
m_vertices[2].texCoords = sf::Vector2f(right, bottom);
m_vertices[3].texCoords = sf::Vector2f(right, top);
}
if (resetTime)
m_currentTime = sf::Time::Zero;
}
void AnimatedSprite::update(sf::Time deltaTime)
{
// if not paused and we have a valid animation
if (!m_isPaused && m_animation)
{
// add delta time
m_currentTime += deltaTime;
// if current time is bigger then the frame time advance one frame
if (m_currentTime >= m_frameTime)
{
// reset time, but keep the remainder
m_currentTime = sf::microseconds(m_currentTime.asMicroseconds() % m_frameTime.asMicroseconds());
// get next Frame index
if (m_currentFrame == 0)
m_currentFrame++;
else
{
// animation has ended
m_currentFrame = 0; // reset to start
if (!m_isLooped)
{
m_isPaused = true;
}
}
// set the current frame, not reseting the time
setFrame(m_currentFrame, false);
}
}
}
void AnimatedSprite::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
if (m_animation && m_texture)
{
states.transform *= getTransform();
states.texture = m_texture;
target.draw(m_vertices, 4, sf::Quads, states);
}
}
diff --git a/bubble.cpp b/bubble.cpp
index 191f797..dc91b0e 100644
--- a/bubble.cpp
+++ b/bubble.cpp
@@ -1,39 +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"))
std::exit(1);
if (!textureFootSteps.loadFromFile("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/data.cpp b/data.cpp
index a4023b6..99d53b7 100644
--- a/data.cpp
+++ b/data.cpp
@@ -1,127 +1,128 @@
+#include <array>
#include "data.h"
namespace efc {
std::string seasonsNames[4] = {"winter", "spring", "summer", "fall"};
// This array defines fields occupied by the river
int terrainArray[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
};
/*
* 0
* 16
* 32
* 48
* 64
* 80
* 96
* 112
* 128
* 144
* 160
* 176
* 192
*/
std::array<std::array<int,2>,256> boards = {
{
{{-1,1}}, {{0,2}}, {{1,3}}, {{2,4}}, {{3,5}}, {{4,21}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{11,26}}, {{12,10}}, {{13,11}}, {{14,12}}, {{15,13}}, {{-1,14}},
{{-1,-1}}, {{18,33}}, {{19,17}}, {{20,18}}, {{21,19}}, {{5,20}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{10, 27,}}, {{26,28}}, {{27,29}}, {{28,30}}, {{29,46}}, {{-1,-1}},
{{33,48}}, {{17,32}}, {{-1,-1}}, {{51,36}}, {{35,37}}, {{36,38}}, {{37,54}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{43,58}}, {{44,42}}, {{60,43}}, {{-1,-1}}, {{30,47}}, {{46,63}},
{{32,49}}, {{48,50}}, {{49,51}}, {{50,35}}, {{-1,-1}}, {{54,69}}, {{38,53}}, {{-1,-1}}, {{-1,-1}}, {{58,73}}, {{42,57}}, {{-1,-1}}, {{61,44}}, {{62,60}}, {{63,61}}, {{47,62}},
{{65,80}}, {{66,64}}, {{67,65}}, {{68,66}}, {{69,67}}, {{53,68}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{57,74}}, {{73,75}}, {{74,76}}, {{75,77}}, {{76,78}}, {{77,79}}, {{78,95}},
{{64,81}}, {{80,97}}, {{-1,-1}}, {{99,84}}, {{83,85}}, {{84,101}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{90,105}}, {{91,89}}, {{92,90}}, {{108,91}}, {{-1,-1}}, {{95,110}}, {{79,94}},
{{-1,-1}}, {{81,98}}, {{97,99}}, {{98,83}}, {{-1,-1}}, {{85,102}}, {{101,118}}, {{-1,-1}}, {{105,120}}, {{89,104}}, {{-1,-1}}, {{-1,-1}}, {{109,92}}, {{110,108}}, {{94,109}}, {{-1,-1}},
{{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{102, 119}},{{118,-2}}, {{104,-2}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}},
{{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}} , {{151,-2}}, {{137,-2}}, {{153,136}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}},
{{-1,-1}}, {{161,146}}, {{145,147}}, {{146,163}}, {{-1,-1}}, {{-1,-1}}, {{166,151}}, {{150,135}} ,{{-1,-1}}, {{154,137}}, {{170,153}}, {{-1,-1}}, {{157,172}}, {{158,156}}, {{174,157}}, {{-1,-1}},
{{176,161}},{{160,145}}, {{-1,-1}}, {{147,164}}, {{163,165}}, {{164,166}}, {{165,150}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{171,154}}, {{172,170}}, {{156,171}}, {{-1,-1}}, {{175,158}}, {{191,174}},
{{177,160}},{{178,176}}, {{179,177}}, {{180,178}}, {{181,179}}, {{182,180}}, {{198,181}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{202,187}}, {{186,188}}, {{187,189}}, {{188,190}}, {{189,191}}, {{190,175}},
{{208,193}},{{192,194}}, {{193,195}}, {{194,211}}, {{-1,-1}}, {{213,198}}, {{197,182}}, {{-1,-1}}, {{-1,-1}}, {{217,202}}, {{201,186}}, {{-1,-1}}, {{205,220}}, {{206,204}}, {{207,205}}, {{223,206}},
{{209,192}},{{225,208}}, {{-1,-1}}, {{195,212}}, {{211,213}}, {{212,197}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{218,201}}, {{219,217}}, {{220,218}}, {{204,219}}, {{-1,-1}}, {{238,223}}, {{222,207}},
{{-1,-1}}, {{226,209}}, {{227,225}}, {{228,226}}, {{229,227}}, {{245,228}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{250,235}}, {{234,236}}, {{235,237}}, {{236,238}}, {{237,222}}, {{-1,-1}},
{{-1,241}}, {{240,242}},{{241,243}}, {{242,244}}, {{243,245}}, {{244,229}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{-1,-1}}, {{251,234}}, {{252,250}}, {{253,251}}, {{254,252}}, {{255,253}}, {{-1,254}},
},
};
std::array<std::array<int,numberSteps>,4> occupiedFields =
{
{
{{1,2,3,4,5,17,18,19,20,21,32,33,35,36,37,38,48,49,50,51,53,54,64,65,66,67,68,69,80,81,83,84,85,97,98,99,101,102,118}},
{{10,11,12,13,14,26,27,28,29,30,42,43,44,46,47,57,58,60,61,62,63,73,74,75,76,77,78,79,89,90,91,92,94,95,104,105,108,109,110}},
{{145,146,147,150,151,160,161,163,164,165,166,176,177,178,179,180,181,182,192,193,194,195,197,198,208,209,211,212,213,225,226,227,228,229,241,242,243,244,245}},
{{137,153,154,156,157,158,170,171,172,174,175,186,187,188,189,190,191,201,202,204,205,206,207,217,218,219,220,222,223,234,235,236,237,238,250,251,252,253,254}}
}
};
sf::Color playersColors[4] = {
sf::Color(122, 185,246,255),
sf::Color(144, 226,106,255),
sf::Color(255, 163,142,255),
sf::Color(250, 255,117,255),
};
std::array<std::array<int,3>,efc::diamondsNumber> DIAMONDS_SETUP =
{
{
{{0,0,-1}},{{0,0,-1}},
{{1,0,-1}},{{1,0,-1}},
{{2,0,-1}},{{2,0,-1}},
{{3,0,-1}},{{3,0,-1}},
{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},
{{0,0,-1}},{{0,0,-1}},
{{1,0,-1}},{{1,0,-1}},
{{2,0,-1}},{{2,0,-1}},
{{3,0,-1}},{{3,0,-1}},
{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},{{4,0,-1}},
{{0,1,-1}},{{0,1,-1}},
{{1,1,-1}},{{1,1,-1}},
{{2,1,-1}},{{2,1,-1}},
{{3,1,-1}},{{3,1,-1}},
{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},
{{0,1,-1}},{{0,1,-1}},
{{1,1,-1}},{{1,1,-1}},
{{2,1,-1}},{{2,1,-1}},
{{3,1,-1}},{{3,1,-1}},
{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},{{4,1,-1}},
{{0,3,-1}},{{0,3,-1}},
{{1,3,-1}},{{1,3,-1}},
{{2,3,-1}},{{2,3,-1}},
{{3,3,-1}},{{3,3,-1}},
{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},
{{0,3,-1}},{{0,3,-1}},
{{1,3,-1}},{{1,3,-1}},
{{2,3,-1}},{{2,3,-1}},
{{3,3,-1}},{{3,3,-1}},
{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},{{4,3,-1}},
{{0,2,-1}},{{0,2,-1}},
{{1,2,-1}},{{1,2,-1}},
{{2,2,-1}},{{2,2,-1}},
{{3,2,-1}},{{3,2,-1}},
{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},
{{0,2,-1}},{{0,2,-1}},
{{1,2,-1}},{{1,2,-1}},
{{2,2,-1}},{{2,2,-1}},
{{3,2,-1}},{{3,2,-1}},
{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},{{4,2,-1}},
}
} ;
}
diff --git a/textureholder.h b/textureholder.h
index 57df59b..a0b3542 100644
--- a/textureholder.h
+++ b/textureholder.h
@@ -1,57 +1,57 @@
#ifndef TEXTUREHOLDER_H
#define TEXTUREHOLDER_H
#include <set>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "data.h"
-
+#include <array>
namespace efc {
std::set<int> getTerrainSet();
}
/*!
* \brief The TextureHolder contains most textures.
*/
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;
sf::Texture textureButtonCpu;
sf::Texture textureButtonHuman;
sf::Texture textureDeerGod;
std::array<sf::Texture, 4> textureCardBases;
std::map<int, std::map<int, int>> tilesDescription;
std::map<int, std::string> tilesTxt;
std::array<std::array<sf::Texture,4>,4> cardsTextures;
};
#endif // TEXTUREHOLDER_H
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Jun 17, 10:19 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69715
Default Alt Text
(16 KB)
Attached To
Mode
R82 deerportal
Attached
Detach File
Event Timeline