Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

TI Basic Game Optimization

Featured Replies

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

smithie3.jpg

I just posted something! ^_^ to the terrorist...er... kirbybeam.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.