Skip to content

Commit 650c538

Browse files
authored
Merge branch 'master' into bianca
2 parents 3be24a1 + fc05689 commit 650c538

24 files changed

+317
-291
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ glm/
3030
*.lai
3131
*.la
3232
*.a
33-
*.lib
3433

3534
# Executables
3635
*.exe

OpenRocket/OpenRocket/Asteroid.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "Asteroid.h"
22
#include "Constants.h"
33

4-
glm::vec4 Asteroid::circlePoint = { 1.0f, 0.0f, 0.f, 1.f };
5-
glm::vec4 Asteroid::circleCenter = { 0.f, 0.0f, 0.f, 1.f };
4+
glm::vec4 Asteroid::circlePoint = { 1.0f, 0.0f, 0.0f, 1.0f };
5+
glm::vec4 Asteroid::circleCenter = { 0.0f, 0.0f, 0.0f, 1.0f };
66

77
Asteroid::Asteroid(float radius = 40.0f, int nrOfVertices = 16, glm::vec4 coordinates = glm::vec4(0.0f,0.0f, 0.0f, 0.0f),
88
glm::vec4 colors = glm::vec4(0.0f, 0.0f,0.0f,0.0f)) :
@@ -11,7 +11,9 @@ Asteroid::Asteroid(float radius = 40.0f, int nrOfVertices = 16, glm::vec4 coordi
1111
coordinates(coordinates),
1212
colors(colors),
1313
translatedDistance(0),
14-
currentZone(Constants::SAFE) {
14+
currentZone(Constants::SAFE),
15+
asteroidMatrix(glm::mat4(1.0f))
16+
{
1517
textureIndex = rand() % Constants::nrOfTextures;
1618
};
1719

@@ -27,7 +29,7 @@ bool Asteroid::inLowerHalf() {
2729
return !this->belowViewport() && this->isInViewport() && this->getRealY() < Constants::height;
2830
}
2931

30-
string Asteroid::getCurrentZone() {
32+
string Asteroid::getCurrentZone() const {
3133
return this->currentZone;
3234
}
3335

@@ -41,11 +43,11 @@ void Asteroid::updateState() {
4143
}
4244
}
4345

44-
float Asteroid::getX() {
46+
float Asteroid::getX() const {
4547
return this->coordinates.x;
4648
}
4749

48-
float Asteroid::getRealY() {
50+
float Asteroid::getRealY() const {
4951
return this->coordinates.y - this->translatedDistance;
5052
}
5153

@@ -56,10 +58,19 @@ void Asteroid::setX(float newXOffset) {
5658
void Asteroid::setY(float newYOffset) {
5759
this->coordinates.y = newYOffset;
5860
}
59-
int Asteroid::getTextureIndex() {
61+
62+
int Asteroid::getTextureIndex() const {
6063
return this->textureIndex;
6164
}
62-
float Asteroid::getTranslatedDistance() { return this->translatedDistance; }
65+
66+
void Asteroid::setAsteroidMatrix(glm::mat4 matrix) { asteroidMatrix = matrix; }
67+
68+
glm::mat4 Asteroid::getAsteroidMatrix() const { return asteroidMatrix; }
69+
70+
float Asteroid::getTranslatedDistance() const { return this->translatedDistance; }
71+
6372
void Asteroid::setTranslatedDistance(float distance) { this->translatedDistance = distance; }
64-
float Asteroid::getRadius() { return this->radius; }
65-
float Asteroid::getY() { return this->coordinates.y; }
73+
74+
float Asteroid::getRadius() const { return this->radius; }
75+
76+
float Asteroid::getY() const { return this->coordinates.y; }

OpenRocket/OpenRocket/Asteroid.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,34 @@ class Asteroid {
2222
string currentZone;
2323
int textureIndex;
2424
bool toBeDeleted = false;
25+
2526
public:
2627
glm::mat4 asteroidMatrix;
2728
static glm::vec4 circlePoint;
2829
static glm::vec4 circleCenter;
29-
public:
30+
3031
Asteroid(float, int, glm::vec<4, float, (glm::qualifier)0>, glm::vec<4, float, (glm::qualifier)0>);
3132
~Asteroid() { };
3233

3334
bool isInViewport();
3435
void updateState();
3536
bool inLowerHalf();
36-
bool belowViewport();
37-
38-
string getCurrentZone();
39-
void setCurrentZone(string);
37+
bool belowViewport();
4038

41-
float getX();
42-
float getY();
43-
float getRadius();
44-
float getTranslatedDistance();
45-
int getTextureIndex();
46-
glm::mat4 getAsteroidMatrix() { return asteroidMatrix; }
47-
bool getToBeDeleted() { return toBeDeleted; }
39+
bool getToBeDeleted() const { return toBeDeleted; }
40+
float getX() const;
41+
float getY() const;
42+
float getRadius() const;
43+
float getTranslatedDistance() const;
44+
int getTextureIndex() const;
45+
glm::mat4 getAsteroidMatrix() const;
46+
string getCurrentZone() const;
47+
float getRealY() const;
4848

4949
void setX(float);
50-
float getRealY();
5150
void setY(float);
5251
void setTranslatedDistance(float);
53-
void setAsteroidMatrix(glm::mat4 matrix) { asteroidMatrix = matrix; }
5452
void setToBeDeleted(bool t) { toBeDeleted = t; }
53+
void setAsteroidMatrix(glm::mat4);
54+
void setCurrentZone(string);
5555
};

OpenRocket/OpenRocket/Bullet.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,33 @@ bool Bullet::aboveViewport() {
1515
return this->y > Constants::height;
1616
}
1717

18-
glm::vec4 Bullet::bulletCenter = { 0.0f, 0.0f, 0.f, 1.f };
19-
glm::vec4 Bullet::bulletPoint = { 0.0f, 0.0f, 0.f, 1.f };
18+
glm::vec4 Bullet::bulletCenter = { 0.0f, 0.0f, 0.0f, 1.0f };
19+
glm::vec4 Bullet::bulletPoint = { 0.0f, 0.0f, 0.0f, 1.0f };
20+
21+
float Bullet::getRadius() const {
22+
return radius;
23+
}
24+
25+
float Bullet::getX() const {
26+
return x;
27+
}
28+
29+
float Bullet::getY() const {
30+
return y;
31+
}
32+
33+
float Bullet::getTranslatedDistance() const {
34+
return translatedDistance;
35+
}
36+
37+
void Bullet::setX(float x) {
38+
this->x = x;
39+
}
40+
41+
void Bullet::setY(float y) {
42+
this->y = y;
43+
}
44+
45+
void Bullet::setTranslatedDistance(float distance) {
46+
translatedDistance = distance;
47+
}

OpenRocket/OpenRocket/Bullet.h

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,24 @@ class Bullet {
1111
float y;
1212
bool toBeDeleted = false;
1313
public:
14-
Bullet(float radius, float posX, float posY);
15-
~Bullet();
16-
17-
float getRadius() const {
18-
return radius;
19-
}
20-
21-
float getX() const {
22-
return x;
23-
}
24-
25-
float getY() const {
26-
return y;
27-
}
28-
29-
float getTranslatedDistance() const {
30-
return translatedDistance;
31-
}
32-
14+
Bullet(float, float, float);
15+
~Bullet() {}
16+
17+
float getRadius() const;
18+
float getX() const;
19+
float getY() const;
20+
float getTranslatedDistance() const;
21+
3322
bool getToBeDeleted() { return toBeDeleted; }
34-
35-
void setX(float x) {
36-
this->x = x;
37-
}
38-
39-
void setY(float y) {
40-
this->y = y;
41-
}
42-
43-
void setTranslatedDistance(float distance) {
44-
translatedDistance = distance;
45-
}
46-
4723
void setToBeDeleted(bool t) { toBeDeleted = t; }
4824

49-
bool aboveViewport();
5025
static glm::vec4 bulletCenter;
5126
static glm::vec4 bulletPoint;
5227
glm::mat4 bulletMatrix;
53-
};
28+
29+
void setX(float);
30+
void setY(float);
31+
void setTranslatedDistance(float);
32+
33+
bool aboveViewport();
34+
};
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include "Constants.h"
22

33
const char* Constants::title = "Open Rocket";
4-
const float Constants::PI = 3.141592;
4+
const float Constants::PI = 3.141592f;
55
const int Constants::width = 800;
66
const int Constants::height = 450;
77
const int Constants::nrOfStars = 1000;
88
const int Constants::maxX = 1600;
99
const int Constants::maxY = 900;
1010
const int Constants::nrOfAsteroids = 20;
1111
const int Constants::nrOfAsteroidsPerFrame = 10;
12-
const float Constants::TWO_PI = 6.28;
12+
const float Constants::TWO_PI = 6.28f;
1313
const int Constants::nrOfVerticesPerCircle = 18;
1414
const float Constants::distanceBetweenAsteroids = 150.0f;
1515
const float Constants::asteroidMovingUnit = 0.15f;
@@ -18,8 +18,8 @@ const float Constants::maxYDistance = 4 * Constants::height;
1818
const std::string Constants::xCoord = "x";
1919
const std::string Constants::yCoord = "y";
2020
const std::string Constants::RED = "Red Zone";
21-
const std::string Constants::SAFE= "Safe Zone";
22-
const std::vector<const char*> Constants::textureImages{
21+
const std::string Constants::SAFE = "Safe Zone";
22+
const std::vector<const char*> Constants::textureImages {
2323
"blueAsteroid.png",
2424
"brightOrangeAsteroid.png",
2525
"darkBlueAsteroid.png",
@@ -28,7 +28,9 @@ const std::vector<const char*> Constants::textureImages{
2828
"turquoiseAsteroid.png"
2929
};
3030
const int Constants::nrOfTextures = 6;
31-
const float Constants::bulletSpeed = 0.1;
31+
const float Constants::bulletSpeed = 0.1f;
3232
const double Constants::bulletSpawnCooldown = 0.1;
3333
const float Constants::bulletRadius = 2.5f;
3434
const int Constants::nrOfBulletsPerFrame = 8;
35+
const int Constants::maxLives = 3;
36+
const double Constants::timeToEscapeAsteroid = 1.0;

OpenRocket/OpenRocket/Constants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ class Constants
3030
static const double bulletSpawnCooldown;
3131
static const float bulletRadius;
3232
static const int nrOfBulletsPerFrame;
33+
static const int maxLives;
34+
static const double timeToEscapeAsteroid;
3335
};

0 commit comments

Comments
 (0)