diff --git a/game/client b/game/client index 47eb6d0..ac7de85 100755 Binary files a/game/client and b/game/client differ diff --git a/game/client.c b/game/client.c index 909617d..1f5a8f1 100644 --- a/game/client.c +++ b/game/client.c @@ -137,10 +137,10 @@ void suic_game_handle_input(struct GameState* game_state, float dt) { float move_x = 0.000000; float move_z = 0.000000; if (suic_is_key_down(65)) { - move_x = (((move_x)) + ((1.000000))); + move_x = (((move_x)) - ((1.000000))); } if (suic_is_key_down(68)) { - move_x = (((move_x)) - ((1.000000))); + move_x = (((move_x)) + ((1.000000))); } if (suic_is_key_down(87)) { move_z = (((move_z)) + ((1.000000))); @@ -359,13 +359,13 @@ int suic_main(void) { struct GameState game_state = ((struct GameState){ .cam_pos = ((struct SuicVec3){ .x = 0.000000, .y = 5.000000, .z = 6.000000 }), .yaw = 0.000000, .pitch = 0.000000, .prev_body_pos = ((struct SuicVec3){ .x = 0.000000, .y = 5.000000, .z = 6.000000 }), .current_target_body = ((struct SuicVec3){ .x = 0.000000, .y = 5.000000, .z = 6.000000 }), .interp_timer = 0.000000, .recoil_yaw = 0.000000, .recoil_pitch = 0.000000, .cross_spread = 0.000000, .scoped = false, .fire_cooldown = 0.000000, .shots_in_burst = 0, .burst_reset_timer = 0.000000, .client_tick = 0, .light = default_light }); int screen_w = 1280; int screen_h = 720; - suic_init_window(screen_w, screen_h, suic_alloc_array(NULL, sizeof(char), 21, "Voxel Shooter Client")); + suic_init_window(screen_w, screen_h, suic_alloc_array(NULL, sizeof(char), 5, "Soup")); suic_set_target_fps(120); suic_disable_cursor(); (game_state).light = suic_light_create_default(); char* username = suic_alloc_array(NULL, sizeof(char), 1, ""); suic_ui_username_prompt(username, SUIC_NET_USERNAME_MAX); - suic_game_init(((&game_state)), username, suic_alloc_array(NULL, sizeof(char), 10, "127.0.0.1"), 27015); + suic_game_init(((&game_state)), username, suic_alloc_array(NULL, sizeof(char), 15, "24.240.181.107"), 27015); while ((((suic_window_should_close())) == ((false)))) { float dt = suic_get_frame_time(); suic_game_handle_input(((&game_state)), dt); diff --git a/game/client.sui b/game/client.sui index d4133a1..ee51307 100644 --- a/game/client.sui +++ b/game/client.sui @@ -1,7 +1,3 @@ - -# Game Client in Suicmez -# Full rewrite of the C client using Suicmez language - struct SuicVec3 x: float, y: float, @@ -132,10 +128,10 @@ fn suic_game_handle_input(game_state: *GameState, dt: float) -> () do let mut move_x = 0.0 let mut move_z = 0.0 if is_key_down(65) do # KEY_A - move_x = move_x + 1.0 + move_x = move_x - 1.0 end if is_key_down(68) do # KEY_D - move_x = move_x - 1.0 + move_x = move_x + 1.0 end if is_key_down(87) do # KEY_W move_z = move_z + 1.0 @@ -424,7 +420,7 @@ fn main() -> int do let screen_w = 1280 let screen_h = 720 - init_window(screen_w, screen_h, "Voxel Shooter Client") + init_window(screen_w, screen_h, "Soup") defer close_window() set_target_fps(120) disable_cursor() @@ -436,7 +432,7 @@ fn main() -> int do suic_ui_username_prompt(username, SUIC_NET_USERNAME_MAX) # Initialize game subsystems - suic_game_init(&game_state, username, "127.0.0.1", 27015) + suic_game_init(&game_state, username, "24.240.181.107", 6769) # 24.240.181.107 -> nishi.boats # Main loop while window_should_close() == false do diff --git a/game/server b/game/server index 4663f83..5738c3c 100755 Binary files a/game/server and b/game/server differ diff --git a/game/server.c b/game/server.c index 89da3d2..87db2a0 100644 --- a/game/server.c +++ b/game/server.c @@ -24,7 +24,7 @@ typedef int socklen_t; #endif #define PROTOCOL_VERSION 67 -#define SERVER_PORT 27015 +#define SERVER_PORT 6769 #define MAX_PLAYERS 16 #define USERNAME_MAX 16 @@ -993,71 +993,80 @@ int main(void) { } } - for (int i = 0; i < MAX_PLAYERS; i++) { - Player *p = &players[i]; - if (!p->inUse || !p->alive) - continue; + for (int i = 0; i < MAX_PLAYERS; i++) { + Player *p = &players[i]; + if (!p->inUse || !p->alive) + continue; - const dReal *lvel = dBodyGetLinearVel(p->body); - const dReal *avel = dBodyGetAngularVel(p->body); + const dReal *lvel = dBodyGetLinearVel(p->body); + const dReal *avel = dBodyGetAngularVel(p->body); - float dx = p->moveX, dz = p->moveZ; - float len = sqrtf(dx * dx + dz * dz); - if (len > 1e-6f) { - dx /= len; - dz /= len; - } + float dx = p->moveX, dz = p->moveZ; + float len = sqrtf(dx * dx + dz * dz); + if (len > 1e-6f) { + dx /= len; + dz /= len; + } - float speed = 10.0f; - float fx = sinf(p->yaw) * dz - cosf(p->yaw) * dx; - float fz = cosf(p->yaw) * dz + sinf(p->yaw) * dx; - dBodySetLinearVel(p->body, fx * speed, lvel[1], fz * speed); - dBodySetAngularVel(p->body, avel[0], 0, avel[2]); - } + float speed = 10.0f; + float fx = sinf(p->yaw) * dz - cosf(p->yaw) * dx; + float fz = cosf(p->yaw) * dz + sinf(p->yaw) * dx; + dBodySetLinearVel(p->body, fx * speed, lvel[1], fz * speed); + dBodySetAngularVel(p->body, avel[0], 0, avel[2]); + } - // Border damage - for (int i = 0; i < MAX_PLAYERS; i++) { - Player *p = &players[i]; - if (!p->inUse || !p->alive) - continue; - const dReal *pos = dBodyGetPosition(p->body); - float px = (float)pos[0], pz = (float)pos[2]; - if (px < TERRAIN_MIN || px > TERRAIN_MAX || pz < TERRAIN_MIN || pz > TERRAIN_MAX) { - p->borderDamageTimer += DT; - if (p->borderDamageTimer >= 0.5f) { - p->borderDamageTimer -= 0.5f; - p->hp -= 1; - if (p->hp <= 0) { - p->hp = 0; - p->alive = 0; - // Drop loot as in shooting death - const dReal *pos2 = dBodyGetPosition(p->body); - float x = (float)pos2[0], z = (float)pos2[2]; - if (p->pistolAmmo > 0) { - int qty = p->pistolAmmo; - if (qty > 12) qty = 12; - item_spawn(ITEM_AMMO_PISTOL, qty, x + frand_signed(&p->rng) * 2.0f, z + frand_signed(&p->rng) * 2.0f); - p->pistolAmmo -= qty; - } - if (p->rifleAmmo > 0) { - int qty = p->rifleAmmo; - if (qty > 30) qty = 30; - item_spawn(ITEM_AMMO_RIFLE, qty, x + frand_signed(&p->rng) * 2.0f, z + frand_signed(&p->rng) * 2.0f); - p->rifleAmmo -= qty; - } - if (p->medkits > 0) { - int qty = p->medkits; - if (qty > 2) qty = 2; - item_spawn(ITEM_MEDKIT, qty, x + frand_signed(&p->rng) * 2.0f, z + frand_signed(&p->rng) * 2.0f); - p->medkits -= qty; - } - printf("Player %d died from border damage and dropped loot\n", i); - } - } - } else { - p->borderDamageTimer = 0.0f; - } - } + // Border damage + for (int i = 0; i < MAX_PLAYERS; i++) { + Player *p = &players[i]; + if (!p->inUse || !p->alive) + continue; + const dReal *pos = dBodyGetPosition(p->body); + float px = (float)pos[0], pz = (float)pos[2]; + if (px < TERRAIN_MIN || px > TERRAIN_MAX || pz < TERRAIN_MIN || + pz > TERRAIN_MAX) { + p->borderDamageTimer += DT; + if (p->borderDamageTimer >= 0.5f) { + p->borderDamageTimer -= 0.5f; + p->hp -= 1; + if (p->hp <= 0) { + p->hp = 0; + p->alive = 0; + // Drop loot as in shooting death + const dReal *pos2 = dBodyGetPosition(p->body); + float x = (float)pos2[0], z = (float)pos2[2]; + if (p->pistolAmmo > 0) { + int qty = p->pistolAmmo; + if (qty > 12) + qty = 12; + item_spawn(ITEM_AMMO_PISTOL, qty, + x + frand_signed(&p->rng) * 2.0f, + z + frand_signed(&p->rng) * 2.0f); + p->pistolAmmo -= qty; + } + if (p->rifleAmmo > 0) { + int qty = p->rifleAmmo; + if (qty > 30) + qty = 30; + item_spawn(ITEM_AMMO_RIFLE, qty, + x + frand_signed(&p->rng) * 2.0f, + z + frand_signed(&p->rng) * 2.0f); + p->rifleAmmo -= qty; + } + if (p->medkits > 0) { + int qty = p->medkits; + if (qty > 2) + qty = 2; + item_spawn(ITEM_MEDKIT, qty, x + frand_signed(&p->rng) * 2.0f, + z + frand_signed(&p->rng) * 2.0f); + p->medkits -= qty; + } + printf("Player %d died from border damage and dropped loot\n", i); + } + } + } else { + p->borderDamageTimer = 0.0f; + } + } MsgSnapshot snap = {0}; snap.type = MSG_SNAPSHOT;