## Friday, November 1, 2013

### Estimate the angle

# This is a game designed to be played on an interactive whiteboard by two players

clg
fastgraphics
p1=0:p2=0
Bestof = 5
#Main ####################################
do

angle1=int(rand*360)
angle2=int(rand*360)
gosub drawscale
gosub drawpie
color white

text 170,280,"A turn"
refresh
gosub cliked
text 170,330,"Guess: "+guess+"º"
refresh
error1=abs(guess-angle1)
pause 1

text 470,280,"B turn"
refresh
gosub cliked
text 470,330,"Guess: "+guess+"º"
refresh
error2=abs(guess-angle2)
pause 1

gosub drawscale
gosub drawpie

color red
if error1<error2 then
win=200
p1=p1+1
color green
end if
text 170,330,"Real: "+angle1+"º"
text 170,380,"Error: "+error1+"º"
color red
if error1>error2 then
win=470
p2=p2+1
color green
end if
text 470,330,"Real: "+angle2+"º"
text 470,380,"Error: "+error2+"º"
color green
text win,150,"Winner"
refresh
pause 2
clg
until p1=Bestof or p2=Bestof
#End code####################################
color black
if p1=5 then text 270,320,"Player A won :)"
if p2=5 then text 270,320,"Player B won :)"
refresh
end
#Subroutines###################################
cliked:
clickclear
do
guess=mousey-7
until clicky>0
return

drawpie:
font "arial",30,100
text 170,10, "Palyer A: "+p1
text 470,10, "Player B: "+p2
color orange
pie ( 150,70,200,200,0,pi*angle1/180 )
color blue
pie ( 450,70,200,200,0,pi*angle2/180 )
return

drawscale:
font "arial",10,100
color black
graphsize 800,600
rect 0,0,800,600
color white
for y = 0 to 360 step 20
text 10,y,y
line 30,y+7,100,y+7
text 775,y,y
line 700,y+7,770,y+7
next y
refresh
return