Page MenuHomePhabricator (Chris)

No OneTemporary

Size
21 KB
Referenced Files
None
Subscribers
None
diff --git a/boarddiamond.cpp b/boarddiamond.cpp
index bdc6cd6..96e570b 100644
--- a/boarddiamond.cpp
+++ b/boarddiamond.cpp
@@ -1,24 +1,27 @@
#include "boarddiamond.h"
BoardDiamond::BoardDiamond()
{
}
-BoardDiamond::BoardDiamond(TextureHolder *textures, int idNumber)
+BoardDiamond::BoardDiamond(TextureHolder *textures, int idNumber,
+ int element, int boardPosition)
{
this->textures = textures;
+ this->element = element;
+ this->boardPosition = boardPosition;
spriteHolder.setTexture(this->textures->textureBoardDiamond);
sf::IntRect textureRect(idNumber*44, 44, (idNumber*44)+idNumber,44);
spriteHolder.setTextureRect(textureRect);
}
void BoardDiamond::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
// target.draw(animatedSprite, states);
}
void BoardDiamond::update(sf::Time deltaTime, std::set<int> &busyTiles)
{
}
diff --git a/boarddiamond.h b/boarddiamond.h
index 98c9976..0f9c4f5 100644
--- a/boarddiamond.h
+++ b/boarddiamond.h
@@ -1,23 +1,24 @@
#ifndef BOARDDIAMOND_H
#define BOARDDIAMOND_H
#include <set>
#include "textureholder.h"
-
+#include "elem.h"
#include <SFML/Graphics.hpp>
-class BoardDiamond: public sf::Drawable, public sf::Transformable
+class BoardDiamond: public Elem
{
public:
BoardDiamond();
- BoardDiamond(TextureHolder *textures, int idNumber);
+ BoardDiamond(TextureHolder *textures, int idNumber,
+ int element, int boardPosition);
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
void update(sf::Time deltaTime, std::set<int>& busyTiles);
TextureHolder *textures;
- int idNumber;
-
+ int idNumber; // number from the sprite sheet
+ int element; // 0-3 elements area on the board
sf::Sprite spriteHolder;
};
#endif // BOARDDIAMOND_H
diff --git a/boarddiamondseq.cpp b/boarddiamondseq.cpp
index 0eb4bde..08d9668 100644
--- a/boarddiamondseq.cpp
+++ b/boarddiamondseq.cpp
@@ -1,19 +1,29 @@
#include "boarddiamondseq.h"
-BoardDiamondSeq::BoardDiamondSeq(TextureHolder *textures, int idNuber)
+BoardDiamondSeq::BoardDiamondSeq(TextureHolder *textures)
{
this->textures = textures;
+
+ diamonds[0] = BoardDiamond(textures, 0,0, 5);
+ diamonds[1] = BoardDiamond(textures, 0,0, 6);
+ diamonds[2] = BoardDiamond(textures, 1,0, 7);
+ diamonds[3] = BoardDiamond(textures, 1,0, 17);
+
}
void BoardDiamondSeq::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
- // target.draw(animatedSprite, states);
+ for (int i=1; i<DIAMONDS_NUMBER; i++)
+ {
+
+ target.draw(diamonds[i],states);
+ }
}
void BoardDiamondSeq::update(sf::Time deltaTime, std::set<int> &busyTiles)
{
}
diff --git a/boarddiamondseq.h b/boarddiamondseq.h
index 95964dd..f48e6b7 100644
--- a/boarddiamondseq.h
+++ b/boarddiamondseq.h
@@ -1,20 +1,37 @@
#ifndef BOARDDIAMONDSEQ_H
#define BOARDDIAMONDSEQ_H
#include <set>
#include "textureholder.h"
#include <SFML/Graphics.hpp>
+#include "boarddiamond.h"
+
+
+
+/*!
+ * \brief The BoardDiamondSeq class
+ * We are going to have 2 cards / diamonds of each element per each area,
+ * which gives 2*4*4 = 32 cards diamonds of elements on the board.
+ *
+ * Additionally there will be extra 6 white diamonds per area to collect, which
+ * gives 4*6 = 24 diamonds on the board.
+ *
+ * Together it would give 32 + 24 = 60 diamonds cards/diamonds together,
+ * 15 per area.
+ */
class BoardDiamondSeq : public sf::Drawable, public sf::Transformable
{
public:
- BoardDiamondSeq(TextureHolder *textures, int idNumber);
+ BoardDiamondSeq(TextureHolder *textures);
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
void update(sf::Time deltaTime, std::set<int>& busyTiles);
TextureHolder *textures;
- int idNumber;
+
+ const static int DIAMONDS_NUMBER = 4;
+ BoardDiamond diamonds[DIAMONDS_NUMBER];
};
#endif // BOARDDIAMONDSEQ_H
diff --git a/character.cpp b/character.cpp
index 26a61ae..49a99a7 100644
--- a/character.cpp
+++ b/character.cpp
@@ -1,368 +1,359 @@
#include "character.h"
/*!
* \brief Character::getMovements
* \return
*/
std::array<int,2> Character::getMovements(int howFar)
{
std::array<int,2> myArray;
if (howFar==7)
{
return std::array<int,2> {-1,-1};
}
if (active==true)
{
// std::cout << "howfar: " <<howFar <<std::endl;
int indexRight = boardPosition;
for (int i=boardPosition;i<=boardPosition+howFar-1;i++)
{
if (indexRight==-1)
break;
indexRight = efc::boards[indexRight][1];
// std::cout << " howfar" << howFar << " index R" << indexRight
// << " move L " << moveLeft << " move R " << moveRight << " dice " << diceResult
// << std::endl;
if (indexRight==-1)
break;
}
moveRight = indexRight;
int indexLeft = boardPosition;
for (int i=boardPosition;i>=boardPosition-howFar+1;i--)
{ if (indexLeft==-1)
break;
indexLeft = efc::boards[indexLeft][0];
// std::cout << " howfar" << howFar << " index l " << indexLeft
// << " move L " << moveLeft << " move R " << moveRight << " dice " << diceResult
// << std::endl;
if (indexLeft==-1)
break;
}
moveLeft = indexLeft;
myArray = {moveLeft,moveRight};
}
else
{
myArray = {-1,-1};
}
// std::cout << "howfar: " <<howFar << std::endl;
return myArray;
}
void Character::setDir(int direction)
{
if (direction==efc::DIR_LEFT)
currentAnimation = &walkingAnimationLeft;
}
void Character::setDir()
{
setDir(currentAnimationIndex);
}
void Character::setDirIndex(int direction)
{
currentAnimationIndex = direction;
}
void Character::play()
{
// animatedSprite.play(*currentAnimation);
animatedSprite.play(animations[currentAnimationIndex]);
sf::Vector2f a(getPosition());
sf::Vector2i position(efc::getCords(a));
// std::cout << a.x << " " << a.y << " "
// << position.x << " " << position.y << " pos > "
// << getBoardPosition() << std::endl;
}
Character::Character(TextureHolder *textures, int playerNumber):
animatedSprite(sf::seconds(0.2), true, false),
nextRedirect(0.f)
{
drawMovements = false;
this->textures = textures;
int offset = playerNumber*16;
active = false;
rectangleLeft.setFillColor(sf::Color(12, 12, 12,120));
rectangleLeft.setOutlineColor(sf::Color(24,24,40, 255));
rectangleRight.setFillColor(sf::Color(240, 240, 240,98));
rectangleRight.setOutlineColor(sf::Color(24,40,24, 90));
walkingAnimationDown.setSpriteSheet(textures->textureCharacters);
walkingAnimationDown.addFrame(sf::IntRect(offset, 0, 16, 24));
walkingAnimationDown.addFrame(sf::IntRect(offset, 24, 16, 24));
walkingAnimationRight.setSpriteSheet(textures->textureCharacters);
walkingAnimationRight.addFrame(sf::IntRect(offset, 48, 16, 24));
walkingAnimationRight.addFrame(sf::IntRect(offset, 72, 16, 24));
walkingAnimationLeft.setSpriteSheet(textures->textureCharacters);
walkingAnimationLeft.addFrame(sf::IntRect(offset, 96, 16, 24));
walkingAnimationLeft.addFrame(sf::IntRect(offset, 120, 16, 24));
walkingAnimationUp.setSpriteSheet(textures->textureCharacters);
walkingAnimationUp.addFrame(sf::IntRect(offset, 144, 16, 24));
walkingAnimationUp.addFrame(sf::IntRect(offset, 168, 16, 24));
currentAnimation = &walkingAnimationRight;
leftChar.setTexture(textures->textureCharacters);
leftChar.setTextureRect(sf::IntRect(offset, 96, 16, 24));
rightChar.setTexture(textures->textureCharacters);
rightChar.setTextureRect(sf::IntRect(offset, 48, 16, 24));
leftChar.scale(0.75,0.75);
rightChar.scale(0.75,0.75);
animations[efc::DIR_LEFT] = walkingAnimationLeft;
animations[efc::DIR_RIGHT] = walkingAnimationRight;
animations[efc::DIR_UP] = walkingAnimationUp;
animations[efc::DIR_DOWN] = walkingAnimationDown;
setDirIndex(efc::DIR_LEFT);
setDir();
sf::Vector2f positions[4] = {
sf::Vector2f(0, 0),
sf::Vector2f(20, 40),
sf::Vector2f(20, 240),
sf::Vector2f(40, 240)
};
std::array<int, 4> boardPositions{0,15,255-15,255};
// std::cout << "define " << playerNumber << std::endl;
setBoardPosition(boardPositions[playerNumber]);
}
void Character::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
target.draw(animatedSprite, states);
if ((active==true) && (drawMovements==true))
{
if (moveLeft>-1)
{
// std::cout << "draw " << rectangleLeft.getPosition().x << " " << rectangleLeft.getPosition().y << std::endl;
target.draw(leftChar);
}
if (moveRight>-1)
{
// std::cout << "draw R" << rectangleRight.getPosition().x << " " << rectangleRight.getPosition().y << std::endl;
target.draw(rightChar);
// target.draw(rectangleRight, 4, sf::Quads, states);
}
}
}
void Character::update(sf::Time deltaTime, std::set<int> &busyTiles)
{
sf::Vector2f a(getPosition());
sf::Vector2i position(efc::getCords(a));
int charPos = efc::transCords(position);
// std::cout << a.x << " " << a.y << " " << position.x << " " << position.y << " " << charPos << std::endl;
nextRedirect -= deltaTime.asSeconds();
if (nextRedirect<0)
{
int number = rand() % 2;
if ((currentAnimationIndex==efc::DIR_LEFT) || (currentAnimationIndex==efc::DIR_RIGHT))
{
if (number==0){
setDirIndex(efc::DIR_DOWN);
setDir();
} else if (number==1)
{
setDirIndex(efc::DIR_UP);
setDir();
}
} else if ((currentAnimationIndex==efc::DIR_UP) || (currentAnimationIndex==efc::DIR_DOWN))
{
if (number==0){
setDirIndex(efc::DIR_LEFT);
setDir();
} else if (number==1)
{
setDirIndex(efc::DIR_RIGHT);
setDir();
}
}
nextRedirect = rand() % 4;
}
if (currentAnimationIndex==efc::DIR_UP)
{
if (position.y<2)
{
setDirIndex(efc::DIR_DOWN);
setDir();
}
} else if (currentAnimationIndex==efc::DIR_DOWN)
{
if (position.y>efc::BOARD_SIZE-1)
{
setDirIndex(efc::DIR_UP);
setDir();
}
} else if (currentAnimationIndex==efc::DIR_LEFT)
{
if (position.x<2)
{
setDirIndex(efc::DIR_RIGHT);
setDir();
}
} else if (currentAnimationIndex==efc::DIR_RIGHT)
{
if (position.x>efc::BOARD_SIZE-1)
{
setDirIndex(efc::DIR_LEFT);
setDir();
}
}
animatedSprite.update(deltaTime);
std::array<int,2> movements(getMovements(diceResult));
int left = movements[0];
int right = movements[1];
if (active==true)
{
if (moveLeft>-1)
{
sf::Vector2i cordsLeft(efc::transPosition(moveLeft));
sf::Vector2i neededCords(efc::transPosition(moveLeft));
sf::Vector2f newPos(efc::getScreenPos(neededCords));
leftChar.setPosition(newPos.x+efc::TILE_SIZE/4,newPos.y);
}
if (moveRight>-1)
{
sf::Vector2i cordsRight(efc::transPosition(moveRight));
sf::Vector2i neededCords(efc::transPosition(moveRight));
sf::Vector2f newPos(efc::getScreenPos(neededCords));
rightChar.setPosition(newPos.x+efc::TILE_SIZE/4,newPos.y);
}
// std::cout << " dice " << diceResult<< moveLeft << " " << moveRight << std::endl;
}
}
sf::FloatRect Character::getLocalBounds() const
{
return sf::FloatRect(0.f, 0.f, 0, 0);
}
sf::FloatRect Character::getGlobalBounds() const
{
return getTransform().transformRect(getLocalBounds());
}
-/*!
- * \brief Character::getBoardPosition
- * \return
- */
-int Character::getBoardPosition()
-{
- sf::Vector2f currentPos(getPosition());
- sf::Vector2i currentCords(efc::getCords(currentPos));
- int currentBoardPosition = efc::transCords(currentCords);
- return currentBoardPosition;
-}
-
-/*!
- * \brief Character::setBoardPosition
- * \param boardPosition
- */
-
-
-
-
-
-void Character::setBoardPosition(int boardPosition)
-{
- sf::Vector2i neededCords(efc::transPosition(boardPosition));
-
- sf::Vector2f newPos(efc::getScreenPos(neededCords));
-
- setPosition(newPos.x, newPos.y);
- this->boardPosition = boardPosition;
-
- std::array<int,2> movements(getMovements(diceResult));
- std::cout << "board pos >> " << boardPosition << " cords >>" << neededCords.x << " " << neededCords.y
- << "newpos >> " << newPos.x << " " << newPos.y << " "
- << "movements >> " << movements[0] << " " << movements[1]
- << std::endl;
-
- sf::Vector2i newVecPos(getPosition());
- sf::FloatRect newSize(getGlobalBounds());
- float newX = newVecPos.x + (efc::TILE_SIZE/3);
-// newX = newX - (newSize.width);
- setPosition(newX, newPos.y);
-
-
-
-
-
-}
+///*!
+// * \brief Character::/*get*/BoardPosition
+// * \return
+// */
+//int Character::getBoardPosition()
+//{
+// sf::Vector2f currentPos(getPosition());
+// sf::Vector2i currentCords(efc::getCords(currentPos));
+// int currentBoardPosition = efc::transCords(currentCords);
+// return currentBoardPosition;
+//}
+
+///*!
+// * \brief Character::setBoardPosition
+// * \param boardPosition
+// */
+
+//void Character::setBoardPosition(int boardPosition)
+//{
+// sf::Vector2i neededCords(efc::transPosition(boardPosition));
+
+// sf::Vector2f newPos(efc::getScreenPos(neededCords));
+
+// setPosition(newPos.x, newPos.y);
+// this->boardPosition = boardPosition;
+
+// std::array<int,2> movements(getMovements(diceResult));
+// std::cout << "board pos >> " << boardPosition << " cords >>" << neededCords.x << " " << neededCords.y
+// << "newpos >> " << newPos.x << " " << newPos.y << " "
+// << "movements >> " << movements[0] << " " << movements[1]
+// << std::endl;
+
+// sf::Vector2i newVecPos(getPosition());
+// sf::FloatRect newSize(getGlobalBounds());
+// float newX = newVecPos.x + (efc::TILE_SIZE/3);
+//// newX = newX - (newSize.width);
+// setPosition(newX, newPos.y);
+//}
diff --git a/character.h b/character.h
index 4d77fdf..fa7e08f 100644
--- a/character.h
+++ b/character.h
@@ -1,63 +1,63 @@
#ifndef CHARACTER_H
#define CHARACTER_H
#include <random>
#include <iostream>
#include "data.h"
#include "textureholder.h"
#include "animatedsprite.h"
#include "tilemap.h"
-#include "character.h"
+#include "elem.h"
-
-class Character: public sf::Drawable, public sf::Transformable
+class Character: public Elem
{
public:
Character(TextureHolder *textures, int playerNumber);
TextureHolder *textures;
Animation walkingAnimationDown;
Animation walkingAnimationUp;
Animation walkingAnimationLeft;
Animation walkingAnimationRight;
Animation animations[4];
Animation* currentAnimation;
int currentAnimationIndex;
sf::Sprite leftChar;
sf::Sprite rightChar;
AnimatedSprite animatedSprite;
sf::FloatRect getLocalBounds() const;
sf::FloatRect getGlobalBounds() const;
void setDirUp();
void setDirDown();
void setDirLeft();
void setDirRight();
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
void update(sf::Time deltaTime, std::set<int>& busyTiles);
void play();
void setDir();
void setDir(int direction);
void setDirIndex(int direction);
float nextRedirect;
std::array<int,2> getMovements(int howFar);
- void setBoardPosition(int boardPosition);
- int getBoardPosition();
- int boardPosition;
+// void setBoardPosition(int boardPosition);
+// int getBoardPosition();
+// int boardPosition;
+
int diceResult;
sf::RectangleShape rectangleLeft;
sf::RectangleShape rectangleRight;
int moveLeft;
int moveRight;
bool active;
bool drawMovements;
};
#endif // CHARACTER_H
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..d1402af
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,6 @@
+pagan-board (1.0-1) precise; urgency=low
+
+ * Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
+
+ -- bluszcz <bluszcz@bluszcz.net> Sat, 06 Feb 20166 21:23:34 +0100
+
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..c407c77
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,15 @@
+Source: pagan-board
+Section: games
+Priority: optional
+Maintainer: Bluszcz <bluszcz@bluszcz.net>
+Build-Depends: debhelper (>= 9), qtbase5-dev, qtbase5-dev-tools, qt5-qmake
+Standards-Version: 3.9.6
+Homepage: https://github.com/bluszcz/pagan-board
+
+Package: pagan-board
+Architecture: any
+Depends: libqt5gui5, libqt5widgets5, libqt5core5a, ${misc:Depends}, ${shlibs:Depends}
+Description: Game
+ SFML / Pagan / Board Linux
+ Etc etc
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..1d3c8af
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,3 @@
+#!/usr/bin/make -f
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/qmake.mk
diff --git a/elem.cpp b/elem.cpp
new file mode 100644
index 0000000..025b38d
--- /dev/null
+++ b/elem.cpp
@@ -0,0 +1,45 @@
+#include "elem.h"
+
+Elem::Elem()
+{
+
+}
+
+/*!
+ * \brief Character::getBoardPosition
+ * \return
+ */
+int Elem::getBoardPosition()
+{
+ sf::Vector2f currentPos(getPosition());
+ sf::Vector2i currentCords(efc::getCords(currentPos));
+ int currentBoardPosition = efc::transCords(currentCords);
+ return currentBoardPosition;
+}
+
+/*!
+ * \brief Character::setBoardPosition
+ * \param boardPosition
+ */
+
+void Elem::setBoardPosition(int boardPosition)
+{
+ sf::Vector2i neededCords(efc::transPosition(boardPosition));
+
+ sf::Vector2f newPos(efc::getScreenPos(neededCords));
+
+ setPosition(newPos.x, newPos.y);
+ this->boardPosition = boardPosition;
+
+// std::array<int,2> movements(getMovements(diceResult));
+// std::cout << "board pos >> " << boardPosition << " cords >>" << neededCords.x << " " << neededCords.y
+// << "newpos >> " << newPos.x << " " << newPos.y << " "
+// << "movements >> " << movements[0] << " " << movements[1]
+// << std::endl;
+
+ sf::Vector2i newVecPos(getPosition());
+// sf::FloatRect newSize(getGlobalBounds());
+ float newX = newVecPos.x + (efc::TILE_SIZE/3);
+// newX = newX - (newSize.width);
+ setPosition(newX, newPos.y);
+}
diff --git a/elem.h b/elem.h
new file mode 100644
index 0000000..8a605fe
--- /dev/null
+++ b/elem.h
@@ -0,0 +1,16 @@
+#ifndef ELEM_H
+#define ELEM_H
+#include <SFML/Graphics.hpp>
+#include "data.h"
+#include "tilemap.h"
+
+class Elem: public sf::Drawable, public sf::Transformable
+{
+public:
+ Elem();
+ void setBoardPosition(int boardPosition);
+ int getBoardPosition();
+ int boardPosition;
+};
+
+#endif // ELEM_H
diff --git a/pagan_board.pro b/pagan_board.pro
index ddeee37..be1b7d1 100644
--- a/pagan_board.pro
+++ b/pagan_board.pro
@@ -1,65 +1,67 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += c++11
SOURCES += main.cpp \
game.cpp \
tilemap.cpp \
selector.cpp \
playerhud.cpp \
boardelem.cpp \
boardelems.cpp \
textureholder.cpp \
hover.cpp \
guiwindow.cpp \
purchaseguielem.cpp \
guichoosebuilding.cpp \
rounddice.cpp \
guirounddice.cpp \
grouphud.cpp \
animation.cpp \
animatedsprite.cpp \
character.cpp \
data.cpp \
rotateelem.cpp \
boarddiamond.cpp \
- boarddiamondseq.cpp
+ boarddiamondseq.cpp \
+ elem.cpp
LIBS += -lsfml-window -lsfml-system -lsfml-graphics -lsfml-audio
DESTDIR = ../build_release_pagan_board
assets.path = $${DESTDIR}/assets
assets.files = assets/*
INSTALLS += assets
HEADERS += \
game.h \
tilemap.h \
selector.h \
playerhud.h \
boardelem.h \
boardelems.h \
textureholder.h \
hover.h \
guiwindow.h \
purchaseguielem.h \
guichoosebuilding.h \
elemsdescription.h \
rounddice.h \
guirounddice.h \
grouphud.h \
data.h \
animation.h \
animatedsprite.h \
character.h \
rotateelem.h \
boarddiamond.h \
- boarddiamondseq.h
+ boarddiamondseq.h \
+ elem.h
OTHER_FILES += \
CREDITS.md
QMAKE_CXXFLAGS += -std=gnu++0x

File Metadata

Mime Type
text/x-diff
Expires
Wed, Feb 4, 2:09 PM (14 h, 42 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55607
Default Alt Text
(21 KB)

Event Timeline