adding multiplayer

This commit is contained in:
2026-04-15 06:57:15 -07:00
parent af639e62c3
commit 3a91db6321
32 changed files with 938 additions and 174 deletions

View File

@@ -6,7 +6,9 @@
#include <unistd.h>
#include <signal.h>
#include "../game_source/entities/Player.h"
#include "../game_source/entities/Player_e.h"
#include "../game_source/entities/Player_c.h"
#include "../game_source/entities/Centery.h"
#include <sys/random.h>
#include <stdio.h>
#include <locale.h>
@@ -78,13 +80,36 @@ int client_init(void* cli) {
CreateWorld(&c->world, clock());
InitWorld(&c->world);
entity* cen = CreatePlayer("testing", c, &c->world);
cen->position.x = 3;
cen->position.y = 3;
AddEntity(&c->world, cen);
player_data p = {
.holding = 0,
.class = 0,
.health = 20,
.ac = 4,
.str = 0,
.wis = 0,
.intel = 0,
.dex = 0,
.name = "testing",
.c = (color){100,100,100},
};
entity* pc = CreatePlayerCharecter(p,c, &c->world);
entity* pe = CreatePlayerEntity(p,0, &c->world);
//pc->position.x = 3;
//pc->position.y = 3;
pe->position.x = 3;
pe->position.y = 3;
//AddEntity(&c->world, pc);
AddEntity(&c->world, pe);
GenerateWorld(&c->world);
CammeraInit(&c->cam, 150,50,0,0,&c->world, &c->w);
clock_gettime(CLOCK_MONOTONIC,&c->last_time);
memset(&c->server, 0, sizeof(game_server));
if(Connect(&c->server) < 0) {
printf("Could not connect to server\n");
return -1;
}
pe->server = c->server.game_info.socket;
return 0;
}
@@ -104,6 +129,8 @@ int client_update(ssh_terminal_data* td, void* cli) {
tart_jump(&w, (tart_vec2){w.windowSize.x, w.windowSize.y-1});
tart_insert_cell(&w, 5, 'a');
tart_jump(&w, (tart_vec2){0,0});
tart_printf(&w, 5, T"Entities %d\n", c->world.ent_list->count);
}