added options to remove the barriers (// if you touch a barrier you're send to the last stable position)
This commit is contained in:
parent
e7c8539460
commit
a4ee6d55b5
8
Makefile
8
Makefile
|
@ -4,15 +4,15 @@ LFLAGS = -lSDL2 -lSDL2_image -lm
|
||||||
|
|
||||||
all: bin/back
|
all: bin/back
|
||||||
|
|
||||||
replay: bin/back
|
|
||||||
bin/back levels/test.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4
|
|
||||||
|
|
||||||
testL: bin/back
|
testL: bin/back
|
||||||
bin/back levels/test.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4 bots/dumb5 bots/dumb6
|
bin/back levels/long.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4 bots/dumb5 bots/dumb6
|
||||||
|
|
||||||
test: bin/back
|
test: bin/back
|
||||||
bin/back levels/test.txt bots/follow1 bots/follow2 bots/follow3 bots/dumb4
|
bin/back levels/test.txt bots/follow1 bots/follow2 bots/follow3 bots/dumb4
|
||||||
|
|
||||||
|
test2: bin/back
|
||||||
|
bin/back levels/long.txt bots/follow1 bots/follow2 bots/follow3 bots/dumb4
|
||||||
|
|
||||||
ez: bin/back
|
ez: bin/back
|
||||||
bin/back levels/simple.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4
|
bin/back levels/simple.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
312 74
|
15 60
|
248
lastActions.txt
248
lastActions.txt
|
@ -1,16 +1,232 @@
|
||||||
-93.744313 76.432231
|
-164.876636 19.899629
|
||||||
116.117314 137.544103
|
-131.793958 142.637930
|
||||||
-108.851340 -205.127439
|
-35.313109 202.939788
|
||||||
-39.162874 101.722447
|
31.598090 123.177047
|
||||||
-101.439733 -85.837810
|
-72.709254 -146.236387
|
||||||
180.096064 -170.152889
|
167.465280 -160.606464
|
||||||
-167.076955 -186.299969
|
-15.466478 190.742777
|
||||||
-105.566090 -54.025360
|
-113.615798 114.656903
|
||||||
-151.804605 175.133056
|
-137.030419 -30.450931
|
||||||
143.612213 161.055315
|
73.528832 -119.056420
|
||||||
-195.623634 -3.422337
|
-22.441415 240.372419
|
||||||
43.548113 142.177413
|
27.306206 162.745110
|
||||||
226.881116 52.960296
|
128.978022 -190.339990
|
||||||
99.886135 -130.792870
|
-32.328017 96.659938
|
||||||
-192.161607 118.121488
|
171.966882 -120.219159
|
||||||
83.948961 -98.039540
|
-177.165811 -42.747950
|
||||||
|
133.355650 28.931980
|
||||||
|
-121.650614 109.756008
|
||||||
|
-158.618004 88.437235
|
||||||
|
-184.518541 -163.020850
|
||||||
|
30.193845 133.756412
|
||||||
|
136.650719 -156.823801
|
||||||
|
34.042093 210.930566
|
||||||
|
-203.624243 -111.244981
|
||||||
|
53.561036 186.500620
|
||||||
|
-154.788353 53.762090
|
||||||
|
149.519829 115.961924
|
||||||
|
-0.546410 185.296582
|
||||||
|
128.339963 -23.835604
|
||||||
|
191.888500 -137.989675
|
||||||
|
158.485594 49.178646
|
||||||
|
79.823772 133.410342
|
||||||
|
43.509856 141.435608
|
||||||
|
-162.478660 -106.472242
|
||||||
|
-195.234761 -29.200025
|
||||||
|
-133.665895 -16.267565
|
||||||
|
99.319570 15.260796
|
||||||
|
196.348045 6.568111
|
||||||
|
173.042173 -38.252209
|
||||||
|
-52.740724 -218.691870
|
||||||
|
46.028600 122.962056
|
||||||
|
51.867701 -147.720968
|
||||||
|
72.447883 186.744649
|
||||||
|
80.124954 189.646459
|
||||||
|
-87.094817 127.640372
|
||||||
|
117.092358 25.875959
|
||||||
|
-203.447572 -3.687761
|
||||||
|
176.876470 -12.491359
|
||||||
|
160.000303 -75.636880
|
||||||
|
-113.120377 -37.010111
|
||||||
|
177.458511 -36.941434
|
||||||
|
36.643910 180.906647
|
||||||
|
-29.114493 148.502977
|
||||||
|
-58.550805 136.189113
|
||||||
|
10.476107 -203.692536
|
||||||
|
99.392763 -182.298258
|
||||||
|
-123.922262 -25.812484
|
||||||
|
67.708986 136.736176
|
||||||
|
151.615675 115.814645
|
||||||
|
-63.304437 -203.449472
|
||||||
|
39.177306 -138.117487
|
||||||
|
33.036223 164.482142
|
||||||
|
-97.023064 -148.570859
|
||||||
|
-174.547334 94.748045
|
||||||
|
161.666149 35.378155
|
||||||
|
-32.042213 111.465654
|
||||||
|
-186.112498 -3.328420
|
||||||
|
-68.160481 -146.909768
|
||||||
|
-79.909244 99.252495
|
||||||
|
-94.187705 -52.868307
|
||||||
|
179.235732 -42.175283
|
||||||
|
179.443311 46.704399
|
||||||
|
-50.147668 151.315084
|
||||||
|
-74.791729 192.098011
|
||||||
|
-172.738639 6.289572
|
||||||
|
56.881383 178.815273
|
||||||
|
30.929376 157.136440
|
||||||
|
-5.160238 -158.972241
|
||||||
|
233.529442 106.742601
|
||||||
|
209.255010 0.645630
|
||||||
|
24.661504 -114.333565
|
||||||
|
-207.836726 -22.173055
|
||||||
|
-57.756658 -215.848892
|
||||||
|
-46.798571 -132.859262
|
||||||
|
139.134254 -75.832466
|
||||||
|
-183.134469 163.389721
|
||||||
|
-94.529561 -137.885661
|
||||||
|
-59.247523 132.523873
|
||||||
|
-112.370963 -5.683564
|
||||||
|
121.408439 -129.404117
|
||||||
|
-140.040462 158.280215
|
||||||
|
-25.859626 -181.316033
|
||||||
|
-97.036059 132.042199
|
||||||
|
166.494511 -104.706804
|
||||||
|
-158.519766 -195.240271
|
||||||
|
60.175525 95.806721
|
||||||
|
-150.252442 104.972901
|
||||||
|
56.429178 173.910136
|
||||||
|
-181.083300 54.835290
|
||||||
|
-145.856729 20.485311
|
||||||
|
51.752973 -105.278905
|
||||||
|
-149.622544 -43.024281
|
||||||
|
143.535309 213.914450
|
||||||
|
-108.491656 -124.748348
|
||||||
|
49.658568 -90.534766
|
||||||
|
-117.067993 132.637241
|
||||||
|
152.114332 -144.443519
|
||||||
|
249.793417 -68.991815
|
||||||
|
-136.453687 13.037382
|
||||||
|
83.341785 71.310446
|
||||||
|
-58.710710 252.921140
|
||||||
|
195.872638 -114.100544
|
||||||
|
-192.900725 15.469874
|
||||||
|
6.182071 130.846122
|
||||||
|
-251.299931 51.366640
|
||||||
|
-210.069968 -15.747961
|
||||||
|
176.893730 151.876228
|
||||||
|
-95.249381 -102.486712
|
||||||
|
15.359101 192.296747
|
||||||
|
-45.591694 266.808291
|
||||||
|
-146.376425 101.877975
|
||||||
|
56.073277 143.911676
|
||||||
|
-107.635160 -116.766613
|
||||||
|
172.732231 -33.546957
|
||||||
|
-179.860685 175.033756
|
||||||
|
93.059084 -45.132589
|
||||||
|
15.605335 -170.023508
|
||||||
|
-73.390211 -111.401032
|
||||||
|
-101.446883 223.948117
|
||||||
|
106.459664 -18.918352
|
||||||
|
-193.563254 36.405068
|
||||||
|
-235.494997 38.498427
|
||||||
|
-230.163625 0.041291
|
||||||
|
-127.165631 -21.312624
|
||||||
|
-45.621901 189.267225
|
||||||
|
126.480850 169.532029
|
||||||
|
115.246764 -131.338987
|
||||||
|
-44.457073 122.750467
|
||||||
|
216.667693 -129.520231
|
||||||
|
108.245895 154.259396
|
||||||
|
221.132741 11.576041
|
||||||
|
114.223203 -56.141271
|
||||||
|
229.602891 59.666708
|
||||||
|
-177.370950 -119.341067
|
||||||
|
91.156217 -154.529352
|
||||||
|
-39.824547 -143.294433
|
||||||
|
-65.674258 -160.940022
|
||||||
|
-203.665153 -59.336865
|
||||||
|
-89.292979 193.934446
|
||||||
|
98.908107 -98.459523
|
||||||
|
158.295770 68.748970
|
||||||
|
-53.390834 -168.704926
|
||||||
|
-152.004524 -167.178374
|
||||||
|
122.610769 34.051383
|
||||||
|
109.474339 150.681326
|
||||||
|
-135.655457 138.596429
|
||||||
|
15.797554 214.292890
|
||||||
|
-118.483302 -63.473311
|
||||||
|
-231.215638 97.253671
|
||||||
|
-151.328243 -79.824562
|
||||||
|
3.098388 171.259667
|
||||||
|
94.841262 -114.786068
|
||||||
|
134.817518 -171.068071
|
||||||
|
69.537313 -180.367643
|
||||||
|
-225.561887 -78.384990
|
||||||
|
-110.783481 -76.878757
|
||||||
|
141.931161 -160.337536
|
||||||
|
200.384232 34.701917
|
||||||
|
-132.468011 -186.721770
|
||||||
|
2.308866 -184.610935
|
||||||
|
226.181539 -90.522499
|
||||||
|
109.494698 -78.683610
|
||||||
|
162.480524 191.429014
|
||||||
|
126.511640 -79.825025
|
||||||
|
-126.415076 168.036147
|
||||||
|
179.839455 -49.489592
|
||||||
|
158.096728 -17.460192
|
||||||
|
81.268221 80.079465
|
||||||
|
-84.704466 212.941911
|
||||||
|
-20.892930 -116.493503
|
||||||
|
79.229842 217.766200
|
||||||
|
-32.203277 -101.189233
|
||||||
|
-244.149247 -44.699792
|
||||||
|
-156.849364 103.341992
|
||||||
|
144.430750 62.478498
|
||||||
|
157.338730 -73.760521
|
||||||
|
-54.540289 198.052385
|
||||||
|
58.775681 116.284743
|
||||||
|
-133.090178 113.116505
|
||||||
|
137.104165 -86.307220
|
||||||
|
-162.652402 156.153891
|
||||||
|
172.119108 -118.289943
|
||||||
|
-169.350223 42.685176
|
||||||
|
-161.756411 -51.234001
|
||||||
|
-78.828134 -239.895237
|
||||||
|
21.897849 190.928634
|
||||||
|
110.756934 -91.561042
|
||||||
|
109.215894 -36.721603
|
||||||
|
-27.426429 -192.311576
|
||||||
|
105.731650 63.681074
|
||||||
|
-130.224095 30.549887
|
||||||
|
149.030146 -48.350946
|
||||||
|
179.744970 56.181260
|
||||||
|
173.146361 -36.692215
|
||||||
|
-161.608998 -191.212124
|
||||||
|
46.405002 -110.601725
|
||||||
|
-126.494430 -182.844076
|
||||||
|
82.565319 -153.900977
|
||||||
|
-159.803180 20.293362
|
||||||
|
90.700865 -136.990084
|
||||||
|
-153.689848 89.127693
|
||||||
|
49.694125 159.942072
|
||||||
|
-34.742757 -205.970802
|
||||||
|
-100.398021 -93.644589
|
||||||
|
65.927274 244.127943
|
||||||
|
142.635188 -112.380019
|
||||||
|
95.344345 137.565429
|
||||||
|
63.870301 116.862762
|
||||||
|
-34.130933 209.000317
|
||||||
|
-163.815603 16.381362
|
||||||
|
-142.724086 75.330433
|
||||||
|
122.840677 116.919247
|
||||||
|
-94.536550 149.752365
|
||||||
|
-7.870342 130.029191
|
||||||
|
-31.054691 -235.845912
|
||||||
|
60.969559 -95.327286
|
||||||
|
-159.216181 -44.547472
|
||||||
|
-179.029626 78.955844
|
||||||
|
-148.122749 106.017190
|
||||||
|
145.503305 -25.752061
|
||||||
|
239.604803 74.792529
|
||||||
|
128.906511 38.617973
|
||||||
|
|
|
@ -2,10 +2,10 @@ name, elo
|
||||||
./bots/dumb 1347
|
./bots/dumb 1347
|
||||||
./bots/dumb2 1404
|
./bots/dumb2 1404
|
||||||
./bots/dumb3 1355
|
./bots/dumb3 1355
|
||||||
./bots/dumb4 980
|
./bots/dumb4 885
|
||||||
./bots/dumb5 540
|
./bots/dumb5 540
|
||||||
./bots/dumb6 562
|
./bots/dumb6 562
|
||||||
./bots/follow1 854
|
./bots/follow1 881
|
||||||
./bots/follow2 1003
|
./bots/follow2 1055
|
||||||
./bots/follow3 899
|
./bots/follow3 933
|
||||||
./bots/follow4 648
|
./bots/follow4 648
|
||||||
|
|
20
output.txt
20
output.txt
|
@ -1,18 +1,14 @@
|
||||||
4
|
4
|
||||||
0 (3 0) (7.52 40.94)
|
0 (1 0) (15.98 83.38)
|
||||||
1 (3 0) (66.47 11.34)
|
1 (6 0) (12.66 31.55)
|
||||||
2 (3 0) (44.58 8.01)
|
2 (1 0) (22.92 36.40)
|
||||||
3 (3 2) (37.59 39.59)
|
3 (3 0) (80.42 49.95)
|
||||||
3
|
3
|
||||||
|
|
||||||
7 8
|
3 10
|
||||||
...S....
|
.S11111114
|
||||||
..35....
|
E........0
|
||||||
..24....
|
2111111115
|
||||||
...24...
|
|
||||||
...353E.
|
|
||||||
...215..
|
|
||||||
........
|
|
||||||
|
|
||||||
100 220 5 0.90 0.80 0.20 0.00 0.20
|
100 220 5 0.90 0.80 0.20 0.00 0.20
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ int RED = 0;
|
||||||
int GREEN = 0;
|
int GREEN = 0;
|
||||||
int BLUE = 0;
|
int BLUE = 0;
|
||||||
|
|
||||||
|
bool* offTheMap;
|
||||||
|
|
||||||
color assignColor() {
|
color assignColor() {
|
||||||
color res = (color){.red = RED, .green = GREEN, .blue = BLUE};
|
color res = (color){.red = RED, .green = GREEN, .blue = BLUE};
|
||||||
|
|
||||||
|
@ -63,11 +65,13 @@ void init_all(int nPl) {
|
||||||
winners = malloc(sizeof(int)*nPlayers);
|
winners = malloc(sizeof(int)*nPlayers);
|
||||||
players = malloc(sizeof(carData)*nPlayers);
|
players = malloc(sizeof(carData)*nPlayers);
|
||||||
remainingD = malloc(sizeof(double)*nPlayers);
|
remainingD = malloc(sizeof(double)*nPlayers);
|
||||||
|
offTheMap = malloc(sizeof(bool)*nPlayers);
|
||||||
for(int p = 0; p < nPlayers; p++) {
|
for(int p = 0; p < nPlayers; p++) {
|
||||||
winners[p] = 0;
|
winners[p] = 0;
|
||||||
players[p].rgb = assignColor();
|
players[p].rgb = assignColor();
|
||||||
remainingD[p] = 0.0;
|
remainingD[p] = 0.0;
|
||||||
players[p].c = init_car(p, nPlayers);
|
players[p].c = init_car(p, nPlayers);
|
||||||
|
offTheMap[p] = false;
|
||||||
}
|
}
|
||||||
minRemD = 0.0;
|
minRemD = 0.0;
|
||||||
maxRemD = 0.0;
|
maxRemD = 0.0;
|
||||||
|
@ -78,6 +82,7 @@ void destroy_all() {
|
||||||
destroy_car(players[p].c);
|
destroy_car(players[p].c);
|
||||||
}
|
}
|
||||||
free(players);
|
free(players);
|
||||||
|
free(offTheMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1 = N
|
// 1 = N
|
||||||
|
|
|
@ -30,10 +30,15 @@ car* init_car(int nPl, int nTotPl) {
|
||||||
car* res = malloc(sizeof(car));
|
car* res = malloc(sizeof(car));
|
||||||
res->itm = NULL;
|
res->itm = NULL;
|
||||||
res->nCoins = 0;
|
res->nCoins = 0;
|
||||||
|
|
||||||
res->pos = get_position(nPl, nTotPl);
|
res->pos = get_position(nPl, nTotPl);
|
||||||
res->lastPos = (ptf){.fx = res->pos.fx, .fy = res->pos.fy};
|
res->lastPos = (ptf){.fx = res->pos.fx, .fy = res->pos.fy};
|
||||||
|
|
||||||
res->chx = START_CHY;
|
res->chx = START_CHY;
|
||||||
|
res->lastChx = START_CHY;
|
||||||
res->chy = START_CHX;
|
res->chy = START_CHX;
|
||||||
|
res->lastChy = START_CHX;
|
||||||
|
|
||||||
res->vel = (ptf){.fx = 0.0, .fy = 0.0};
|
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);
|
//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)/100.0*2.0*MAX_SPEED, .fy = (rand()%100-50.0)/100.0*2.0*MAX_SPEED};
|
//res->vel = (ptf){.fx = (rand()%100)/100.0*2.0*MAX_SPEED, .fy = (rand()%100-50.0)/100.0*2.0*MAX_SPEED};
|
||||||
|
|
282
src/collisions.c
282
src/collisions.c
|
@ -57,33 +57,57 @@ void move_on_START(int nPl) {
|
||||||
(START_DIR != 3 && c->pos.fx-PLAYER_R <= 0.0 && c->vel.fx < 0.0) ||
|
(START_DIR != 3 && c->pos.fx-PLAYER_R <= 0.0 && c->vel.fx < 0.0) ||
|
||||||
(START_DIR == 3 && c->pos.fx-PLAYER_R <= 0.0 && c->vel.fx < 0.0 && (c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE || c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)))
|
(START_DIR == 3 && c->pos.fx-PLAYER_R <= 0.0 && c->vel.fx < 0.0 && (c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE || c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)))
|
||||||
) { // left wall
|
) { // left wall
|
||||||
c->vel.fx *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->vel.fx *= -1.0;
|
||||||
c->vel.fx *= RESTITUTION_WALL;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
|
c->vel.fx *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
(START_DIR != 1 && c->pos.fx+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fx > 0.0) ||
|
(START_DIR != 1 && c->pos.fx+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fx > 0.0) ||
|
||||||
(START_DIR == 1 && c->pos.fx+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fx > 0.0 && (c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE || c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)))
|
(START_DIR == 1 && c->pos.fx+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fx > 0.0 && (c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE || c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)))
|
||||||
) { // right wall
|
) { // right wall
|
||||||
c->vel.fx *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->vel.fx *= -1.0;
|
||||||
c->vel.fx *= RESTITUTION_WALL;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
|
c->vel.fx *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
(START_DIR != 0 && c->pos.fy-PLAYER_R <= 0.0 && c->vel.fy < 0.0) ||
|
(START_DIR != 0 && c->pos.fy-PLAYER_R <= 0.0 && c->vel.fy < 0.0) ||
|
||||||
(START_DIR == 0 && c->pos.fy-PLAYER_R <= 0.0 && c->vel.fy < 0.0 && (c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE || c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)))
|
(START_DIR == 0 && c->pos.fy-PLAYER_R <= 0.0 && c->vel.fy < 0.0 && (c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE || c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)))
|
||||||
) { // top wall
|
) { // top wall
|
||||||
c->vel.fy *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->vel.fy *= -1.0;
|
||||||
c->vel.fy *= RESTITUTION_WALL;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
c->vel.fy *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
(START_DIR != 2 && c->pos.fy+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fy > 0.0) ||
|
(START_DIR != 2 && c->pos.fy+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fy > 0.0) ||
|
||||||
(START_DIR == 2 && c->pos.fy+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fy > 0.0 && (c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE || c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)))
|
(START_DIR == 2 && c->pos.fy+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fy > 0.0 && (c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE || c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)))
|
||||||
) { // bottom wall
|
) { // bottom wall
|
||||||
c->vel.fy *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->vel.fy *= -1.0;
|
||||||
c->vel.fy *= RESTITUTION_WALL;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
c->vel.fy *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,30 +119,54 @@ void move_on_FINISH(int nPl) {
|
||||||
if(
|
if(
|
||||||
(c->pos.fx-PLAYER_R <= 0.0 && c->vel.fx < 0.0)
|
(c->pos.fx-PLAYER_R <= 0.0 && c->vel.fx < 0.0)
|
||||||
) { // left wall
|
) { // left wall
|
||||||
c->vel.fx *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->vel.fx *= -1.0;
|
||||||
c->vel.fx *= RESTITUTION_WALL;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
|
c->vel.fx *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
(c->pos.fx+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fx > 0.0)
|
(c->pos.fx+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fx > 0.0)
|
||||||
) { // right wall
|
) { // right wall
|
||||||
c->vel.fx *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->vel.fx *= -1.0;
|
||||||
c->vel.fx *= RESTITUTION_WALL;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
|
c->vel.fx *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
(c->pos.fy-PLAYER_R <= 0.0 && c->vel.fy < 0.0)
|
(c->pos.fy-PLAYER_R <= 0.0 && c->vel.fy < 0.0)
|
||||||
) { // top wall
|
) { // top wall
|
||||||
c->vel.fy *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->vel.fy *= -1.0;
|
||||||
c->vel.fy *= RESTITUTION_WALL;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
c->vel.fy *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
(c->pos.fy+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fy > 0.0)
|
(c->pos.fy+PLAYER_R >= 1.0*ROOM_SIZE && c->vel.fy > 0.0)
|
||||||
) { // bottom wall
|
) { // bottom wall
|
||||||
c->vel.fy *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->vel.fy *= -1.0;
|
||||||
c->vel.fy *= RESTITUTION_WALL;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
c->vel.fy *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,14 +175,26 @@ void move_on_STR_V(int nPl) {
|
||||||
c->pos.fx += c->vel.fx*DT;
|
c->pos.fx += c->vel.fx*DT;
|
||||||
c->pos.fy += c->vel.fy*DT;
|
c->pos.fy += c->vel.fy*DT;
|
||||||
if(c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fx < 0.0) { // left wall
|
if(c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fx < 0.0) { // left wall
|
||||||
c->vel.fx *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->vel.fx *= -1.0;
|
||||||
c->vel.fx *= RESTITUTION_WALL;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
|
c->vel.fx *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fx > 0.0) { // right wall
|
if(c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fx > 0.0) { // right wall
|
||||||
c->vel.fx *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->vel.fx *= -1.0;
|
||||||
c->vel.fx *= RESTITUTION_WALL;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
|
c->vel.fx *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,14 +204,26 @@ void move_on_STR_VB(int nPl) {
|
||||||
c->pos.fx += c->vel.fx*DT;
|
c->pos.fx += c->vel.fx*DT;
|
||||||
c->pos.fy += c->vel.fy*DT;
|
c->pos.fy += c->vel.fy*DT;
|
||||||
if(c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fx < 0.0) { // left wall
|
if(c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fx < 0.0) { // left wall
|
||||||
c->vel.fx *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->vel.fx *= -1.0;
|
||||||
c->vel.fx *= RESTITUTION_WALL;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
|
c->vel.fx *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fx > 0.0) { // right wall
|
if(c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fx > 0.0) { // right wall
|
||||||
c->vel.fx *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->vel.fx *= -1.0;
|
||||||
c->vel.fx *= RESTITUTION_WALL;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
|
c->vel.fx *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(absf(c->pos.fx - 0.5*ROOM_SIZE) < ROOM_SIZE*STR2_W/2.0) { // middle area
|
if(absf(c->pos.fx - 0.5*ROOM_SIZE) < ROOM_SIZE*STR2_W/2.0) { // middle area
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
|
@ -164,14 +236,26 @@ void move_on_STR_H(int nPl) {
|
||||||
c->pos.fx += c->vel.fx*DT;
|
c->pos.fx += c->vel.fx*DT;
|
||||||
c->pos.fy += c->vel.fy*DT;
|
c->pos.fy += c->vel.fy*DT;
|
||||||
if(c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fy < 0.0) { // top wall
|
if(c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fy < 0.0) { // top wall
|
||||||
c->vel.fy *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->vel.fy *= -1.0;
|
||||||
c->vel.fy *= RESTITUTION_WALL;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
c->vel.fy *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fy > 0.0) { // bottom wall
|
if(c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fy > 0.0) { // bottom wall
|
||||||
c->vel.fy *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->vel.fy *= -1.0;
|
||||||
c->vel.fy *= RESTITUTION_WALL;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
c->vel.fy *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,14 +264,26 @@ void move_on_STR_HB(int nPl) {
|
||||||
c->pos.fx += c->vel.fx*DT;
|
c->pos.fx += c->vel.fx*DT;
|
||||||
c->pos.fy += c->vel.fy*DT;
|
c->pos.fy += c->vel.fy*DT;
|
||||||
if(c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fy < 0.0) { // top wall
|
if(c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fy < 0.0) { // top wall
|
||||||
c->vel.fy *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->vel.fy *= -1.0;
|
||||||
c->vel.fy *= RESTITUTION_WALL;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
c->vel.fy *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fy > 0.0) { // bottom wall
|
if(c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fy > 0.0) { // bottom wall
|
||||||
c->vel.fy *= -1.0;
|
if(BARRIERS == 1) {
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->vel.fy *= -1.0;
|
||||||
c->vel.fy *= RESTITUTION_WALL;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
c->vel.fy *= RESTITUTION_WALL;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(absf(c->pos.fy - 0.5*ROOM_SIZE) < ROOM_SIZE*STR2_W/2.0) { // middle area
|
if(absf(c->pos.fy - 0.5*ROOM_SIZE) < ROOM_SIZE*STR2_W/2.0) { // middle area
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
|
@ -207,60 +303,84 @@ void move_on_TURN(int nPl, int cenX, int cenY) {
|
||||||
|
|
||||||
// inner circle
|
// inner circle
|
||||||
if(prevDist-PLAYER_R > ROOM_SIZE*DIST_EDGE && nextDist-PLAYER_R <= ROOM_SIZE*DIST_EDGE) {
|
if(prevDist-PLAYER_R > ROOM_SIZE*DIST_EDGE && nextDist-PLAYER_R <= ROOM_SIZE*DIST_EDGE) {
|
||||||
ptf to_in = normalize((ptf){
|
if(BARRIERS == 1) {
|
||||||
.fx = cenX-prev.fx,
|
ptf to_in = normalize((ptf){
|
||||||
.fy = cenY-prev.fy
|
.fx = cenX-prev.fx,
|
||||||
});
|
.fy = cenY-prev.fy
|
||||||
double inwards = dot(to_in, c->vel);
|
});
|
||||||
c->vel = add(c->vel, (ptf){.fx = -2.0*to_in.fx*inwards, .fy = -2.0*to_in.fy*inwards});
|
double inwards = dot(to_in, c->vel);
|
||||||
|
c->vel = add(c->vel, (ptf){.fx = -2.0*to_in.fx*inwards, .fy = -2.0*to_in.fy*inwards});
|
||||||
|
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case someone clips (inner)
|
// in case someone clips (inner)
|
||||||
if(nextDist-prevDist < 0.0 && prevDist-PLAYER_R < ROOM_SIZE*DIST_EDGE) {
|
if(nextDist-prevDist < 0.0 && prevDist-PLAYER_R < ROOM_SIZE*DIST_EDGE) {
|
||||||
ptf to_in = normalize((ptf){
|
if(BARRIERS == 1) {
|
||||||
.fx = cenX-prev.fx,
|
ptf to_in = normalize((ptf){
|
||||||
.fy = cenY-prev.fy
|
.fx = cenX-prev.fx,
|
||||||
});
|
.fy = cenY-prev.fy
|
||||||
double inwards = dot(to_in, c->vel);
|
});
|
||||||
c->vel = add(c->vel, (ptf){.fx = -2.0*to_in.fx*inwards, .fy = -2.0*to_in.fy*inwards});
|
double inwards = dot(to_in, c->vel);
|
||||||
|
c->vel = add(c->vel, (ptf){.fx = -2.0*to_in.fx*inwards, .fy = -2.0*to_in.fy*inwards});
|
||||||
|
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// outer circle
|
// outer circle
|
||||||
if(prevDist+PLAYER_R < ROOM_SIZE*(1.0-DIST_EDGE) && nextDist+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)) {
|
if(prevDist+PLAYER_R < ROOM_SIZE*(1.0-DIST_EDGE) && nextDist+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE)) {
|
||||||
ptf to_out = normalize((ptf){
|
if(BARRIERS == 1) {
|
||||||
.fx = prev.fx-cenX,
|
ptf to_out = normalize((ptf){
|
||||||
.fy = prev.fy-cenY
|
.fx = prev.fx-cenX,
|
||||||
});
|
.fy = prev.fy-cenY
|
||||||
double outwards = dot(to_out, c->vel);
|
});
|
||||||
c->vel = add(c->vel, (ptf){.fx = -2.0*to_out.fx*outwards, .fy = -2.0*to_out.fy*outwards});
|
double outwards = dot(to_out, c->vel);
|
||||||
|
c->vel = add(c->vel, (ptf){.fx = -2.0*to_out.fx*outwards, .fy = -2.0*to_out.fy*outwards});
|
||||||
|
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case someone clips (outer)
|
// in case someone clips (outer)
|
||||||
if(nextDist-prevDist > 0.0 && prevDist-PLAYER_R > ROOM_SIZE*(1.0-DIST_EDGE)) {
|
if(nextDist-prevDist > 0.0 && prevDist-PLAYER_R > ROOM_SIZE*(1.0-DIST_EDGE)) {
|
||||||
ptf to_in = normalize((ptf){
|
if(BARRIERS == 1) {
|
||||||
.fx = cenX-prev.fx,
|
ptf to_in = normalize((ptf){
|
||||||
.fy = cenY-prev.fy
|
.fx = cenX-prev.fx,
|
||||||
});
|
.fy = cenY-prev.fy
|
||||||
double inwards = dot(to_in, c->vel);
|
});
|
||||||
c->vel = add(c->vel, (ptf){.fx = -2.0*to_in.fx*inwards, .fy = -2.0*to_in.fy*inwards});
|
double inwards = dot(to_in, c->vel);
|
||||||
|
c->vel = add(c->vel, (ptf){.fx = -2.0*to_in.fx*inwards, .fy = -2.0*to_in.fy*inwards});
|
||||||
|
|
||||||
c->pos.fx += 2.0*c->vel.fx*DT;
|
c->pos.fx += 2.0*c->vel.fx*DT;
|
||||||
c->pos.fy += 2.0*c->vel.fy*DT;
|
c->pos.fy += 2.0*c->vel.fy*DT;
|
||||||
|
} else {
|
||||||
|
c->vel.fx = 0.0;
|
||||||
|
c->vel.fy = 0.0;
|
||||||
|
offTheMap[nPl] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bumpOtherCars(int nPl) {
|
void bumpOtherCars(int nPl) {
|
||||||
for(int p = 0; p < nPlayers; p++) {
|
for(int p = 0; p < nPlayers; p++) {
|
||||||
if(p != nPl && 0==winners[p]) {
|
if(p != nPl && 0==winners[p] && !offTheMap[p]) {
|
||||||
double sep = distance(
|
double sep = distance(
|
||||||
get_absolute_coords(p),
|
get_absolute_coords(p),
|
||||||
get_absolute_coords(nPl)
|
get_absolute_coords(nPl)
|
||||||
|
|
|
@ -569,7 +569,8 @@ void renderPlayers(SDL_Renderer* renderer, int cx, int cy, int range, int rsize)
|
||||||
//printf("[%d]", p);
|
//printf("[%d]", p);
|
||||||
int cox = (WIDTH-rsize)/2+rsize*(players[p].c->chx-cy) + (int)((players[p].c->pos.fx*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);
|
int coy = (HEIGHT-rsize)/2+rsize*(players[p].c->chy-cx) + (int)((players[p].c->pos.fy*1.0)/ROOM_SIZE*rsize);
|
||||||
SDL_RenderFillCircle(renderer, cox, coy, PLAYER_R*rsize/ROOM_SIZE, players[p].rgb.red, players[p].rgb.green, players[p].rgb.blue, 255);
|
int divd = (offTheMap[p])?(2):(1);
|
||||||
|
SDL_RenderFillCircle(renderer, cox, coy, PLAYER_R*rsize/ROOM_SIZE, players[p].rgb.red/divd, players[p].rgb.green/divd, players[p].rgb.blue/divd, 255);
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
15
src/main.c
15
src/main.c
|
@ -252,6 +252,21 @@ int main(int argc, char** argv) {
|
||||||
// no movement
|
// no movement
|
||||||
placeRectToRenderer(rend, 0, HEIGHT-50, 50, 50, 255, 32, 32, 192);
|
placeRectToRenderer(rend, 0, HEIGHT-50, 50, 50, 255, 32, 32, 192);
|
||||||
//B *= -1.0;
|
//B *= -1.0;
|
||||||
|
// update stable positions
|
||||||
|
for(int p = 0; p < nPlayers; p++) {
|
||||||
|
if(!offTheMap[p]) {
|
||||||
|
players[p].c->lastPos.fx = players[p].c->pos.fx;
|
||||||
|
players[p].c->lastPos.fy = players[p].c->pos.fy;
|
||||||
|
players[p].c->lastChx = players[p].c->chx;
|
||||||
|
players[p].c->lastChy = players[p].c->chy;
|
||||||
|
} else {
|
||||||
|
players[p].c->pos.fx = players[p].c->lastPos.fx;
|
||||||
|
players[p].c->pos.fy = players[p].c->lastPos.fy;
|
||||||
|
players[p].c->chx = players[p].c->lastChx;
|
||||||
|
players[p].c->chy = players[p].c->lastChy;
|
||||||
|
}
|
||||||
|
offTheMap[p] = false;
|
||||||
|
}
|
||||||
updateWins(ranks);
|
updateWins(ranks);
|
||||||
if(ONEATATIME == 1) {
|
if(ONEATATIME == 1) {
|
||||||
if(remainingTurns != 0 && 0==winners[playerToMove]) {
|
if(remainingTurns != 0 && 0==winners[playerToMove]) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ const double RESTITUTION_PLAYER = 0.8; // keep equal to previous constant
|
||||||
const int PLAYER_R = 5;
|
const int PLAYER_R = 5;
|
||||||
const int MAX_THETA_SPAWN = 80; // degrees
|
const int MAX_THETA_SPAWN = 80; // degrees
|
||||||
|
|
||||||
const int BARRIERS = 1; // enables/disables barriers [UNUSED]
|
const int BARRIERS = 0; // enables/disables barriers
|
||||||
const int ONEATATIME = 0; // 0 = everyone move at the same time, 1 = turn-based movement (one player at a time)
|
const int ONEATATIME = 0; // 0 = everyone move at the same time, 1 = turn-based movement (one player at a time)
|
||||||
const double BARRIER_WIDTH = 0.05;
|
const double BARRIER_WIDTH = 0.05;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,11 @@ typedef struct item_t {
|
||||||
|
|
||||||
typedef struct car_t {
|
typedef struct car_t {
|
||||||
ptf pos; // remains in [0, ROOM_SIZE[
|
ptf pos; // remains in [0, ROOM_SIZE[
|
||||||
ptf lastPos;
|
ptf lastPos; // last static position for the car (used when barriers are off)
|
||||||
int chx;
|
int chx;
|
||||||
int chy;
|
int chy;
|
||||||
|
int lastChx;
|
||||||
|
int lastChy;
|
||||||
ptf vel;
|
ptf vel;
|
||||||
int nCoins;
|
int nCoins;
|
||||||
item* itm; // either NULL or a pointer to an item
|
item* itm; // either NULL or a pointer to an item
|
||||||
|
@ -79,6 +81,8 @@ extern int currentTurn; // name explains
|
||||||
|
|
||||||
extern carData* players; // contains each player and its corresponding data
|
extern carData* players; // contains each player and its corresponding data
|
||||||
extern int nPlayers; // size of players
|
extern int nPlayers; // size of players
|
||||||
|
|
||||||
|
extern bool* offTheMap; // offTheMap[p] = true <==> the player p is off the map (groundbreaking I know)
|
||||||
// ------------------------------------------------------------------------ //
|
// ------------------------------------------------------------------------ //
|
||||||
// constants
|
// constants
|
||||||
extern const int WIDTH;
|
extern const int WIDTH;
|
||||||
|
|
|
@ -2,10 +2,10 @@ name, elo
|
||||||
./bots/dumb 1347
|
./bots/dumb 1347
|
||||||
./bots/dumb2 1404
|
./bots/dumb2 1404
|
||||||
./bots/dumb3 1355
|
./bots/dumb3 1355
|
||||||
./bots/dumb4 980
|
./bots/dumb4 885
|
||||||
./bots/dumb5 540
|
./bots/dumb5 540
|
||||||
./bots/dumb6 562
|
./bots/dumb6 562
|
||||||
./bots/follow1 854
|
./bots/follow1 881
|
||||||
./bots/follow2 1003
|
./bots/follow2 1055
|
||||||
./bots/follow3 899
|
./bots/follow3 933
|
||||||
./bots/follow4 648
|
./bots/follow4 648
|
||||||
|
|
Loading…
Reference in New Issue