runesmithie Posted April 12, 2006 Share Posted April 12, 2006 So the past week or two I've been making a simple snake-ish/tron-ish game on my TI89 in favor of continuing on in my Independent Study (teacher never really checks on me :oops: and it is programming related so, *shrug*) What I would like help in: * Optimizing the darn thing * Why does the "enemy" go in diagonals??? * Anyways to get the argument for a program to have a default value? Some notes: * You can't leave parentheses,etc off of the code in a TI89 or it gives an error (Another reason I'm doing this is to be able to see all the code at once instead of 8 lines at a time) runner(rpt) Prgm ClrDraw getmode("ALL")->modes rand(100)->zz RandSeed zz 1->m 0->z 36->x 78->y 30->xxo 30->yyo 30->xx 30->yy If rpt=0 Then ClrIO Disp "Runner" Disp "By (myname)" Disp "" Pause "Press ENTER to play" ClrIO EndIf If getType(snhs)="MAT" Then Else [["",0]["",0]["",0]["",0]["",0]["",0]["",0]["",0]["",0]["",0]["",0]]->snhs EndIf Dialog Request "Enter your name",snname DropDown "Enemies on",{"YES","NO"},eno EndDlog PxlVert 0 PxlVert 158 PxlHorz 0 PxlHorz 76 Loop PxlOn x,y getKey()->key If key=337 Then 1->m ElseIf key=338 Then 2->m ElseIf key=340 Then 3->m ElseIf key=344 Then 4->m ElseIf key=264 Then programs\death(0) EndIf If m=1 Then If pxlTest(x,y-1)=true Then programs\death(1) Stop Else y-1->y z+1->z EndIf ElseIf m=2 Then If pxlTest(x-1,y)=true Then programs\death(1) Stop Else x-1->x z+1->z EndIf ElseIf m=3 Then If pxlTest(x,y+1)=true Then programs\death(1) Stop Else y+1->y z+1->z EndIf ElseIf m=4 Then If pxlTest(x+1,y)=true Then programs\death(1) Stop Else x+1->x z+1->z EndIf EndIf If eno=1 Then PxlLine abs(xxo),abs(yyo),abs(xx),abs(yy),-1 rand(5)->en If en=1 Then xx->xxo xx+2->xx ElseIf en=2 Then xx->xxo xx-2->xx ElseIf en=3 Then yy->yyo yy+2->yy ElseIf en=4 Then yy->yyo yy-2->yy ElseIf en>=5 Then If x xx->xxo xx-2->xx Else xx->xxo xx+2->xx EndIf If y yy->yyo yy-2->yy Else yy->yyo yy+2->yy EndIf EndIf If xx>75 Then xx-3->xx ElseIf yy>157 Then yy-3->yy EndIf EndIf EndLoop EndPrgm death(exc) Prgm 1->r If exc=0 Then Dialog DropDown "Do you want to QUIT",{"YES","NO"},quit EndDlog If quit=1 Then Dialog DropDown "Do you want to SAVE your score",{"YES","NO"},score EndDlog While r<=15 PxlCrcl x,y,r,-1 r+1->r EndWhile Text "Your score is "&string(z) If score=1 Then If z>snhs[6,2] Then 1->u 4->n Unarchiv snhs While u<=6 If z>snhs[u,2] Then While n>=0 snhs[u+n,1]->snhs[u+n+1,1] snhs[u+n,2]->snhs[u+n+1,2] n-1->n EndWhile snname->snhs[u,1] z->snhs[u,2] 10->u EndIf u+1->u EndWhile Archive snhs EndIf EndIf ClrIO ClrDraw 1->u While u<=6 Disp left(snhs[u,1],8]&" "&string(snhs[u,2] EndWhile Pause DispHome setMode(modes) DelVar exc,z,r,quit,score,x,u,n,modes,y Stop EndIf ElseIf exc=1 Then DelVar rpt,zz,en,xxo,yyo,xx,yy,eno,key,m While r<=20 PxlCrcl x,y,r,-1 r+1->r EndWhile Text "Your score is "&string(z) Dialog DropDown "Do you want to SAVE your score",{"YES","NO"},score EndDlog If score=1 Then If z>snhs[6,2] Then 1->u 4->n Unarchiv snhs While u<=6 If z>snhs[u,2] Then While n>=0 snhs[u+n,1]->snhs[u+n+1,1] snhs[u+n,2]->snhs[u+n+1,2] n-1->n EndWhile snname->snhs[u,1] z->snhs[u,2] 10->u EndIf u+1->u EndWhile Archive snhs EndIf EndIf Dialog DropDown "Play again",{"YES","NO"},quit EndDlog If quit=1 Then ClrDraw programs\runner(1) ElseIf quit=2 Then ClrIO ClrDraw 1->u While u<=6 Disp left(snhs[u,1],8)&" "&string(snhs[u,2]) u+1->u EndWhile Pause DispHome DelVar exc,z,r,quit,score,x,u,n,modes,y Stop EndIf EndIf EndPrgm I just posted something! ^_^ to the terrorist...er... kirbybeam. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now