aboutsummaryrefslogtreecommitdiff
path: root/src/includes
diff options
context:
space:
mode:
authoraleksav013 <aleksav013@gmail.com>2021-06-01 21:03:32 +0200
committeraleksav013 <aleksav013@gmail.com>2021-06-01 21:03:32 +0200
commitdbe41a2f77774ee716d3ff45db766d6400970f57 (patch)
treeec86f7305bcb2d3eec37bf8e123cb901f80a5a5d /src/includes
parent82d49a6825af009d950b3a6c18d609da2ef8486c (diff)
Splitting code; Creating Makefile
Diffstat (limited to 'src/includes')
-rw-r--r--src/includes/Enemy1.hpp17
-rw-r--r--src/includes/Enemy2.hpp17
-rw-r--r--src/includes/Enemy3.hpp17
-rw-r--r--src/includes/Entity.hpp15
-rw-r--r--src/includes/Game.hpp54
-rw-r--r--src/includes/Global.hpp12
-rw-r--r--src/includes/Player.hpp17
-rw-r--r--src/includes/Powerup.hpp13
-rw-r--r--src/includes/State.hpp19
9 files changed, 181 insertions, 0 deletions
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<SFML/Graphics.hpp>
+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<Enemy1> nep1;
+ std::vector<Enemy2> nep2;
+ std::vector<Enemy3> nep3;
+ std::vector<Powerup> 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<random>
+#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<SFML/Graphics.hpp>
+class State
+{
+ private:
+ sf::RenderWindow prozor;
+ int visina,sirina;
+ bool ischanged=0,pause=0;
+
+ void events();
+ void keyboard();
+ public:
+ State();
+ void loop();
+};
+
+#endif