mirror of
https://github.com/lov3b/Pong.git
synced 2025-01-18 20:50:12 +01:00
speed increase for every bump
This commit is contained in:
parent
179f34db80
commit
b57bd9381e
@ -18,16 +18,16 @@ inline double_t toRadians(double_t degrees) {
|
|||||||
class Vec2d {
|
class Vec2d {
|
||||||
private:
|
private:
|
||||||
std::default_random_engine random;
|
std::default_random_engine random;
|
||||||
const float_t hypotenuse;
|
float_t hypotenuse;
|
||||||
double_t x, y;
|
double_t x, y;
|
||||||
|
const float_t bumpSpeedIncrease = 1.05;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Vec2d(float_t hypotenuse) : hypotenuse(hypotenuse) {
|
Vec2d(float_t hypotenuse) : hypotenuse(hypotenuse) {
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
random = std::default_random_engine(rd());
|
random = std::default_random_engine(rd());
|
||||||
int sign = random() % 2 == 0 ? -1 : 1;
|
int sign = random() % 2 == 0 ? -1 : 1;
|
||||||
//double_t angle = toRadians(random() % 6000 / 100 - 30);
|
double_t angle = toRadians(random() % 6000 / 100 - 30);
|
||||||
double_t angle = 15;
|
|
||||||
x = cos(angle) * sign * hypotenuse;
|
x = cos(angle) * sign * hypotenuse;
|
||||||
y = sin(angle) * sign * hypotenuse;
|
y = sin(angle) * sign * hypotenuse;
|
||||||
}
|
}
|
||||||
@ -38,6 +38,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void bump(BumpType bumpType, PaddleDirection paddleDirection) {
|
void bump(BumpType bumpType, PaddleDirection paddleDirection) {
|
||||||
|
// Make everything a bit faster so it's not boring
|
||||||
|
hypotenuse *= bumpSpeedIncrease;
|
||||||
|
x *= bumpSpeedIncrease;
|
||||||
|
y *= bumpSpeedIncrease;
|
||||||
|
|
||||||
switch (bumpType) {
|
switch (bumpType) {
|
||||||
case BumpType::BOTH:
|
case BumpType::BOTH:
|
||||||
x = -x;
|
x = -x;
|
||||||
@ -58,6 +63,7 @@ public:
|
|||||||
y = sin(angle) * hypotenuse;
|
y = sin(angle) * hypotenuse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
@ -29,7 +29,7 @@ public:
|
|||||||
this->rightPaddle = rightPaddle;
|
this->rightPaddle = rightPaddle;
|
||||||
this->x = screen->x / 2;
|
this->x = screen->x / 2;
|
||||||
this->y = screen->y / 2;
|
this->y = screen->y / 2;
|
||||||
vec2d = new Vec2d(4);
|
vec2d = new Vec2d(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetPosition() {
|
void resetPosition() {
|
||||||
@ -37,7 +37,7 @@ public:
|
|||||||
this->y = screen->y / 2;
|
this->y = screen->y / 2;
|
||||||
|
|
||||||
delete vec2d;
|
delete vec2d;
|
||||||
vec2d = new Vec2d(4);
|
vec2d = new Vec2d(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(SDL_Renderer *renderer) const {
|
void draw(SDL_Renderer *renderer) const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user