forked from MohanadKh03/Space_Arcade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvaders.h
111 lines (108 loc) · 2.56 KB
/
Invaders.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#pragma once
#pragma once
#include <SFML/Graphics.hpp>
#include <iostream>
#include <Ctime>
#include <SFML/Audio.hpp>
const int NumOfEnemies = 60;
const int NumOfBullets = 20;
const int NumOfEnemyBullets = 2;
//struct powerups
//{
// int effect;
// sf::CircleShape body;
// sf::Clock powerclock;
// sf::Time powerTime;
// bool powerSpared;
// bool powerConsumed;
// bool fireRate;
//};
struct Bullet {
sf::Vector2f speed = { 0,-900 };
sf::RectangleShape body;
bool released = false;
void Update(float&);
};
//struct Boss
//{
// int health;
// sf::Sprite Boss;
// sf::Texture BossTexture;
// Bullet bossBullet;
//};
struct Sheild
{
sf::Texture texture;
sf::RectangleShape body;
int health = 100;
bool active = true;
};
struct InvaderEnemy
{
float posx, posy, speedx = 120.f, speedy = 10.25f, health;
int shootingchance;
int transperancy = 0;
int red = 255;
int green = 255;
int blue = 255;
sf::Texture enemytexture;
Bullet enemybu;
sf::SoundBuffer enemyshot;
sf::Sound enemysound;
int bulletspeed;
sf::Sprite enemy;
int bulletIndex = 0;
//powerups enemypower;
};//
struct Player {
float posx, posy, speedx = 10.f;
sf::Texture playertexture;
sf::SoundBuffer playershot;
sf::Sound playersound;
sf::RectangleShape playersprite;
bool Damaged;
int health;
};
struct SpaceInvader {
SpaceInvader(sf::RenderWindow& window);
float WindowFactor = sf::VideoMode::getDesktopMode().width / sf::VideoMode::getDesktopMode().height;
int score = 0;
bool isgameover = false;
sf::Clock karizmaBoss;
sf::Time KarizmaTime;
sf::Text GameOverText;
sf::Font GameOverFont;
sf::Text scoretext;
sf::Font scorefont;
sf::Text livestext;
sf::Font livesfont;
sf::Text SheildText[3];
sf::Font SheildFont[3];
InvaderEnemy enemies[NumOfEnemies];
sf::Music backgroundMusic;
Player player;
Bullet bullets[NumOfBullets];
Sheild sheilds[3];
sf::Texture background;
sf::Sprite backgroundsprite;
//Boss boss;
int bulletIndex = 0;
float bulletDelay = 0.0f;
float bulletTimer = 0.1f;
sf::Clock clock;
sf::Time deltatimemove;
void EnemyMovement(float dt, sf::Clock& clock, sf::Time& deltatimemove);
void PlayerMovement();
/*void Enemybulletfunction(float dt);*/
void ShootBullet(float&);
void bulletsFunction(sf::Event& event, float dt);
void Collision(sf::RenderWindow& w, int& gameID);
void GameOver(sf::RenderWindow& w, int& gameID);
void Run(sf::RenderWindow&, int&, sf::Event&, float&, int& gameID);
void Destroyandgen(float dt);
/*void Boss();?*/
void audio();
void Bossmovement(sf::Clock& karizmaBoss, sf::Time& karizmatime, float dt);
void Sheild();
/*void PowerUps(float dt);*/
};