|
|
|
|
![]() ![]() |
Apr 3 2008, 09:44 PM
Post
#1
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
Description
Ok, so this is my first TI-BASIC tutorial. In this tutorial you will learn how to create a very simple slot machine, so you can entertain yourself in math class Try it out Ok, first create a new program called 'SLOT MACHINE'. Hit the enter key. Now input the following code. CODE :ClrHome :Lbl 1 :Output(1,1,"--Slot Machine--") :Output(2,1,randInt(0,9,1)) :Output(2,4,randInt(0,9,1)) :Output(2,7,randInt(0,9,1)) :Goto 1 **EDIT** (Sorry, I didn't have enough time to finish this yesterday) Ok, now exit the program editing screen, and run the program. You have created your first TI-Basic slot machine! You may be wondering how to stop the slots. Simply hit the 'On' button while the program is running. It will force the program to error. It will ask you to quit, do it. After you quit, you will see whatever numbers you stopped the slot machine on. To run it again, simply hit enter. This post has been edited by KansukeKojima: Apr 4 2008, 02:48 PM |
|
|
|
Apr 4 2008, 08:31 PM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 281 Joined: 5-October 07 From: Random Places Member No.: 51,171 ![]() |
Very nice Kansuke, I advise though using a better form of stopping it. Also, labels suck in Ti-BASIC. They can cause the calculator to output an error message.
Here is a little better version of the code. CODE :ClrHome :A=0 :While(A=0) :getKey -> K :Output(1,1,"--Slot Machine--") :Output(2,1,randInt(0,9,1)) :Output(2,4,randInt(0,9,1)) :Output(2,7,randInt(0,9,1)) :If K=105:Stop :End EDIT: Fixed Output statements This post has been edited by coolcat50: Apr 4 2008, 10:41 PM |
|
|
|
Apr 4 2008, 09:37 PM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
Thanks man! I wasn't quite sure how to use the Enter Key to get it to stop... I kind of just figured out how to do this by messing around with stuff and learning how to use the output command XD
|
|
|
|
Apr 4 2008, 10:36 PM
Post
#4
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 281 Joined: 5-October 07 From: Random Places Member No.: 51,171 ![]() |
No problem! You use getKey to retrieve a key value and you compare the key value from getKey with a key value of a certain button using an if statement. I've made a few neat games using getKey and the Graph.
|
|
|
|
Apr 25 2008, 06:29 PM
Post
#5
|
|
|
Newbie ![]() Group: Members Posts: 6 Joined: 24-April 08 From: England Member No.: 61,279 |
Nice Ti-basic --- Slot Machine tutorial Kansuke
|
|
|
|
May 15 2008, 09:21 PM
Post
#6
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
Hello again everyone. In my recent math classes, I've been able to improve my slot machine.
It now includes: 1. A coin counter So if you want this on your TI calculator, then copy this code: CODE :ClrHome :If Z=-1:10->Z :0->A :0->K :Output(6,1,"COINS:") :Output(7,1,Z) :Output(1,1,"--SLOT MACHINE--") :Output(5,1,"----------------") :While (A=0) :getKey->K :Output(3,4,randInt(0,9,1)) :Output(3,7,randInt(0,9,1)) :Output(3,10,randInt(0,9,1)) :If K=105:Z-1->Z :If Z=-1:Output(6,1,"PLAY AGAIN?" :If K=105:Stop :End All this modification does: you start the game with ten coins, every time you play, you lose a coin. Once the coins reach zero, you are asked to play again. If you hit enter, you'll get ten new coins to play with. Also, if anyone knows how to do this, could you please modify this so that you will win coins when you get three numbers in a row? |
|
|
|
May 22 2008, 02:39 AM
Post
#7
|
|
|
Trap Double Mocha Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,360 Joined: 21-September 07 Member No.: 50,369 |
Replying to KansukeKojima
I MAY BE ABLE TO HELP, BUT YOU HAVE TO TELL ME WHAT EACH VARIABLE MEANS -reply by RANDOM |
|
|
|
Jun 13 2008, 11:30 PM
Post
#8
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
Hello Again everyone! I have finally perfected the slot machine! It now gives you more coins when:
1. You get three of the same number in a row (example: 1,1,1) 2. You get a series of numbers in a row. (example: 1,2,3) 3. You get two of the same numbers. (example: 1,1,2) 4. You get two numbers that add up to the other (example: 5,2,7 (5+2=7)) Anyways, just type this into the program mode on your calculator and you should be able to play. CODE :ClrHome :If D=E and E=F:Z+10->Z :If D=E or E=F or D=F:Z+2->Z :If F=E+1 and E=D+1:Z+2->Z :If F=D+E or E=D+F or D=E+F:Z+2->Z :If Z=-1:10->Z :0->A :0->K :Output(6,1,"COINS:") :Output(7,1,Z) :Output(1,1,"--SLOT MACHINE--") :Output(5,1,"----------------") :While (A=0) :getKey->K :randInt(0,9)->D :randInt(0,9)->E :randInt(0,9)->F :Output(3,7,D) :Output(3,10,E) :Output(3,10,F) :If K=105:Z-1->Z :If Z=-1:Output(6,1,"PLAY AGAIN?") :If K=105:Stop :End That should work, if it does not, then please post in response saying so, and I will try to fix it. If your coin count ever gets to high just type in 10->Z to reset how much your coins are worth. Enjoy. |
|
|
|
Jun 14 2008, 12:38 AM
Post
#9
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: [HOSTED] Posts: 49 Joined: 1-June 08 Member No.: 62,997 |
Very good, i have never used that Basic. I started learning with your tutorial and probably i will continue in my own.
Thanks and regards |