Skip to content

Commit

Permalink
Merge pull request #47 from Ipagaxi/char-act
Browse files Browse the repository at this point in the history
some new stuff
  • Loading branch information
Ipagaxi authored Apr 28, 2024
2 parents 3f946c5 + 4a22318 commit 55f46d3
Show file tree
Hide file tree
Showing 64 changed files with 1,142 additions and 760 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ file(GLOB source_files
"src/main/*.cpp"
"src/main/Activities/*.cpp"
"src/main/UIElements/*.cpp"
"src/main/UIComponents/*.cpp"
"src/main/Actors/*.cpp"
"src/main/Animations/*.cpp"
"src/main/UI_Objects/*.cpp"
"src/main/UIObjects/*.cpp"
"src/main/FightStates/*.cpp"
)
set(SOURCES ${source_files})

Expand Down
13 changes: 11 additions & 2 deletions src/include/Activities/Activity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>
#include "GameEvents.hpp"
#include "ActivityEnum.hpp"
#include "UIElements/UIButton.hpp"

class GameState;
class Game;

class Activity {
public:
Activity(Game &game);
virtual ~Activity();
virtual void executeActivity(GameState &gameState);
virtual ActivityEnum executeActivity(Game &game);

private:

protected:
UIButton exitButton = UIButton("buttonClose/buttonClose.png");
};

#endif
20 changes: 20 additions & 0 deletions src/include/Activities/CharacterActivity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef CHARACTERACTIVITY_HPP
#define CHARACTERACTIVITY_HPP

#include "Activities/Activity.hpp"
#include "Defines.hpp"
#include "Game.hpp"

class CharacterActivity : public Activity {
public :
CharacterActivity(Game &game);

ActivityEnum executeActivity(Game &game) override;


private :
sf::Texture backgroundTX;
sf::Sprite backgroundSP;
};

#endif
14 changes: 0 additions & 14 deletions src/include/Activities/CharacterManagementActivity.hpp

This file was deleted.

58 changes: 20 additions & 38 deletions src/include/Activities/FightActivity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,49 @@
#include <vector>
#include <string>
#include <SFML/Graphics.hpp>
#include <random>

#include "Activities/Activity.hpp"
#include "ActivityEnum.hpp"
#include "Animations/TextFadingManager.hpp"
#include "Animations/IncomingBanner.hpp"
#include "UIComponents/UIStats.hpp"
#include "UI_Objects/UIEnemyOverview.hpp"
#include "UI_Objects/UIPlayerOverview.hpp"
#include "Activities/MenuActivity.hpp"
#include "UIElements/UIStats.hpp"
#include "UIObjects/UIEnemyOverview.hpp"
#include "UIObjects/UIPlayerOverview.hpp"
#include "UIElements/UIColorPicker.hpp"
#include "UIElements/UIButton.hpp"
#include "UIElements/UIBox.hpp"
#include "Actors/Player.hpp"
#include "PerlinNoise.hpp"
#include "GameState.hpp"
#include "Game.hpp"
#include "Defines.hpp"
#include "Actors/Enemy.hpp"
#include "Color.hpp"
#include "FightEnv.hpp"
#include "FightStates/PlayersTurn.hpp"
#include "FightStates/EnemiesTurn.hpp"
#include "FightStates/TurnChangeState.hpp"
#include "FightStates/FightState.hpp"
#include "FightStateEnum.hpp"

class FightActivity: public Activity {
public:
FightActivity(GameState &gameState);
FightActivity(Game &game);
~FightActivity();

void executeActivity(GameState &gameState) override;
void runFight(GameState &gameState);
ActivityEnum executeActivity(Game &game) override;
void runCurrentState(Game &game);

private:
sf::Texture backgroundTX;
sf::Sprite backgroundSP;
UIButton exitButton = UIButton("buttonClose/buttonClose.png");
UIStats playerStatsBox;
UIEnemyOverview enemyOverview;
UIPlayerOverview playerOverview;
TextFadingManager textFadingManager;
sf::Texture playersTurnTX;
sf::Texture enemiesTurnTX;
sf::Sprite turnSP;
IncomingBanner turnChangeBanner;
sf::Music backgroundMusic;
FightEnv fightEnv;
FightStateEnum currentFightStateEnum = FightStateEnum::TURN_CHANGE;

sf::Color pickedColor;
int maxMultiplier = 2;
int isPlayersTurn;
bool enemyDamageCalculated = false;
bool turnIsChanging = true;
std::unique_ptr<FightState> currentFightState;

Enemy initEnemy();
void runPlayersTurn(GameState &gameState);
void runEnemiesTurn(GameState &gameState);
void runDefeat(GameState &gameState);
void runVictory(GameState &gameState);

// Compute damage multiplier
float mapInInterval(float value);
float calculateSingleMultPart(Color color);
float calculateAttackMult();
// Metrics in file DamageMultMetrics.cpp
float counterColorMetric(Color color);
float tugOfWarMetric(Color color);
void runPlayersTurn(Game &game);
void runEnemiesTurn(Game &game);
void runDefeat(Game &game);
void runVictory(Game &game);
};

#endif
17 changes: 9 additions & 8 deletions src/include/Activities/MenuActivity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
#include <SFML/Graphics.hpp>

#include "Activities/Activity.hpp"
#include "GameState.hpp"
#include "Activities/FightActivity.hpp"
#include "Game.hpp"
#include "Activities/CharacterActivity.hpp"
#include "Defines.hpp"
#include "UIElements/UIButton.hpp"

class MenuActivity: public Activity {
public:
MenuActivity(Game &game);
~MenuActivity();

ActivityEnum executeActivity(Game &game) override;

private:
sf::Texture backgroundTX;
sf::Sprite backgroundSP;
Expand All @@ -21,13 +27,8 @@ class MenuActivity: public Activity {


UIButton buttonFight = UIButton("Fight!", "button1/button1.png");
UIButton buttonCharacter = UIButton("Character", "button1/button1.png");
UIButton buttonExit = UIButton("Exit", "button1/button1.png");

public:
MenuActivity(GameState &gameState);
~MenuActivity();

void executeActivity(GameState &gameState) override;
};

#endif
3 changes: 2 additions & 1 deletion src/include/ActivityEnum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

enum ActivityEnum {
Fight,
Menu
Menu,
Character
};

#endif
22 changes: 13 additions & 9 deletions src/include/Animations/IncomingBanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
#define INCOMINGBANNER_HPP

#include <string>
#include <iostream>
#include <SFML/Graphics.hpp>

#include "GameState.hpp"
#include "Game.hpp"

class IncomingBanner {
public:
IncomingBanner(GameState &GameState);
IncomingBanner(GameState &gameState, std::string label);
IncomingBanner(Game &game);
IncomingBanner(Game &game, std::string label);

void setNewLabel(std::string newLabel);
void startAnimation();
void updateAnimation(GameState &gameState, bool &animationRuns);
void drawAnimation(sf::RenderWindow &gameWindow);
bool runAnimation(Game &game);
void drawAnimation(sf::RenderWindow* gameWindow);

private:
sf::RectangleShape banner;
sf::Text bannerText;
void init(GameState &gameState);
int pastTimeInMillSec = 0;
int pastMovementTime = 0;
bool animationStillActive = true;

sf::RectangleShape banner;
sf::Text bannerText;
void init(Game &game);
};

#endif
40 changes: 20 additions & 20 deletions src/include/Animations/TextFadingManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <thread>
#include <vector>

#include "GameState.hpp"
#include "Game.hpp"
#include "Defines.hpp"
#include "Animations/Animation.hpp"

Expand All @@ -20,32 +20,32 @@ enum AnimationPath {

class TextFading {
public:
TextFading();
TextFading(std::string text, sf::Vector2f pos, sf::Color textColor, int textSize, sf::Font _font);
sf::Font font;
sf::Text text;
int remainingVisibilty = 0;
int millSecToLive = 600;
AnimationPath animationPath = Right;
float pixelPerMillSec = 0.15;
// Used for parabel computation
int pastMillSec = 0;
float initPosY;
float initPosX;

void draw(GameState &gameState);
float computeParabel(float value);
void setNewParabelPos();
TextFading();
TextFading(std::string text, sf::Vector2f pos, sf::Color textColor, int textSize, sf::Font _font, int _millSecToLive);
sf::Font font;
sf::Text text;
int remainingVisibilty = 0;
int millSecToLive = 600;
AnimationPath animationPath = Right;
float pixelPerMillSec = 0.15;
// Used for parabel computation
int pastMillSec = 0;
float initPosY;
float initPosX;

void draw(sf::RenderWindow* gameWindow);
float computeParabel(float value);
void setNewParabelPos();

private:

};

class TextFadingManager: Animation {
public:
void run(GameState &gameState);
void startAnimation(GameState &gameState, std::string text, sf::Vector2f pos, sf::Color textColor, int textSize, AnimationPath animationPath);
void updateAnimationState(GameState &gameState);
void run(sf::RenderWindow* gameWindow, GameStatus &gameStatus);
void startAnimation(std::string text, sf::Vector2f pos, sf::Color textColor, int textSize, AnimationPath animationPath, int millSecToLive);
void updateAnimationState(GameStatus &gameStatus);
TextFading fadingText;
bool isRunning = false;
};
Expand Down
1 change: 1 addition & 0 deletions src/include/Defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define DEFINES_HPP

#define RESOURCE_PATH "./resources/"
#define REL_FONT_PATH "fonts/Avara-Bold.otf"
#define GEN_IMG_WIDTH 512
#define GEN_IMG_HEIGHT 512
#define NUM_ENEMY 5
Expand Down
34 changes: 34 additions & 0 deletions src/include/FightEnv.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef FIGHTEVENTS_HPP
#define FIGHTEVENTS_HPP

#include <SFML/Graphics.hpp>
#include "UIElements/UIStats.hpp"
#include "UIObjects/UIEnemyOverview.hpp"
#include "UIObjects/UIPlayerOverview.hpp"
#include "Animations/TextFadingManager.hpp"
#include "Animations/IncomingBanner.hpp"
#include "Game.hpp"

class FightEnv {
public:
FightEnv(Game &game);

sf::Texture backgroundTX;
sf::Sprite backgroundSP;
UIStats playerStatsBox;
UIEnemyOverview enemyOverview;
UIPlayerOverview playerOverview;
TextFadingManager textFadingManager;
sf::Texture playersTurnTX;
sf::Texture enemiesTurnTX;
sf::Sprite turnSP;
sf::Music backgroundMusic;

sf::Color pickedColor;
int maxMultiplier = 2;
int isPlayersTurn;
bool enemyDamageCalculated = false;

};

#endif
10 changes: 10 additions & 0 deletions src/include/FightStateEnum.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef FIGHTSTATEENUM_HPP
#define FIGHTSTATEENUM_HPP

enum FightStateEnum {
PLAYER_STATE,
ENEMY_STATE,
TURN_CHANGE
};

#endif
16 changes: 16 additions & 0 deletions src/include/FightStates/EnemiesTurn.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef ENEMIESTURN_HPP
#define ENEMIESTURN_HPP

#include <random>
#include "FightStates/FightState.hpp"
#include "FightStateEnum.hpp"

class EnemiesTurn: public FightState {
public:
~EnemiesTurn();
FightStateEnum run(Game &game, FightEnv &fightEnv) override;

private:
};

#endif
Loading

0 comments on commit 55f46d3

Please sign in to comment.