From: DeaDDooMER Date: Tue, 4 Apr 2017 16:07:20 +0000 (+0300) Subject: Добавлено ограничение максимального ускорения X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=0afebb148532e32e6b47194e08e908beec45087e;p=netwar.git Добавлено ограничение максимального ускорения --- diff --git a/game.c b/game.c index 4b1c345..36dccb4 100644 --- a/game.c +++ b/game.c @@ -10,6 +10,9 @@ #define ROTATE (0.03 / TICK) #define BULL_SPEED (0.4 / TICK) +#define MAX_SPEED (0.3 / TICK) +#define MAX_ROTATE (0.3 / TICK) + Player g_player[MAX_PLAYERS]; Bullet g_bullet[MAX_BULLETS]; @@ -53,10 +56,17 @@ static int freebullet() { static void moveplayer(int id, float speed) { g_player[id].vx += speed * cos(g_player[id].r * 2 * M_PI); g_player[id].vy += speed * sin(g_player[id].r * 2 * M_PI); + + if(fabs(g_player[id].vx) > MAX_SPEED) + g_player[id].vx = copysignf(MAX_SPEED, g_player[id].vx); + if(fabs(g_player[id].vy) > MAX_SPEED) + g_player[id].vy = copysignf(MAX_SPEED, g_player[id].vy); } static void roteplayer(int id, float speed) { g_player[id].vr += speed; + if(fabs(g_player[id].vr) > MAX_ROTATE) + g_player[id].vr = copysignf(MAX_ROTATE, g_player[id].vr); } static void fireplayer(int id) {