diff --git a/bin/back b/bin/back index 261582f..bd7c58b 100755 Binary files a/bin/back and b/bin/back differ diff --git a/levels/test.txt b/levels/test.txt index c7dea7e..bf0588d 100644 --- a/levels/test.txt +++ b/levels/test.txt @@ -1,9 +1,10 @@ -5 6 -S..... -031E.. -024... -215... -...... +5 5 +..S.. +..214 +...35 +.E15. +..... + $ . = NULL diff --git a/obj/cars.o b/obj/cars.o index a5fb509..de11045 100644 Binary files a/obj/cars.o and b/obj/cars.o differ diff --git a/obj/collisions.o b/obj/collisions.o index 04c0f78..e503cd8 100644 Binary files a/obj/collisions.o and b/obj/collisions.o differ diff --git a/obj/display.o b/obj/display.o index d5ccc1c..6f740c6 100644 Binary files a/obj/display.o and b/obj/display.o differ diff --git a/obj/main.o b/obj/main.o index 54aec2c..eeeb2e9 100644 Binary files a/obj/main.o and b/obj/main.o differ diff --git a/obj/structure.o b/obj/structure.o index 495b56d..09a49d8 100644 Binary files a/obj/structure.o and b/obj/structure.o differ diff --git a/src/cars.c b/src/cars.c index c793f5c..371a0d7 100644 --- a/src/cars.c +++ b/src/cars.c @@ -32,8 +32,8 @@ car* init_car(int nPl, int nTotPl) { res->nCoins = 0; res->pos = get_position(nPl, nTotPl); res->lastPos = (ptf){.fx = res->pos.fx, .fy = res->pos.fy}; - res->chx = START_CHX; - res->chy = START_CHY; + res->chx = START_CHY; + res->chy = START_CHX; //res->vel = (ptf){.fx = 0.0, .fy = 0.0}; double theta = (2.0*MAX_THETA_SPAWN*nPl/((nTotPl-1==0)?(1):(nTotPl-1)) - 1.0*MAX_THETA_SPAWN); res->vel = (ptf){.fx = (rand()%100-50.0)/100.0*2.0*MAX_SPEED, .fy = (rand()%100-50.0)/100.0*2.0*MAX_SPEED}; diff --git a/src/collisions.c b/src/collisions.c index 01e7ac4..732ebca 100644 --- a/src/collisions.c +++ b/src/collisions.c @@ -134,11 +134,11 @@ void bumpOtherCars(int nPl) { double speed_P = norm(players[p].c->vel); double speed_N = norm(players[nPl].c->vel); - players[p].c->vel.fx = director.fx*RESTITUTION_PLAYER*(speed_P - speed_P/2.0 + speed_N/2.0); - players[p].c->vel.fy = director.fy*RESTITUTION_PLAYER*(speed_P - speed_P/2.0 + speed_N/2.0); + players[p].c->vel.fx = director.fx*RESTITUTION_PLAYER*(speed_N); + players[p].c->vel.fy = director.fy*RESTITUTION_PLAYER*(speed_N); - players[nPl].c->vel.fx = -director.fx*RESTITUTION_PLAYER*(speed_N + speed_P/2.0 - speed_N/2.0); - players[nPl].c->vel.fy = -director.fy*RESTITUTION_PLAYER*(speed_N + speed_P/2.0 - speed_N/2.0); + players[nPl].c->vel.fx = -director.fx*RESTITUTION_PLAYER*(speed_P); + players[nPl].c->vel.fy = -director.fy*RESTITUTION_PLAYER*(speed_P); } } } diff --git a/src/display.c b/src/display.c index a7b4a08..d1b5c93 100644 --- a/src/display.c +++ b/src/display.c @@ -504,10 +504,10 @@ void renderCircles(SDL_Renderer* renderer, level* lvl, int cx, int cy, int range void renderPlayers(SDL_Renderer* renderer, int cx, int cy, int range, int rsize) { for(int p = 0; p < nPlayers; p++) { if(players[p].c->chx >= cx-range && players[p].c->chx <= cx+range && players[p].c->chy >= cy-range && players[p].c->chy <= cy+range) { - int plchx = players[p].c->chx; - int plchy = players[p].c->chy; - int cox = (WIDTH-rsize)/2+rsize*(plchx-cx) + (int)((players[p].c->pos.fx*1.0)/ROOM_SIZE*rsize); - int coy = (HEIGHT-rsize)/2+rsize*(plchy-cy) + (int)((players[p].c->pos.fy*1.0)/ROOM_SIZE*rsize); + int cox = (WIDTH-rsize)/2+rsize*(players[p].c->chx-cy) + (int)((players[p].c->pos.fx*1.0)/ROOM_SIZE*rsize); + int coy = (HEIGHT-rsize)/2+rsize*(players[p].c->chy-cx) + (int)((players[p].c->pos.fy*1.0)/ROOM_SIZE*rsize); + //printf("Abs : (%d %d)\n", players[p].c->chx, players[p].c->chy); + //printf("Relative : (%d : %d)\n", players[p].c->chx-cy, players[p].c->chy-cx); SDL_RenderFillCircle(renderer, cox, coy, PLAYER_R, players[p].rgb.red, players[p].rgb.green, players[p].rgb.blue, 255); } else { // diff --git a/src/main.c b/src/main.c index 3e1261d..47558cf 100644 --- a/src/main.c +++ b/src/main.c @@ -18,7 +18,7 @@ #include "rooms.h" #include "cars.h" -const int N_PLAYERS = 6; +const int N_PLAYERS = 4; double elapsed = 0.0; bool halt = false; @@ -77,7 +77,7 @@ int main() { while(!halt) { resetRenderer(rend); - renderMap(rend, test, 1, 1, 2, 250); + renderMap(rend, test, 1, 2, 2, 250); if(elapsed <= 0.7) { placeRectToRenderer(rend, 0, 0, 50, 50, 255, 255, 32, 192); } else if(updateCars(test)) { diff --git a/src/structure.c b/src/structure.c index 297855e..b0cc5b8 100644 --- a/src/structure.c +++ b/src/structure.c @@ -15,12 +15,12 @@ const double RESTITUTION_WALL = 0.8; const double RESTITUTION_PLAYER = 0.8; const int PLAYER_R = 10; -const int MAX_THETA_SPAWN = 60; // degrees +const int MAX_THETA_SPAWN = 80; // degrees const int BARRIERS = 1; const double BARRIER_WIDTH = 0.05; const double FRICTION = 0.75; -const double DV = 1.0; // m/s +const double DV = 1.5; // m/s const double DT = 1.0/100.0; const double EPSILON = 1.0/4096.0; \ No newline at end of file