I spent a few days working on this to dust off my TI-BASIC skills, and here is the result. If there are any problems with the code, PM me or make a post with the offending code!

This was written on a TI-84+ CE, so it may not work on other calculators.

This uses a list named lPONG.


Code:



:ClrHome
:Menu("OPTIONS","PLAY!",AA,"VIEW STATS",BB,"LEAVE",CC
:Lbl BB
:Output(1,1,"PLAYER 1:
:Output(2,1,LPONG(1)
:Output(2,5,"WINS
:Output(4,1,"PLAYER 2:
:Output(5,1,LPONG(2)
:Output(5,5,"WINS
:Output(7,1,"HIGH SCORE:
:Output(7,13,LPONG(3)
:Lbl CC
:Stop
:Lbl AA
:Menu("-----CHOOSE-----","1 PLAYER",BC,"2 PLAYER",BD
:Lbl BC
:0-->E
:Goto F
:Lbl BD
:1-->E
:Lbl F
:prgmGRAPH       //all this does is clear graph and take out X&Y axis, Just put a standard fnOff, axisOff, GridOff, BackgroundOff, ect
:0-->Xmin
:-62-->Ymin
:1-->ΔX
:1-->ΔY
:-23-->A
:-23-->B
:47-->C
:-30-->D
:-2-->M
:0-->N
:Line(91,B,91,B+9
:Lbl A
:While M=-2
:Pt-On(C,D,2
:Line(3,A,3,A+9
:getKey-->K
:A+4(K=72)-4(K=92-->A
:For(X,A-4,A-1
:Pt-Off(3,X
:End
:For(X,A+9,A+13
:Pt-Off(3,X
:End
:Pt-Off(C,D,2
:C+M-->C
:D+N-->D
:If D≥-2 or D≤-60
:-N-->N
:If C<2
:Goto P2
:If pxl-Test(-D,C-2
:2-->M
:End
:T+1-->T
:randInt(-3,3-->N
:While M=2
:Pt-On(C,D,2
:Line(91,B,91,B+9
:getKey-->K
:B+4(K=74)-4(K=94-->B
:For(X,B-4,B-1
:Pt-Off(91,X
:End
:For(X,B+10,B+13
:Pt-Off(91,X
:End
:Pt-Off(C,D,2
:C+M-->C
:D+N-->D
:If D≥-2 or D≤-60
:-N-->N
:If C>92
:Goto P1
:If pxl-Test(-D,C+2)
:-2-->M
:End
:randInt(-3,3-->N
:T+.01-->T
:Goto A
:Lbl P1
:If E=1
:Then
:Disp "PLAYER 1 WINS!
:LPONG(1)+1-->LPONG(1)
:End
:If E=0
:Then
:Disp iPart(T)+100fPart(T)
:If iPart(T)+100fPart(T)>LPONG(3)
:iPart(T)+100fPart(T)>LPONG(3)
:End
:Stop
:Lbl P2
:If E=1
:Then
:Disp "PLAYER 2 WINS!
:LPONG(2)+1-->LPONG(2)
:End
:If E=0
:Then
:iPart(T)+100fPart(T)-->H
:Disp H
:If H>LPONG(3)
:H-->LPONG(3)
:End
I see some room for optimization, but you will need to provide PrgmGRAPH in order for me to be able to help you fully (it's preferable to be able to run the program and test things out)
I haven't taken the time to play with the entire thing, but here is the last 200 or so bytes, which can easily be optimized down to about 100 (it could probably be optimized a little more, but this is what I came up with)

Code:
Lbl P1
If E=1
Then
Disp "PLAYER 1 WINS!
LPONG(1)+1->LPONG(1)
End
If E=0
Then
Disp iPart(T)+100fPart(T)
If iPart(T)+100fPart(T)>LPONG(3)
iPart(T)+100fPart(T)>LPONG(3)
End
Stop
Lbl P2
If E=1
Then
Disp "PLAYER 2 WINS!
LPONG(2)+1->LPONG(2)
End
If E=0
Then
iPart(T)+100fPart(T)->H
Disp H
If H>LPONG(3)
H->LPONG(3)
End

                  //could be

Lbl P1
DelVar HGoto P3
Lbl P2
1->H
Lbl P3
If E
Disp "PLAYER "+eval(H+1)+" WINS!
If not(E
Then
iPart(T)+100fPart(T
Disp Ans
If Ans>LPONG(3
Ans->LPONG(3
End
LPONG+{Enot(H),EH,0->LPONG

By taking a closer look at the code, I noticed that the variable T had something awkward about what it was doing. Every time the ball hits a paddle, it would add 1 or 0.01 depending on which paddle it hit. However, the only other time T shows up is in the iPart(T)+100fPart(T).This means that
1) Every 100 right paddle hits, it will add 1 to the score of the left, and overflow the right back to 0.
2) Since these scores are combined at the end, there is no use for this overcomplicating of T.
Therefore,

Code:
you can replace

T+.01-->T

With this

T+1-->T

And replace all occurences of

iPart(T)+100fPart(T)

with this

T

And if you choose to do so, you can obviously also replace the iPart(T)+100fPart(T) in the code I provided yesterday.
prgmGraph:


Code:

fnOff
AxisOff
GridOff
BackgroundOff
ClrDraw
ClrGraph
mr womp womp wrote:
I see some room for optimization, but you will need to provide PrgmGRAPH in order for me to be able to help you fully (it's preferable to be able to run the program and test things out)
I haven't taken the time to play with the entire thing, but here is the last 200 or so bytes, which can easily be optimized down to about 100 (it could probably be optimized a little more, but this is what I came up with)

Code:
Lbl P1
If E=1
Then
Disp "PLAYER 1 WINS!
LPONG(1)+1->LPONG(1)
End
If E=0
Then
Disp iPart(T)+100fPart(T)
If iPart(T)+100fPart(T)>LPONG(3)
iPart(T)+100fPart(T)>LPONG(3)
End
Stop
Lbl P2
If E=1
Then
Disp "PLAYER 2 WINS!
LPONG(2)+1->LPONG(2)
End
If E=0
Then
iPart(T)+100fPart(T)->H
Disp H
If H>LPONG(3)
H->LPONG(3)
End

                  //could be

Lbl P1
DelVar HGoto P3
Lbl P2
1->H
Lbl P3
If E
Disp "PLAYER "+eval(H+1)+" WINS!
If not(E
Then
iPart(T)+100fPart(T
Disp Ans
If Ans>LPONG(3
Ans->LPONG(3
End
LPONG+{Enot(H),EH,0->LPONG

Thanks! I Put prgmGraph up and will test your optimizations when I have time, and if they work, and if you are ok w/ it, I will revise the post and code!

Thanks (Again)!
I made a Pong game for the CE in BASIC some while back, just for fun. I didnt really work on optimizing the code when I made it, but here it is:

Code:
:Lbl 2
:ClrHome:5->A:5->B:0->C:0->D
:Output(1,3,"--PONG by Cal[e]b Hill--
:Lbl 1
:Output(V,W,"
:randInt(3,9->V:randInt(8,12->W:
:1->M:1->N
:Output(1,1,C
:Output(1,26,D
:If C>D:"bolduparrowbolddownarrow->Str1
:If C"bolddownarrowbolduparrow->Str1
:If C=D:"--->Str1
:Output(1,2,sub(Str1,1,1
:Output(1,25,sub(Str1,2,1
:DelVar EDelVar K
:Repeat K=45 or C=5 or D=5
:   getKey->K
:   If K=21 and A>2:Then:Output(A+1,1,"
:   A-1->A
:   End
:   If K=31 and A<9:Then:Output(A,1,"
:   A+1->A
:   End
:   If K=25 and B>2:Then:Output(B+1,26,"
:   B-1->B
:   End
:   If K=34 and B<9:Then:Output(B,26,"
:   B+1->B
:   End
:   Output(A,1,"|
:   Output(A+1,1,"|
:   Output(B,26,"|
:   Output(B+1,26,"|
:   If not((W=2 and (A=V or A+1=V)) or (W=25 and (B=V or B+1=V))) and (W=2 or W=25)
:   Then
:   If W=25:C+1->C
:   If W=2:D+1->D
:   2->E
:   End
:   If E=2:Goto 1
:   If W=25 or W=2:N*~1->N
:   If V=2 or V=10:M*~1->M
:   Output(V,W,"
:   V+M->V
:   W+N->W
:   Output(V,W,"theta
:End
:If C=5:Output(5,5,"L Play[e]r Won!
:If D=5:Output(5,5,"R Play[e]r Won!
:Output(6,5,"To Play Again, hit 1"
:Repeat K
:   getKey->K
:End
:If K=92:Goto 2
:ClrHome


It uses the Home Screen/Calculator Screen, not the graph screen.
CHill wrote:
I made a Pong game for the CE in BASIC some while back, just for fun. I didnt really work on optimizing the code when I made it, but here it is:

Code:
:Lbl 2
:ClrHome:5->A:5->B:0->C:0->D
:Output(1,3,"--PONG by Cal[e]b Hill--
:Lbl 1
:Output(V,W,"
:randInt(3,9->V:randInt(8,12->W:
:1->M:1->N
:Output(1,1,C
:Output(1,26,D
:If C>D:"bolduparrowbolddownarrow->Str1
:If C"bolddownarrowbolduparrow->Str1
:If C=D:"--->Str1
:Output(1,2,sub(Str1,1,1
:Output(1,25,sub(Str1,2,1
:DelVar EDelVar K
:Repeat K=45 or C=5 or D=5
:   getKey->K
:   If K=21 and A>2:Then:Output(A+1,1,"
:   A-1->A
:   End
:   If K=31 and A<9:Then:Output(A,1,"
:   A+1->A
:   End
:   If K=25 and B>2:Then:Output(B+1,26,"
:   B-1->B
:   End
:   If K=34 and B<9:Then:Output(B,26,"
:   B+1->B
:   End
:   Output(A,1,"|
:   Output(A+1,1,"|
:   Output(B,26,"|
:   Output(B+1,26,"|
:   If not((W=2 and (A=V or A+1=V)) or (W=25 and (B=V or B+1=V))) and (W=2 or W=25)
:   Then
:   If W=25:C+1->C
:   If W=2:D+1->D
:   2->E
:   End
:   If E=2:Goto 1
:   If W=25 or W=2:N*~1->N
:   If V=2 or V=10:M*~1->M
:   Output(V,W,"
:   V+M->V
:   W+N->W
:   Output(V,W,"theta
:End
:If C=5:Output(5,5,"L Play[e]r Won!
:If D=5:Output(5,5,"R Play[e]r Won!
:Output(6,5,"To Play Again, hit 1"
:Repeat K
:   getKey->K
:End
:If K=92:Goto 2
:ClrHome


It uses the Home Screen/Calculator Screen, not the graph screen.


Cool! I decided to use the graph screen because I felt it would present more of a challenge, but this is better looking...
I tried this with the optimizations and it doesn’t work. I will reread my code to make sure I typed it in right.
FrankzeeTank wrote:
I tried this with the optimizations and it doesn’t work. I will reread my code to make sure I typed it in right.


Hey Franzee Tank,

You do realize that you could have just copied and pasted the code into TI Connect CE?
That is a free software offered by Texas Instruments that allows you to import programs from sites like Cemetech and Ticalc, and paste them into your calculator. You could have done the same when typing in the program manually.
Please help! I can't move my paddles. i double checked the code and it is all correct! Does anyone no a fix?
johnnyUp78733 wrote:
Please help! I can't move my paddles. i double checked the code and it is all correct! Does anyone no a fix?

Wowiie this isn't a recent thread Laughing
The controls should be 2nd and ALPHA for the left paddle and the up/down arrows for the right paddle. Are you using a TI-84 plus CE? And did you actually manually punch in all the code into your calc?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement