adding multiplayer
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user