1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
<!DOCTYPE html>
<html lang="en" dir="ltr" class="no-js">
<head>
<meta charset="utf-8" />
<title>gamescopycat [BASIC 256 - Language Documentation]</title>
<link rel="stylesheet" type="text/css" href="lib/exe/cssc171c1dfe8519125bb40a349172b001a.css"/>
</head>
<body>
<div id="dokuwiki__site"><div id="dokuwiki__top" class="site dokuwiki mode_show tpl_dokuwiki ">
<div id="dokuwiki__header"><div class="pad group">
<div class="headings group">
<h1><a href="start.html" accesskey="h" title="[H]"><img src="lib/tpl/dokuwiki/images/logo.png" width="64" height="64" alt="" /> <span>BASIC 256 - Language Documentation</span></a></h1>
</div>
</div>
<div class="breadcrumbs">
<div class="youarehere"><span class="bchead">You are here: </span><span class="home"><bdi><a href="start.html" class="wikilink1" title="start">start</a></bdi></span> » <bdi><span class="curid"><a href="gamescopycat.html" class="wikilink1" title="gamescopycat">gamescopycat</a></span></bdi></div>
</div>
<hr class="a11y" />
</div></div>
<div class="wrapper group">
<div id="dokuwiki__content"><div class="pad group">
<div class="pageId"><span>gamescopycat</span></div>
<div class="page group">
<div class="table sectionedit1"><table class="inline">
<tr class="row0">
<td class="col0"><a href="http://doc.basic256.org/lib/exe/detail.php?id=gamescopycat&media=gamescopycat.png" class="media" title="gamescopycat.png"><img src="lib/exe/gamescopycat.png" class="media" alt="" /></a></td><td class="col1">Repeat after the computer. Longer and longer patterns of lights and sounds will test your short term memory. Choose more color slices to make the game more difficult.</td>
</tr>
</table></div>
<pre class="code">#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, darkcolors
fastgraphics
dim game(100)
print "CopyCat"
print "See how long of a pattern you can remember. Click on the correct pie wedge when it is your turn."
do
input "How many pie slices (3-7)?", pies
until pies >=3 and pies <= 7
# generate the game
for t = 0 to game[?]-1
game[t] = int(rand*pies)
next t
round = 0
gameon = true
while gameon
# show the pattern
round++
print "Round " + round
for t = 0 to round -1
call showslice(100,300,game[t])
next t
#
# get the user to give it back
print " Play it back."
for t = 0 to round -1
g = getclick(3000,game[t])
if g = -1 then
# made a mistake - die
gameon = false
t = round
end if
next t
end while
print "You completed " + round + " rounds."
end
subroutine showslice(waittime, soundtime, slice)
pause waittime/1000
call drawgame(slice)
call playsound(slice, soundtime)
call drawgame(-1)
end subroutine
function getclick(timeout, slicetoclick)
# get the click before the timeout
start = msec
while msec<start+timeout and mouseb = 0
pause .01
end while
if msec>=start+timeout then
call drawgame(slicetoclick)
call playdie()
return -1
else
slice = -1
for t = 0 to pies-1
if pixel(mousex, mousey) = darkcolors[t] then slice = t
next t
if slice <> slicetoclick then
call drawgame(slicetoclick)
call playdie()
return -1
else
call drawgame(slice)
call playsound(slice, 250)
while mouseb <> 0
pause .01
end while
call drawgame(-1)
return slice
end if
end if
end function
subroutine playdie()
sound 100,500
say "you loose."
end subroutine
subroutine playsound(s, d)
sound 200+s*50,d
end subroutine
subroutine drawgame(sliceon)
# set slice number by passing its number (-1) nothing is on
clg
penwidth 1
w = 2*pi/pies
for t = 0 to pies-1
if t = sliceon then
color black,lightcolors[t]
else
color black,darkcolors[t]
end if
pie 0,0,300,300,t*w,w
next t
refresh
end subroutine</pre>
</div>
<div class="docInfo"><bdi>gamescopycat.txt</bdi> · Last modified: 2013/01/07 20:44 by <bdi>admin</bdi></div>
</div></div>
<hr class="a11y" />
</div>
<div id="dokuwiki__footer"><div class="pad">
<div class="license">Except where otherwise noted, content on this wiki is licensed under the following license: <bdi><a href="http://creativecommons.org/licenses/by-sa/3.0/" rel="license" class="urlextern">CC Attribution-Share Alike 3.0 Unported</a></bdi></div>
</div></div>
</div></div>
<div id="screen__mode" class="no"></div>
</body>
</html>
|