le jeu des motos dans tron - retour accueil
git clone git://bebou.netlib.re/tron
Log | Files | Refs | README |
commit aa2ea1759082a10c43533b5e1bf9c962cc3fe295 parent a1af2ee374f40706a9c94f595c50036ab5ddf54d Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Thu, 26 Jun 2025 21:32:37 +0200 On peut quitter quand on veut Méga copier/colleeeeer J'ai pas d'idée sur comment faire autrement là de suite Diffstat:
M | tron.c | | | 17 | +++++++++++++++-- |
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tron.c b/tron.c @@ -181,6 +181,12 @@ int main(int argc, char **argv) { break; } } + if(ev.key==27) { + for (int i=0;i<bikes.count;i++) free(bikes.list[i].path); + free (bikes.list); + tb_shutdown(); + return 0; + } } /*On joue*/ @@ -200,8 +206,15 @@ int main(int argc, char **argv) { display_title_screen(height,width); display(bikes,ticknb,arena,timeout); tb_present(); - do tb_poll_event(&ev); - while(ev.ch!=32); + do { + tb_poll_event(&ev); + if (ev.key==27) { + for (int i=0;i<bikes.count;i++) free(bikes.list[i].path); + free (bikes.list); + tb_shutdown(); + return 0; + } + } while(ev.ch!=32); break; case 122: /*z*/ if(bikes.list[1].direction!=DOWN) bikes.list[1].direction=UP;