GAMES, HELP


Hello, this page is to help you learn how to make your own games.  Go to www.ticalc.org for link to more tutorials


============ TI-83 Basic Tutorial===

Lesson1: In the beggining

Ok, you want to know how to make a game. First I'm gonna show you the extreme basic stuff. So if your a newbie, listen up. Follow these simple steps....

1) Get out your calculator and turn it on.

2) To start creating a program, press PRGM, then right arrow twice, then enter.
It will say Name=. It is asking you to name your game so type in the name of your program. For now, just type in "HELLO" because that will be your first program, then press enter.

3)On the screen now at the top it will say the program's name and below it is a colon. This is where you begin writing you program. To write a program, you use a bunch of commands. I will tell you what they all are later. You can not type the commands in by hand. They are located in different menu's. For example, press PRGM. Instead of a list of programs, it has a list of commands. There may be more than one list of commands under each menu; use the left and right keys to move back and forth. If you press enter it puts that command into your program. To cancel, press CLEAR. To leave the program editor, press 2nd QUIT.

4) Good job, you have made your first program, but it doesnt do anything :o(


Lesson 2: Hello
Ok, now you will make your program say "Hello, this is cool."

1) Open up your HELLO program. To do that, press PRGM, then right, then select your program and press enter.

2)Now you see what makes up your program... nothing so far.

3)Press PRGM, you now see a bunch of commands. Press right, then scroll down till you reach ClrHome. Press enter to select it.

4)Now ClrHome should be in your program. This command will clear the screen. Go ahead, try it out if you dont believe me. :o)

5)Now press PRGM again and select Disp.

6)Now put "HELLO","THIS IS COOL
Disp. stands for Display, it puts letters/numbers on the screen. Remember you can only have 16 letters on one line. So you when you display somthing, you have to split it up. So if you wanted to say "Daniel is the coolest person alive", you would have to do:
Disp "DANIEL IS THE","COOLEST PERSON","ALIVE"

7)Your program should now look like this:
:ClrHome
:Disp "HELLO","THIS IS COOL

8)Now press 2nd QUIT to exit. Then run your program. Tada!




Lesson 3: Variables
Variables are letters that you can store numbers into and change around. For example, you can store 2 into A, so A would equal 2.

1) Create a new program
2) Type 2, then press the STO button, then put the letter A. This makes A equal 2.
3) Now on the next line put the command: Disp A
Your screen should look like this:
:2->A
:Disp A
4) Run the program, it should display a 2 on the screen. You can store any number into any letter (I consider theta a letter too, theta is the one after Z, the O with a line in it).

You can also do other stuff,
--You can store A into B, which would make B equal whatever A is.
--You can store A-3 into B, store A x 2 into B, store A divided by B into B, or pretty much anything else.
--If you did somthing like this:
:2->A
:5->B
:A+B->C
Then C would equal 7, (2+5)



Lesson4: Commands
Ok, now that you know how to start a new program, I'm gonna show you what most of the commands do...

===IF, THEN, INPUT, GOTO, DISP, STOP

Here is an example:
:ClrHome
:Lbl A
:Disp "PICK A NUMBER","1 OR 2"
:Input X
:If X=1
:Goto B
:If X=2
:Goto C
:If X<1 or X>2
:Goto A
:Lbl B
:Disp "YOU PICKED ONE"
:Stop
:Lbl C
:Disp "YOU PICKED TWO
:Stop

Ok, this probably isnt that hard to understand, but I'm gonna explain it anyway. This program asks the user to input a number, 1 or 2. If you type in 1 then it says "YOU PICKED ONE", if you typed in 2 it says "YOU PICKED TWO". If you typed in neither 1 or 2, then it loops back to the begging.
You could use this method to make a choose-your-own-adventure game.


===MENU
Another way you can branch off is Menu. Here is an example:
:Menu("TITLE HERE","FIRST CHOICE",A,"SECOND CHOICE",B,"THIRD CHOICE",C

This would make a menu that whould give you 3 choices, the first would take you to Lbl A, the second to Lbl B, and the third Lbl C.

===OUTPUT
Output is used to display stuff at a certain location on the homescreen. Its used like this:
:Output(2,5,"HELLO
This would display HELLO at 2 spaces down, and 5 spaces across.

===PAUSE
This command makes the program wait for the user to press Enter. Its used like this:
:Disp "WAITING"
:Pause
:Disp "IM DONE"
This displays WAITING, then when you press enter is says IM DONE.

Lesson 5: Drawing stuff

While editiing a program goto 2nd Draw.  This brings up a bunch of commands to let you put stuff on the Graphscreen (There are two screens, the Homescreen and the Graphscreen)

===CLRDRAW

This is the same thing as ClrHome but for the Graphscreen.

===LINE

As you may have guessed, it draws a line. You put in four variables: X1, Y1, X2, Y2 in that order.  So if you wanted a line going from 3,4 to 8,7 (X and Y coordinates), you would use Line(3,4,8,7). To erase the line put a zero after those four to erase the line. For examle. If you wanted to erase that line (3,4,8,7) then you would type Line(3,4,8,7,0).

===HORIZONTAL and VERTICAL

Horizontal Makes a horizontal line at the place on the Y axis which you specify. For example, if you want a horizontal line through 0,0, you would put "Horizontal 0".  Vertical is the same as Horizontal only it creates a vertical line.

===CIRCLE

Draws a circle. It uses 3 variables. The first 2 are x and y coordinates of the center; the last is the radius. So if you wanted a circle centered at 0,0 and a radius of 5, you would write Circle(0,0,5)

===TEXT

This command is like Output but on the graphscreen. The only difference is that you use pixels instead of rows and columns. The pixels are NOT affected in any way by the Window range. So if I wanted to write "HELLO" 5 pixels from the left side of the screen and 34 pixels down, I would write Text(5,34,"Hello".

===PtON, PtOFF, and PtCHANGE

Draws a point at the x- and y-coordinates specified. If you wanted a point at 4,6 then write Pt-On(4,6). You can also make different shaped points by adding 2 or 3 to the end of it (i.e. Pt-On(4,6,2). Pt-Off does the same thing only it turns the point off.  Pt-Change( changes the status of that point. So if it was on it would change it to off and vice-versa. Note: These commands are listed under POINTS on the [Draw] menu. These can help draw pictures.

===PxlON, PxlOFF, and PxlTEST

These are almost the same as the above ones. They turn on and off pixels. The major difference is that the spacing is like Text(, where it uses pixels from the side of the screen, and is not affected by Window Range. Another difference is that you cannot use different shapes; it must be a pixel. The pxl-Test tests to see if the pixel is on or off. It returns 0 if it is off and 1 if it is on.
So if you wanted to test to see if a pixel was on or off or not, you would do:

PxlTest (5,5) -> A

If A = 1

Disp "IT IS ON"

Lesson 6:  Making stuff Move!!!

This is the best lesson of all!  This is what really makes a game a game, making stuff move.  The calculator uses Getkey to get a key pressed and then do somthing about it.  Here is how you can move an X around the Homescreen:

4 -> A

5 -> B

Lbl A

Output( B,A,"X"

Getkey -> K

If K = 21

Goto X

If K = 24

Goto L

If K=25

Goto U

If K=26

Goto R

If K=34

Goto D

Goto A

Lbl X

Stop

Lbl L

Output(B,A," "

A-1 -> A

Goto A

Lbl R

Output(B,A," "

A+1 -> A

Goto A

Lbl U

Output(B,A," "

B-1 -> B

Goto A

Lbl D

Output(B,A," "

B+1 -> B

Goto A

There ya go, that should move an X around the screen.  I started out by stating the starting position of the X.  Then the loop (Lbl A, GotoA) holds the rest of the program.  Getkey reads what button is pressed and stores its number into K (Every button has a number, look in your TI manual for the chart of the numbers).  Then if it is button 21 (2nd) then it goes to Label X where it ends the game.  If Button 24 (Left) is pressed then it goes to Label L where it clears the X (so there is no trail) and then it subtracts A (The x-coordinate) by 1 so when X is drawn again, it is now left one space.  If no buttons are pressed then it goes back to Label A.

Lesson 7:  Fixing whats wrong

No one who programs can get everything right the first time. There are going to be bugs, or problems, with the program. The TI-83 (an all TI-Calculators) will tell you what the problem is. When you run a program, it may stop the program and give you an error message. It will then give you the options of (1) Quitting and (2) Going to the problem and fixing it (you have to fix it yourself, though). If you select GOTO, it will take you exactly where the program is. Here are some of the most common errors and what they mean.

ERR:SYNTAX This is probably the most common bug. It means you mistyped something or did something that doesn't make sense. For example, maybe you forgot to press enter between lines and typed: If A=B Goto C then it would give you a syntax error. Or maybe you typed something twice, like If A>>B. These are examples of Syntax errors.

ERR:DOMAIN This error probably means you tryed to output something off the screen. The TI-83 has 8 rows and 16 columns, so if you typed: Output(9,20,"O" it would give you this message. However when using output, youy can type something longer than will fit and it will wrap to the next line. You just can't start something off the screen.

ERR:ARGUMENT occurs when something is missing. If you just typed in "If", then it would expect something to follow it, and if there is nothing, it would give an ARGUMENT error. It would also occur if you didn't put the column in an OUTPUT command, like "Output(6,"O".

ERR:MEM. This is the Error no one wants. Your calculator is out of memory and couldn't finish the program. You'll have to erase some things to free up memory.

ERR:OVERFLOW. You may have seen this one on the homescreen. It means that you tried to create a number that is too big for the calculator.

Lesson 8:  Example program

Here is the source code to a basic dont-hit-the-walls game.  Every single line is explained, so you should be able to understand how it works...

Since there are some symbols on the calculator that your computer cant show, I made a key that explains what all those wierd letters are suppost to be:

ü=STO ->

Á=THETA (the O with a line through it)

ö=little T (under MATRX)

ù=greater than or equal to

÷=less than or equal to

ø=not equal to

ú=negative sign

á=mini "L" (under LIST)

Code to game DRIVE, with explinations
1üdim(áDHS Creates the List DHS to store the highscores
Full Makes sure its in full screen mode
ClrHome Clears the screen
Disp "RACE","+-+","! !","! !","! !","+-+" Draws the stoplight
For(Á,1,100

End

Counts to 100 then contiunes to the next line
Output(3,2,"*! READY" Displays the Red light at 3,2
For(Á,1,100

End

Counts to 100
Output(4,2,"*! SET" Displays the Yellow light at 4,2
For(Á,1,100

End

Counts to 100
Output(5,2,"ô! GO" Displays the green light at 5,2
5üC

5üB

5üA

0üL

0üN

5üR

8üV

8üK

7üO

1üP

Stores the starting numbers for each variable

C is the test to see if you have touched the border

Im not sure about A and B

L is your score

N is the timer

R is the position of the left side of the tunnel

V is the position of you

K is your previous position

O is the # of spaces between the walls of the tunnel

P is how much the tunnel shrinks

While 1 Start of the game loop
R+randInt(ú1,1)üR Gets a random number, 1 or -1 and adds it to R making the tunnel move
If R=2

3üR

If the left side of the tunnel is at 2, then make it 3
If R=9

8üR

If the left side of the tunnel is at 9, then make it 8
Disp "" Displays nothing, but makes the screen move up
Output(8,R,"]" Draw the left side of the tunnel at 8,R
Output(8,R+O,"[" Draw the right sid of the tunnel at 8,R+O
getKeyüY Getkey, to get what button you press
If Y=24 If you pressed button 24, then move left
V-1üV 1 is subtracted from V, making your x-coordinate left 1
If Y=26 If you pressed button 26, then move right
V+1üV 1 is added to V, making your x-coordinate right 1
If Y=21

Pause

If you pressed button 21, 2nd, then Pause the game
Output(4,K," " Clear your old position at 4,K so you dont leave a trail
Output(5,V,"v" Draw your guy at the new position at 5,V
VüK Store your new position into the old position
If V÷C or VùC+O

Goto C

If V is on the borders of the tunnel, then goto C
CüD

BüC

AüB

RüA

Stores the tunnel positon R, into C

Not sure why he uses A,B, and D. I guess to slow it down

N+1üN Increse the timer by 1
If Nù40 If the timer reaches 40, then shrink the tunnel
Then

O-PüO

0üN

L+4üL

End

Subtract O by 1

Reset the timer to 0

Make your score go up 4

If O÷2

0üP

If O is 2, then dont make the tunnel shrink anymore
End The bottom of the main game loop, it then goes back to the top
Lbl C

0üX

Game over sequence
While X÷2

Output(5-X,V-X,"*"

Output(5+X,V+X,"*"

Output(5-X,V+X,"*"

Output(5+X,V-X,"*"

Output(5-X,V,"*"

Output(5+X,V,"*"

Output(5,V-X,"*"

Output(5,V+X,"*"

X+1üX

End

Loop while X is less or equal to 2

Draw the explosion

Increse X by 1

0üX Reset X to 0
While X÷2

Output(5-X,V-X," "

Output(5+X,V+X," "

Output(5-X,V+X," "

Output(5+X,V-X," "

Output(5-X,V," "

Output(5+X,V," "

Output(5,V-X," "

Output(5,V+X," "

X+1üX

End

Loop again until X is not less or equal to 2

Clear the explosion

Output(1,1,"SCORE: "

Output(2,1,"HIGH: "

Display score and high
L*130+NüS Add up for your final score: score*130+timer
If S>áDHS(1) If final score is greater than the high score
Then

{S}üDHS

Output(3,1,"NEW HIGH SCORE!"

End

Store your total score into List DHS

Display you have a new high score

Output(1,7,S Display your final score
Output(2,6,áDHS Display the highscore