Skip to content

Commit 1b96eb6

Browse files
committed
Refactoring 3
1 parent af93a26 commit 1b96eb6

File tree

9 files changed

+134
-103
lines changed

9 files changed

+134
-103
lines changed

OpenRocket/OpenRocket/Asteroid.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Asteroid::Asteroid(float radius = 40.0f, int nrOfVertices = 16, glm::vec4 coordi
1414
currentZone(Constants::SAFE),
1515
asteroidMatrix(glm::mat4(1.0f))
1616
{
17+
// setting a random texture for the asteroid
1718
textureIndex = rand() % Constants::nrOfTextures;
1819
};
1920

@@ -22,7 +23,7 @@ bool Asteroid::isInViewport() {
2223
}
2324

2425
bool Asteroid::belowViewport() {
25-
return this->coordinates.y - this->translatedDistance < - this->radius;
26+
return this->coordinates.y - this->translatedDistance < -this->radius;
2627
}
2728

2829
bool Asteroid::inLowerHalf() {
@@ -63,14 +64,26 @@ int Asteroid::getTextureIndex() const {
6364
return this->textureIndex;
6465
}
6566

66-
void Asteroid::setAsteroidMatrix(glm::mat4 matrix) { asteroidMatrix = matrix; }
67+
void Asteroid::setAsteroidMatrix(glm::mat4 matrix) {
68+
asteroidMatrix = matrix;
69+
}
6770

68-
glm::mat4 Asteroid::getAsteroidMatrix() const { return asteroidMatrix; }
71+
glm::mat4 Asteroid::getAsteroidMatrix() const {
72+
return asteroidMatrix;
73+
}
6974

70-
float Asteroid::getTranslatedDistance() const { return this->translatedDistance; }
75+
float Asteroid::getTranslatedDistance() const {
76+
return this->translatedDistance;
77+
}
7178

72-
void Asteroid::setTranslatedDistance(float distance) { this->translatedDistance = distance; }
79+
void Asteroid::setTranslatedDistance(float distance) {
80+
this->translatedDistance = distance;
81+
}
7382

74-
float Asteroid::getRadius() const { return this->radius; }
83+
float Asteroid::getRadius() const {
84+
return this->radius;
85+
}
7586

76-
float Asteroid::getY() const { return this->coordinates.y; }
87+
float Asteroid::getY() const {
88+
return this->coordinates.y;
89+
}

OpenRocket/OpenRocket/Bullet.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#include "Bullet.h"
22
#include "Constants.h"
3-
#include <iostream>
43

54
Bullet::Bullet(float radius, float posX, float posY) :
65
radius(radius),
76
x(posX),
87
y(posY),
98
translatedDistance(0)
109
{
11-
1210
}
1311

1412
bool Bullet::aboveViewport() {

OpenRocket/OpenRocket/Bullet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ class Bullet {
1010
float x;
1111
float y;
1212
bool toBeDeleted = false;
13+
1314
public:
1415
Bullet(float, float, float);
1516
~Bullet() {}
1617

1718
float getRadius() const;
1819
float getX() const;
1920
float getY() const;
20-
float getTranslatedDistance() const;
21-
21+
float getTranslatedDistance() const;
2222
bool getToBeDeleted() { return toBeDeleted; }
23-
void setToBeDeleted(bool t) { toBeDeleted = t; }
2423

2524
static glm::vec4 bulletCenter;
2625
static glm::vec4 bulletPoint;
@@ -29,6 +28,7 @@ class Bullet {
2928
void setX(float);
3029
void setY(float);
3130
void setTranslatedDistance(float);
31+
void setToBeDeleted(bool t) { toBeDeleted = t; }
3232

3333
bool aboveViewport();
3434
};

OpenRocket/OpenRocket/Constants.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class Constants
99
static const int height;
1010
static const int maxX;
1111
static const int maxY;
12-
static const char* title;
13-
static const float PI;
12+
static const char* title;
13+
static const float PI;
1414
static const int nrOfStars;
1515
static const int nrOfAsteroids;
1616
static const int nrOfAsteroidsPerFrame;

0 commit comments

Comments
 (0)