im doing a horse racing game where u make a bet and u click on 1-5 for a horse..it then goes to a racing stage how do i make it that if that horse wins the money goes up
Offline
Hi lil_mellybelly,
http://scratch.mit.edu/projects/LeBurt/38267
I made an example in the above project. Have a look and post your questions here if it's not clear to you. The sprites don't move, you'll have to drag them across the finish line. Look at the script in the FinishLine sprite.
The important concept here is in variable Race On? This kind of variable is called a flag and is used to tell a program whther to do an action or not. That's why a flag will always be 0 or 1 (or, in other programming languages, TRUE or FALSE). In this case, when the race starts by pressing the green flag, the Race On? flag is set to 1, meaning the race has started. When a sprite touches the line, any sprite, the flag is set to 0. Notice that the repeat loop check the value of the flag and if it has been set to 0, it ends. This prevents the following horses from winning.
Hope this helps!
LeBurt.
Offline
Um, you need two variables: 'Horse', and 'Winning horse'. 'Horse' is chosen when a player presses 1,2,3,4 or 5. Then, 'Winning horse' is chosen randomly. Give each horse a number, and make each horse have a script that says 'When variable 'winning horse' equals (Horses number) Repeat (However many steps you want) change X by 1. If 'winning horse' is not equal to horses number, repeat (however many times you want) change X by 1 wait 0.25 seconds. Then, make the finish line so if the horse that wins touches it, increse money by 10.
Offline