le jeu des motos dans tron - retour accueil
git clone git://bebou.netlib.re/tron
Log | Files | Refs | README |
commit 284b6e2c41c9848ecff12dd007d8bc86c912fac2 parent a2aca3d01eb2fa96f65cd1eeda8e7df7c68c4e35 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Wed, 25 Jun 2025 16:17:10 +0200 On tente d'init les path, on les free à la fin Diffstat:
M | tron.c | | | 7 | ++++++- |
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tron.c b/tron.c @@ -74,7 +74,11 @@ int rd(int min, int max) { struct car createcar(int color, struct arena a) { struct car c; - c.path=malloc(sizeof(coord)*900); + c.path=malloc(sizeof(coord)*TAIL); + for (int i=0;i<TAIL;i++) { + coord p; p.x=0; p.y=0; + c.path[i]=p; + } c.color=color; c.position.x=rd(10,a.width-10); c.position.y=rd(10,a.height-10); if(c.position.x<a.width/2) c.direction=RIGHT; else c.direction=LEFT; @@ -157,6 +161,7 @@ int main(int argc, char **argv) { } switch(ev.key) { case 13: /*Enter*/ + free(c1.path); free(c2.path); tb_shutdown(); return 0; case 65517: /*up*/