TI-BASIC Wiki
Register
Advertisement

By: Michael Delfino

This is a work in progress...

Description[]

PIEATER is a game I made in middle school. You play the role of P, the Pi-eater. Your goal in life is to eat as much π as you can. It seems simple enough until your archnemeses the X's show up to thwart your plans. They don't want to eat the π, they want to eat YOU!

Controls[]

Move with the arrows

Display[]

The game is displayed on the home screen. You control a 'P' moving around trying to eat a stationary 'π'. Every time you eat one another appears in a random location. You are being chased by 2 X's. Your score is displayed at the bottom of the screen. Initially there is an intro page then a menu where you can select to read the instructions, play the game or quit.

The Code[]

 PROGRAM:PIEATER
 :ClrHome
 :Output(4,1,"P I -  E A T E R
 :Pause
 :0→S
 :7→A
 :16→B
 :1→C
 :1→D
 :4→E
 :8→F
 :randInt(2,6→G
 :randInt(2,15→H
 :0→X
 :ClrHome
 :Menu("P I -  E A T E R","PLAY",1,"INSTRUCTIONS",2,"QUIT",Z
 :Lbl 2
 :ClrHome
 :Disp "You are the P.","","Move with the","arrow keys."
 :Pause
 :ClrHome
 :Disp "Avoid each X.","","Collect every π."
 :Pause
 :ClrHome
 :Lbl 1
 :While (A≠C or B≠D) and (A≠E or B≠F)
 :X+1→X
 :X(X≠6)→X
 :If A=G and B=H
 :Then
 :S+1→S
 :randInt(2,6→G
 :randInt(2,15→H
 :End
 :Output(8,1,"Score: "
 :Output(8,8,S
 :Output(G,H,"π
 :Output(A,B,"P
 :Output(E,F,"X
 :Output(C,D,"X
 :getKey→Z
 :If Z=24 or Z=25 or Z=26 or Z=34
 :Output(A,B," "
 :A+(Z=34)(A≠7)-(Z=25)(A≠1)→A
 :B+(Z=26)(B≠16)-(Z=24)(B≠1)→B
 :0→Z
 :Output(E,F," "
 :E+randInt(-1,1)→E
 :F+randInt(-1,1)→F
 :E+(E=1)-(E=7)→E
 :F+(F=1)-(F=16)→F
 :Output(E,F,"X
 :If X=0 or X=3
 :Output(C,D," "
 :C+(A>C)(X=0)-(A<C)(X=0)→C
 :D+(B>D)(X=3)-(B<D)(X=3)→D
 :If S=50
 :Then
 :ClrHome
 :Disp "YOU ARE THE π","EATING CHAMPION!
 :7→A
 :16→B
 :1→C
 :1→D
 :4→E
 :8→F
 :Pause
 :ClrHome
 :Menu("WHAT WILL U DO? ","KEEP EATING π",1,"RETIRE",Z
 :End
 :End
 :ClrHome
 :Disp "You died.","","Final Score:",S
 :Pause
 :Lbl Z
 :ClrHome
 :Disp "PROGRAMMED BY:","MICHAEL DELFINO",""
 :Output(8,1," "

Explanation of Code[]

Coming Soon: Line-by-line analysis of code

Initially I set up variables to be used in the program (After intro screen). Then I called a menu with options to view instructions, play the game or quit. Label 2 is the instructions section, it's simply 2 Disp commands follewed by Pause to wait for the user to press enter then ClrHome to erase the text. Then following Label 1 the game's main loop is started ( A While loop with conditions that neither one of the X's has the same position as the player). The main loop has several chunks of code that are basically Render Objects->Get Input->Process Input->Update Objects. There are "winning" conditions (Score gets to 50) but the user can keep playing even after they achieved the target score. The end of the game displays the score after you die then displays the "credits" and the program is exited.

Advertisement