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

@@ -3,19 +3,30 @@
#include "vector.h"
#include "world.h"
int EntityMove(entity* e, vec2 pos) {
#include "stdio.h"
int EntityMove(entity* e, vec2* pos) {
world* world = e->world;
if(world->wells[at(pos.x,pos.y, world)].cell->flags & (CELL_FLAG_BLOCKING)){
vec2 p = *pos;
if(pos->x < 0) {
p.x = (world->size_x + (pos->x- 1)) ;
printf("x less then 0 setting p.x to %d\n", p.x);
pos->x = p.x;
}
if(pos->y < 0) {
p.y = (world->size_y + (pos->y - 1)) ;
printf("y less then 0 setting p.y to %d\n", p.y);
pos->y = p.y;
}
if(world->wells[at(p.x,p.y, world)].cell->flags & (CELL_FLAG_BLOCKING)){
return 1;
}
if(world->wells[at(pos.x,pos.y, world)].entityIds[0] != NULL){
if(world->wells[at(p.x,p.y, world)].entityIds[0] != NULL){
return 2;
}
world->wells[at(e->position.x,e->position.y, world)].entityIds[0] = 0;
world->wells[at(pos.x,pos.y, world)].entityIds[0] = e;
e->position = pos;
world->wells[at(p.x,p.y, world)].entityIds[0] = e;
e->position = p;
return 0;
}