Computer Science Canada LED Game |
Author: | initialfresh [ Tue Jun 17, 2008 10:44 pm ] |
Post subject: | LED Game |
This is my code for a LED Game that i am supposed to make for my final project. The program will ask user to first enter which LED they will try to stop the cycle on (LED 1, 2, 3, or 4 from left to right). If user input is not valid, then program should exit. If the user is successful in stopping the program on the correct LED, the program should say ?YOU DID IT!?. If they are off by one LED the program should say ?YOU JUST MISSED!?. If they are off by 2 or more LED?s the program should say ?YOU?RE WAY OFF!?. After displaying the result, the program will return to the point where the user has the opportunity to select which LED to stop on. The program must still wait for user to push button before the cycle restarts and cycle will still restart from the beginning. I am not that good at turing and hopefully someone can help me complete this project! Quote: var onezero : int var target : int View.Set ("graphics:470;300,position:center;center,nobuttonbar") put " LED GAME! " put " Please enter LED that you will attempt to hit!" put " ( anything else to quit ) " .. get target cls loop Draw.Oval (70, 100, 50, 50, brown) Draw.Oval (180, 100, 50, 50, brown) Draw.Oval (290, 100, 50, 50, brown) Draw.Oval (400, 100, 50, 50, brown) put " You are trying to stop on LED ", target put " Press Button to Start! " loop onezero := parallelget exit when onezero = 56 end loop delay (500) loop Draw.FillOval (70, 100, 50, 50, brightred) parallelput (8) delay (100) Draw.FillOval (70, 100, 50, 50, white) Draw.Oval (70, 100, 50, 50, brown) onezero := parallelget exit when onezero = 56 %------------------------------------------- Draw.FillOval (180, 100, 50, 50, brightred) parallelput (4) delay (100) Draw.FillOval (180, 100, 50, 50, white) Draw.Oval (180, 100, 50, 50, brown) onezero := parallelget exit when onezero = 56 %------------------------------------------- Draw.FillOval (290, 100, 50, 50, brightred) parallelput (2) delay (100) Draw.FillOval (290, 100, 50, 50, white) Draw.Oval (290, 100, 50, 50, brown) onezero := parallelget exit when onezero = 56 %------------------------------------------- Draw.FillOval (400, 100, 50, 50, brightred) parallelput (1) delay (100) Draw.FillOval (400, 100, 50, 50, white) Draw.Oval (400, 100, 50, 50, brown) onezero := parallelget exit when onezero = 56 %------------------------------------------- Draw.FillOval (400, 100, 50, 50, brightred) parallelput (1) delay (100) Draw.FillOval (400, 100, 50, 50, white) Draw.Oval (400, 100, 50, 50, brown) onezero := parallelget exit when onezero = 56 %------------------------------------------- Draw.FillOval (290, 100, 50, 50, brightred) parallelput (2) delay (100) Draw.FillOval (290, 100, 50, 50, white) Draw.Oval (290, 100, 50, 50, brown) onezero := parallelget exit when onezero = 56 %------------------------------------------- Draw.FillOval (180, 100, 50, 50, brightred) parallelput (4) delay (100) Draw.FillOval (180, 100, 50, 50, white) Draw.Oval (180, 100, 50, 50, brown) onezero := parallelget exit when onezero = 56 %------------------------------------------- Draw.FillOval (70, 100, 50, 50, brightred) parallelput (8) delay (100) Draw.FillOval (70, 100, 50, 50, white) Draw.Oval (70, 100, 50, 50, brown) onezero := parallelget exit when onezero = 56 %------------------------------------------- end loop if onezero = target then put "YOU DID IT!" elsif (target = onezero - 1) or (target = onezero + 1) then put "YOU JUST MISSED!" else put "YOU'RE WAY OFF!" end if exit when onezero = 56 cls end loop |