This shows you the differences between two versions of the page.
gamescopycat [2016/01/01 22:36] 127.0.0.1 external edit |
gamescopycat [2020/02/28 10:46] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | |{{gamescopycat.png}}|Repeat after the computer. | ||
- | < | ||
- | #CopyCat - A follow along memory game | ||
- | # 2013-01-07 j.m.reneau | ||
- | # requires BASIC256 0.9.9.25 or later | ||
- | pies = 5 | ||
- | dim lightcolors(1) | ||
- | lightcolors = {red, blue, green, yellow, purple, cyan, orange} | ||
- | dim darkcolors(1) | ||
- | darkcolors = {darkred, darkblue, darkgreen, darkyellow, darkpurple, darkcyan, darkorange} | ||
- | global pies, lightcolors, | ||
- | |||
- | fastgraphics | ||
- | dim game(100) | ||
- | |||
- | print " | ||
- | print "See how long of a pattern you can remember. | ||
- | |||
- | do | ||
- | input "How many pie slices (3-7)?", | ||
- | until pies >=3 and pies <= 7 | ||
- | |||
- | # generate the game | ||
- | for t = 0 to game[?]-1 | ||
- | | ||
- | next t | ||
- | |||
- | round = 0 | ||
- | gameon = true | ||
- | while gameon | ||
- | # show the pattern | ||
- | | ||
- | print "Round " + round | ||
- | for t = 0 to round -1 | ||
- | call showslice(100, | ||
- | next t | ||
- | # | ||
- | # get the user to give it back | ||
- | print " | ||
- | for t = 0 to round -1 | ||
- | g = getclick(3000, | ||
- | if g = -1 then | ||
- | # made a mistake - die | ||
- | | ||
- | t = round | ||
- | end if | ||
- | next t | ||
- | end while | ||
- | print "You completed " + round + " rounds." | ||
- | end | ||
- | |||
- | subroutine showslice(waittime, | ||
- | pause waittime/ | ||
- | call drawgame(slice) | ||
- | call playsound(slice, | ||
- | call drawgame(-1) | ||
- | end subroutine | ||
- | |||
- | function getclick(timeout, | ||
- | # get the click before the timeout | ||
- | start = msec | ||
- | while msec< | ||
- | pause .01 | ||
- | end while | ||
- | if msec> | ||
- | call drawgame(slicetoclick) | ||
- | call playdie() | ||
- | return -1 | ||
- | else | ||
- | slice = -1 | ||
- | for t = 0 to pies-1 | ||
- | if pixel(mousex, | ||
- | next t | ||
- | if slice <> slicetoclick then | ||
- | call drawgame(slicetoclick) | ||
- | call playdie() | ||
- | | ||
- | else | ||
- | call drawgame(slice) | ||
- | call playsound(slice, | ||
- | while mouseb <> 0 | ||
- | pause .01 | ||
- | end while | ||
- | call drawgame(-1) | ||
- | | ||
- | end if | ||
- | end if | ||
- | end function | ||
- | |||
- | subroutine playdie() | ||
- | sound 100,500 | ||
- | say "you loose." | ||
- | end subroutine | ||
- | |||
- | subroutine playsound(s, | ||
- | sound 200+s*50,d | ||
- | end subroutine | ||
- | |||
- | subroutine drawgame(sliceon) | ||
- | # set slice number by passing its number (-1) nothing is on | ||
- | clg | ||
- | | ||
- | w = 2*pi/pies | ||
- | for t = 0 to pies-1 | ||
- | if t = sliceon then | ||
- | color black, | ||
- | else | ||
- | color black, | ||
- | end if | ||
- | pie 0, | ||
- | next t | ||
- | | ||
- | end subroutine | ||
- | </ |