Bonjour! Je viens de programmer un snake, pas encore super mais ca s'améliore, mais je fais face à un bug que je ne comprends pas : le serpent mange, mange, et, des que son corps fait 7 px de long ou plus, rien ne va plus : il laisse une affreuse trainée derrière lui... je ne sais pas du tout où est l'erreur donc je vous donne tout le code :
Code
:ClrDraw
:AxesOff
:1->Xmin:94->Cmax
:1->Ymin:62->Ymax
:Fill(40,L1)
:5->Q:1->M:0->S
:Line(30,62,94,62)
:Line(30,61,94,61)
:Line(30,1,94,1)
:Line(30,2,94,2)
:Line(30,1,30,62)
:Line(31,1,31,62)
:Line(94,1,94,62)
:Line(93,1,93,62)
:Text(3,5,"SCORE")
:Text(10,5,"-----")
:Text(15,13,S)
:Goto E
:Lbl A
:Pxl-On(L1(1),L1(2))
:Pxl-Off(L1(1+2Q),L1(2+2Q))
:getKey
:If Ans=26:1->M
:If Ans=24:2->M
:If Ans=25:3->M
:If Ans=34:4->M
:If M=1:Then
:If Y=L1(1) and X=L1(2)+1:Goto G
:If pxl-Test(L1(1),L1(2)+1)=0
:Then:L1(2)+1->L1(2)
:Else
:Goto P
:End:End
If M=2:Then
:If Y=L1(1) and X=L1(2)-1:Goto G
:If pxl-Test(L1(1),L1(2)-1)=0:Then
:L1(2)-1->L1(2)
:Else:Goto P
:End:End
If M=3:Then
:If L1(1)-1=Y and L1(2)=X:Goto G
:If pxl-Test(L1(1)-1,L1(2))=0:Then
:L1(1)-1->L1(1)
:Else:Goto P
:End:End
:If M=4:Then
:If L1(1)+1=Y and X=L1(2):Goto G
:If pxl-Test(L1(1)+1,L1(2))=0:Then
L1(1)+1->L1(1)
:Else:Goto P
:End:End
:L1(13)->L1(15)
1L1(12)->L1(14)
:L1(11)->L1(13)
:L1(10)->L1(12)
:L1(9)->L1(11)
:L1(8)->L1(10)
:L1(7)->L1(9)
:L1(6)->L1(8)
:L1(5)->L1(7)
:L1(4)->L1(6)
:L1(3)->L1(5)
:L1(2)->L1(4)
:L1(1)->L1(3)
:Goto A
:Lbl P
:ClrHome
:Output(5,4,"YOU LOOSE")
:Pause:Stop
:Lbl E
:int (rand*60+3)->Y
:int (rand*59+33)->X
:Pxl-Off(Y,X)
:Goto A
:Lbl G
:Pxl-Off(Y,X)
:S+1->S:Q+1->Q
:Text(15,13,S)
:Goto E