DEADSOFTWARE

Добавлена задержка между выстрелами. У клиента пули не создаются без подтвеждения...
[netwar.git] / game.c
diff --git a/game.c b/game.c
index 9b7f2391ddc78d4aa3fdb7ef0777ba46c9001e61..cacaf6213412aca5862a489bb33f50c5cc9a2aa9 100644 (file)
--- a/game.c
+++ b/game.c
@@ -6,14 +6,16 @@
 
 #include "game.h"
 
-#define SPEED  0.00006
-#define ROTATE 0.00004
-#define BULL_SPEED 0.008
+#define SPEED      0.00006
+#define ROTATE     0.00004
+#define BULL_SPEED 0.00800
 
 Player g_player[MAX_PLAYERS];
 Bullet g_bullet[MAX_BULLETS];
 
-void g_player_set(unsigned int id, bool live, float x, float y, float r, float vx, float vy, float vr) {
+static bool svmode;
+
+void g_player_set(unsigned int id, bool live, float x, float y, float r, float vx, float vy, float vr, int shoot) {
        assert(id < MAX_PLAYERS);
        g_player[id] = (Player) {
                .updated = true,
@@ -62,9 +64,16 @@ static void fireplayer(int id) {
        if(j < 0)
                return;
 
-       float vx = BULL_SPEED * cos(g_player[id].r * 2 * M_PI);
-       float vy = BULL_SPEED * sin(g_player[id].r * 2 * M_PI);
-       g_bullet_set(j, id, true, g_player[id].x, g_player[id].y, vx, vy, 0);
+       if(g_player[id].shoot < PLAYER_SHOOT)
+               return;
+
+       g_player[id].shoot = 0;
+
+       if(svmode) {
+               float vx = BULL_SPEED * cos(g_player[id].r * 2 * M_PI);
+               float vy = BULL_SPEED * sin(g_player[id].r * 2 * M_PI);
+               g_bullet_set(j, id, true, g_player[id].x, g_player[id].y, vx, vy, 0);
+       }
 }
 
 static void checkspacebound(float * a) {
@@ -105,6 +114,10 @@ void g_update() {
                        g_player[i].r += g_player[i].vr;
                        checkspacebound(&g_player[i].x);
                        checkspacebound(&g_player[i].y);
+
+                       ++g_player[i].shoot;
+                       if(g_player[i].shoot > PLAYER_SHOOT)
+                               g_player[i].shoot = PLAYER_SHOOT;
                }
        }
 
@@ -129,3 +142,8 @@ void g_update() {
                }
        }
 }
+
+void g_init(bool server_mode) {
+       svmode = server_mode;
+       // TODO memset & co
+}