From dbe41a2f77774ee716d3ff45db766d6400970f57 Mon Sep 17 00:00:00 2001 From: aleksav013 Date: Tue, 1 Jun 2021 21:03:32 +0200 Subject: Splitting code; Creating Makefile --- src/includes/Enemy1.hpp | 17 +++++++++++++++ src/includes/Enemy2.hpp | 17 +++++++++++++++ src/includes/Enemy3.hpp | 17 +++++++++++++++ src/includes/Entity.hpp | 15 ++++++++++++++ src/includes/Game.hpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ src/includes/Global.hpp | 12 +++++++++++ src/includes/Player.hpp | 17 +++++++++++++++ src/includes/Powerup.hpp | 13 ++++++++++++ src/includes/State.hpp | 19 +++++++++++++++++ 9 files changed, 181 insertions(+) create mode 100644 src/includes/Enemy1.hpp create mode 100644 src/includes/Enemy2.hpp create mode 100644 src/includes/Enemy3.hpp create mode 100644 src/includes/Entity.hpp create mode 100644 src/includes/Game.hpp create mode 100644 src/includes/Global.hpp create mode 100644 src/includes/Player.hpp create mode 100644 src/includes/Powerup.hpp create mode 100644 src/includes/State.hpp (limited to 'src/includes') diff --git a/src/includes/Enemy1.hpp b/src/includes/Enemy1.hpp new file mode 100644 index 0000000..0405365 --- /dev/null +++ b/src/includes/Enemy1.hpp @@ -0,0 +1,17 @@ +#ifndef ENEMY1_H +#define ENEMY1_H + +#include"Entity.hpp" +class Enemy1:public Entity +{ + private: + float vx,vy; + public: + static float time; + Enemy1():Entity() {} + Enemy1(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja); + void izracunajbrzinu(float igracx,float igracy); + void izracunajpoz(float dt); +}; + +#endif diff --git a/src/includes/Enemy2.hpp b/src/includes/Enemy2.hpp new file mode 100644 index 0000000..25555a4 --- /dev/null +++ b/src/includes/Enemy2.hpp @@ -0,0 +1,17 @@ +#ifndef ENEMY2_H +#define ENEMY2_H + +#include"Entity.hpp" +class Enemy2:public Entity +{ + private: + float vx,vy; + public: + static float time; + Enemy2():Entity() {} + Enemy2(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja); + void izracunajbrzinu(float igracx,float igracy,float dt); + void izracunajpoz(float igracx,float igracy,float dt); +}; + +#endif diff --git a/src/includes/Enemy3.hpp b/src/includes/Enemy3.hpp new file mode 100644 index 0000000..e1498bf --- /dev/null +++ b/src/includes/Enemy3.hpp @@ -0,0 +1,17 @@ +#ifndef ENEMY3_H +#define ENEMY3_H + +#include"Entity.hpp" +class Enemy3:public Entity +{ + private: + float vx,vy; + public: + static float time; + Enemy3():Entity() {} + Enemy3(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja); + void izracunajpoz(float dt); + void izracunajbrzinu(int sirina,int duzina); +}; + +#endif diff --git a/src/includes/Entity.hpp b/src/includes/Entity.hpp new file mode 100644 index 0000000..7f83c98 --- /dev/null +++ b/src/includes/Entity.hpp @@ -0,0 +1,15 @@ +#ifndef ENTITY_H +#define ENTITY_H + +#include +class Entity +{ + public: + bool ziv=1; + float x,y; + sf::RectangleShape telo; + Entity() {} Entity(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja); + void respawn(int sirina,int visina); +}; + +#endif diff --git a/src/includes/Game.hpp b/src/includes/Game.hpp new file mode 100644 index 0000000..4418ab3 --- /dev/null +++ b/src/includes/Game.hpp @@ -0,0 +1,54 @@ +#ifndef GAME_H +#define GAME_H + +#include"Player.hpp" +#include"Enemy1.hpp" +#include"Enemy2.hpp" +#include"Enemy3.hpp" +#include"Powerup.hpp" + +class Game +{ + private: + sf::Font font; + sf::Texture healthtex,neprijateljtex; + float dt; + sf::Clock sat,time; + + Player igrac; + std::vector nep1; + std::vector nep2; + std::vector nep3; + std::vector pow; + + int visina,sirina; + sf::RenderWindow *prozor; + + sf::CircleShape krug; + sf::RectangleShape health,healthblank,stomp,stompblank; + sf::Text healthtext,stomptext,fps,score; + + void keyboard(); + void run(); + void draw(); + void stompmain(); + + void updateui(); + void updatedt(); + bool gameover(); + void respawn(); + void position(); + void checkcollision(); + + void initshapes(); + void initui(); + void inittex(); + void initent(); + void updatewin(); + public: + Game() {} + Game(sf::RenderWindow *glprozor); + void loop(bool ischanged,bool pause); +}; + +#endif diff --git a/src/includes/Global.hpp b/src/includes/Global.hpp new file mode 100644 index 0000000..bfb808a --- /dev/null +++ b/src/includes/Global.hpp @@ -0,0 +1,12 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +#include +#define seseku(a,b) a.getGlobalBounds().intersects(b.getGlobalBounds()) +class Global +{ + public: + static std::mt19937 rng; +}; + +#endif diff --git a/src/includes/Player.hpp b/src/includes/Player.hpp new file mode 100644 index 0000000..3a2a040 --- /dev/null +++ b/src/includes/Player.hpp @@ -0,0 +1,17 @@ +#ifndef PLAYER_H +#define PLAYER_H + +#include"Entity.hpp" +class Player:public Entity +{ + public: + int health,xp; + int stomprad=270; + float stomptime; + + Player():Entity() {} + Player(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja); + void updatest(float dt); +}; + +#endif diff --git a/src/includes/Powerup.hpp b/src/includes/Powerup.hpp new file mode 100644 index 0000000..2b6ec72 --- /dev/null +++ b/src/includes/Powerup.hpp @@ -0,0 +1,13 @@ +#ifndef POWRUP_H +#define POWERUP_H + +#include"Entity.hpp" +class Powerup:public Entity +{ + public: + static float time; + Powerup():Entity() {} + Powerup(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja); +}; + +#endif diff --git a/src/includes/State.hpp b/src/includes/State.hpp new file mode 100644 index 0000000..fdde7b8 --- /dev/null +++ b/src/includes/State.hpp @@ -0,0 +1,19 @@ +#ifndef STATE_H +#define STATE_H + +#include +class State +{ + private: + sf::RenderWindow prozor; + int visina,sirina; + bool ischanged=0,pause=0; + + void events(); + void keyboard(); + public: + State(); + void loop(); +}; + +#endif -- cgit v1.2.3