le jeu des motos dans tron - retour accueil
git clone git://bebou.netlib.re/tron
Log | Files | Refs | README |
commit 28daec387a12bf6cd28ce4cca5923b8617092d4f parent 26866e2bd34ac730d99d6587297967444ebeb504 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Thu, 26 Jun 2025 15:17:45 +0200 Ajout/Suppr des vélos dans le titre corrects Diffstat:
M | tron.c | | | 19 | ++++++++++++++----- |
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/tron.c b/tron.c @@ -164,13 +164,22 @@ int main(int argc, char **argv) { tb_poll_event(&ev); switch(ev.ch) { case 43: /*+*/ - if (bikes.count>=MAX_CAR_NUMBER) break; - createbike(bikes.count%8+2,&bikes,arena); - update(&bikes.list[bikes.count-1],incs); + if (bikes.count<MAX_CAR_NUMBER) { + createbike(bikes.count%8+2,&bikes,arena); + update(&bikes.list[bikes.count-1],incs); + } else + for (int i=0;i<bikes.count;i++) + if(bikes.list[i].status==DEAD) { + bikes.list[i].status=ALIVE; + break; + } break; case 45: /*-*/ - kill_bike(&bikes,bikes.count-1); - break; + for (int i=bikes.count-1;i>=0;i--) + if(bikes.list[i].status==ALIVE) { + kill_bike(&bikes,i); + break; + } } }