MAX SPEED for balls implemented, #1

This commit is contained in:
Luis Fernando Molina committed 2018-04-24 12:50:51 +02:00
1 parent b1364008d6
commit ff8b5b919c
2 files changed
+20

No files matched your search

Binary file not shown.
+20
View File
@@ -113,6 +113,26 @@ function newFloatingSpace() {
ball.currentSpeed.y = ball.currentSpeed.y - .005;
}
// Lets put a maximun speed also.
const MAX_SPEED = 50;
if (ball.currentSpeed.x > MAX_SPEED) {
ball.currentSpeed.x = MAX_SPEED;
}
if (ball.currentSpeed.y > MAX_SPEED) {
ball.currentSpeed.y = MAX_SPEED;
}
if (ball.currentSpeed.x < -MAX_SPEED) {
ball.currentSpeed.x = -MAX_SPEED;
}
if (ball.currentSpeed.y < -MAX_SPEED) {
ball.currentSpeed.y = -MAX_SPEED;
}
// The radius also have a target.
if (ball.currentRadius < ball.targetRadius) {