le jeu des motos dans tron - retour accueil
git clone git://bebou.netlib.re/tron
Log | Files | Refs | README |
commit ca3af25ffffff47cff3ba45160dcdcef64661f3c parent 9e2c6509dcdb355ee3f6be705f2bae94b4b37142 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Thu, 19 Jun 2025 12:03:53 +0200 On sait laquelle est morte Diffstat:
M | tron.c | | | 6 | ++++-- |
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tron.c b/tron.c @@ -38,7 +38,7 @@ int is_in_conflict(struct car *cars, int ticks) { for (int j=0;j<ticks;j++) { if (cars[i].position.x==cars[i].path[j].x && cars[i].position.y==cars[i].path[j].y) - return 1; + return i+1; } } return 0; @@ -73,7 +73,9 @@ int main(int argc, char **argv) { while(1) { for(int i=0;i<2;i++) update(&cars[i],incs,ticknb); - if(is_in_conflict(cars,ticknb)) { + dead_car=is_in_conflict(cars,ticknb); + if(dead_car>0) { + printf("car %d is dead",dead_car); tb_shutdown(); return 0; }