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