Calculator Community > The Axe Parser Project |
Snake: What’s wrong? |
(1/1) |
Pixilized:
I’m making Snake in Axe as practice, but my code isn’t working and I can’t figure out what’s wrong. The Snake is supposed to be longer, but I can only make it be one segment. What did I do wrong? Here’s my code. Thanks in advance! --- Quote from: SourceCoder 3 (thetaSNAKE) ---:.SNAKE :DiagnosticOff :ClrHome : :.sprites :[E0A0E00000000000]->Pic0BODY :[1F1F1FFFFFFFFFFF]->Pic0FILL : :.v\ariable RAM :|E9872->->^^oVR : :.create v\ars :^^oVR->->^^oHeadX+2->->^^oHeadY+2->->^^oDir+2->->^^oTail+2->->^^oLength : :.set v\ars :0->HeadX->HeadY :1->Tail+6->Length :3->Dir : :.set list :Data(0,0,0,0,0,0)->GDB1SEGX :Data(0,0,0,0,0,0)->GDB1SEGY : :.game loop :Repeat getKey(15) : : .erase tail : Pt-And({Tail-1+GDB1SEGX},{Tail-1+GDB1SEGY},Pic0FILL) : : .draw head : Pt-On(HeadX,HeadY,Pic0BODY) : : .update list : HeadX->{Tail-1+GDB1SEGX} : HeadY->{Tail-1+GDB1SEGY} : : .get input : getKey->Ans : If Ans?Ans<=4 : : Ans->Dir : : End : : .move : (Dir=3)-(Dir=2)+HeadX->HeadX : (Dir=1)-(Dir=4)+HeadY->HeadY : : .update tail : Tail+1-(Length*(Tail=Length))->Tail : : .draw screen : DispGraphClrDraw : :End --- End quote --- Side note: what is the bbcode for a code box? I clicked the bbcode button on SourceCoder, but that makes it a quote with a bunch of styling. How do I make the code box that you can click "copy" on? Never mind, I found out what was wrong with snake. I forgot DispGraphClrDraw cleared the current buffer. Edit (Eeems): Merged triple post |
E37:
Ans in Axe is TI-Basic's Ans. That means that changing it lets you communicate with TI-Basic but it is also as slow as using Basic. Speed isn't a problem for your code but you should avoid it in the future. I usually use the letter variables for scratch space. |
Navigation |
Message Index |