summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f23bc97)
raw | patch | inline | side by side (parent: f23bc97)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 4 Apr 2017 19:03:23 +0000 (22:03 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 4 Apr 2017 19:03:23 +0000 (22:03 +0300) |
game.c | patch | blob | history | |
game.h | patch | blob | history | |
netwar.c | patch | blob | history |
index 3acaa36a82a9a558f5501e349e5bc29c7e31171b..0c632468e1bbc5a0121b58a0aa0f967e0d78c7df 100644 (file)
--- a/game.c
+++ b/game.c
#include "game.h"
-#define SPEED (0.03 / TICK)
+#define SPEED (0.015 / TICK)
#define ROTATE (0.03 / TICK)
#define BULL_SPEED (0.4 / TICK)
#define MAX_ROTATE (0.3 / TICK)
// Цифры взяты с потолка, но вроде неплохо подобраны
-#define G 3.673e-4
-#define M_STAR 10.0
+#define G 6.673e-4
+#define M_STAR 8.0
#define M_SHIP 0.1
Player g_player[MAX_PLAYERS];
}
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);
+ if(fabs(g_player[id].vx) < MAX_SPEED)
+ g_player[id].vx += speed * cos(g_player[id].r * 2 * M_PI);
+ if(fabs(g_player[id].vy) < MAX_SPEED)
+ g_player[id].vy += speed * sin(g_player[id].r * 2 * M_PI);
}
static void roteplayer(int id, float speed) {
static void checkspacebound(float * a) {
float x = *a;
- if(x < -1)
- x = fabs(x);
- else if(x > 1)
- x = -x;
+ if(x < -1 || x > 1)
+ x = copysign(fmodf(x, 1) + 1, -1 * x);
*a = x;
}
checkspacebound(&g_bullet[i].x);
checkspacebound(&g_bullet[i].y);
+ //gravity(&g_bullet[i].vx, &g_bullet[i].vy, g_bullet[i].x, g_bullet[i].y);
+
for(int j = 0; j < MAX_PLAYERS; j++)
if(g_player[j].live)
if(collide(g_bullet[i].x, g_bullet[i].y, 0.0001, g_player[j].x, g_player[j].y, PLAYER_SIZE))
index e41bb05b40a5a75a2ff54bc39db0c044601a4a41..35536b6cf006568a65e512e0a7380cc43503b352 100644 (file)
--- a/game.h
+++ b/game.h
#include "protocol.h"
-#define MAX_PLAYERS 32
-#define MAX_BULLETS (MAX_PLAYERS * 8)
+#define MAX_PLAYERS 8
+#define MAX_BULLETS (MAX_PLAYERS * 5)
#define TICK 24 // Количество обновлений мира в секунду
#define TICK_DELAY (1000 / TICK) // Задержка между тиками
#define BULLET_TIME (TICK * 6) // Время жизни игрока
#define PLAYER_SHOOT ((int)(TICK * 0.8)) // Задержка между выстрелами
-#define PLAYER_SIZE 0.01785 // Радиус игрока
-#define STAR_SIZE 0.1 // Радиус звезды
+#define PLAYER_SIZE 0.03 // Радиус игрока
+#define STAR_SIZE 0.15 // Радиус звезды
typedef struct Player {
/* public */
diff --git a/netwar.c b/netwar.c
index 44e8725cc6ff9c117784d59b64472fd207d491a2..b7c2222b212be1a1511e8a0af5167770053ab1a6 100644 (file)
--- a/netwar.c
+++ b/netwar.c
}
static void paintmodel(const float * model, int modelsz, float mx, float my, float r, float size, int cx, int cy) {
- int scale = (WIDTH + HEIGHT) / 2 * size;
+ int scale = (WIDTH + HEIGHT) / 2 * size / 2;
int count = modelsz / sizeof(model[0]) / 2;
int x = mx * WIDTH / 2;
int cy = HEIGHT / 2;
SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0xFF, 0x00);
- paintmodel(star, sizeof(star), 0, 0, 0, STAR_SIZE, cx, cy);
+
+ static float start_r;
+ for(int i = 0; i < STAR_SIZE * 200; i++)
+ paintmodel(star, sizeof(star), 0, 0, M_PI / i + start_r, STAR_SIZE, cx, cy);
+
+ start_r += 0.0001;
for(int i = 0; i < MAX_PLAYERS; i++) {
if(i == cl_playerid)