summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dadb512)
raw | patch | inline | side by side (parent: dadb512)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 4 Apr 2017 16:07:20 +0000 (19:07 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 4 Apr 2017 16:07:20 +0000 (19:07 +0300) |
game.c | patch | blob | history |
index 4b1c345c43d2443572eb281bdb13533ce4197c47..36dccb41669cf628070979921560f8fdf93ec3d2 100644 (file)
--- a/game.c
+++ b/game.c
#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];
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) {