wider terrain

This commit is contained in:
Masashi 2025-12-18 21:55:51 +05:30
commit 7fc4e9cd3c
4 changed files with 52 additions and 23 deletions

View file

@ -21,7 +21,7 @@ typedef int socklen_t;
#define CLOSESOCK close
#endif
#define PROTOCOL_VERSION 5
#define PROTOCOL_VERSION 67
#define SERVER_PORT 27015
#define MAX_PLAYERS 16
#define USERNAME_MAX 16
@ -558,6 +558,7 @@ typedef struct PlayerStateNet {
float x, y, z, yaw, pitch;
uint8_t weapon;
int16_t pistolMag, rifleMag, pistolAmmo, rifleAmmo, medkits;
int16_t reloadTimeLeft;
char username[USERNAME_MAX];
} PlayerStateNet;
@ -589,6 +590,7 @@ typedef struct RemotePlayer {
float yaw, pitch;
uint8_t weapon;
int16_t pistolMag, rifleMag, pistolAmmo, rifleAmmo, medkits;
int16_t reloadTimeLeft;
char username[USERNAME_MAX];
} RemotePlayer;
@ -715,7 +717,7 @@ int main(void) {
float recoilYaw = 0.0f, recoilPitch = 0.0f, crossSpread = 0.0f;
float fireCooldown = 0.0f;
int shotsInBurst = 0;
float burstResetTimer = 0.0f;
float burstResetTimer = 0.0f;
const float pistolFireRate = 4.0f, rifleFireRate = 12.0f;
const float recoilReturn = 18.0f, crossReturn = 14.0f;
@ -799,15 +801,16 @@ int main(void) {
p->pistolAmmo = ps->pistolAmmo;
p->rifleAmmo = ps->rifleAmmo;
p->medkits = ps->medkits;
p->reloadTimeLeft = ps->reloadTimeLeft;
memset(p->username, 0, USERNAME_MAX);
strncpy(p->username, ps->username, USERNAME_MAX - 1);
}
if (myId != 255 && rp[myId].present) {
Vector3 body = rp[myId].pos;
camPos.x = body.x;
camPos.y = body.y + 1.0f;
camPos.z = body.z + 0.0001f;
camPos.x = body.x;
camPos.y = body.y + 1.0f;
camPos.z = body.z + 0.0001f;
// Prevent camera from clipping into terrain
float terrain_h = get_terrain_height(camPos.x, camPos.z);
@ -854,8 +857,6 @@ int main(void) {
if (IsKeyDown(KEY_S))
moveZ -= 1.0f;
uint8_t buttons = 0;
if (IsKeyPressed(KEY_ONE))
buttons |= BTN_SWITCH_PISTOL;
@ -1055,7 +1056,10 @@ int main(void) {
DrawText(TextFormat("%d", currentMag), sw - 250, sh - 75, 40, RAYWHITE);
DrawText(TextFormat("/ %d", reserveAmmo), sw - 140, sh - 65, 24,
(Color){180, 180, 180, 255});
if (currentMag == 0)
if (rp[myId].reloadTimeLeft > 0)
DrawText("RELOADING...", sw - 250, sh - 30, 20,
(Color){255, 200, 80, 255});
else if (currentMag == 0)
DrawText("RELOAD!", sw - 250, sh - 30, 20, (Color){255, 80, 80, 255});
}