Professional Documents
Culture Documents
import random
import time
import sys
pattern = []
#o is the amount of times the game will run - 1
o= 100000
#easy mode
if (gamemode[0] == 'e'):
#Graphic window
win = GraphWin(title = "Simon Says", width = 300, height = 300)
gbutton = Rectangle(Point(50,50),Point(150,150))
rbutton = Rectangle(Point(150,50),Point(250,150))
ybutton = Rectangle(Point(50,150),Point(150,250))
bbutton = Rectangle(Point(150,150),Point(250,250))
gb = Rectangle(Point(60,60),Point(140,140))
rb = Rectangle(Point(160,60),Point(240,140))
yb = Rectangle(Point(60,160),Point(140,240))
bb = Rectangle(Point(160,160),Point(240,240))
gb.setFill(color_rgb(204,255,204))
rb.setFill(color_rgb(255,204,204))
yb.setFill(color_rgb(255,255,204))
bb.setFill(color_rgb(204,204,255))
gbutton.setFill("green")
rbutton.setFill("red")
ybutton.setFill("yellow")
bbutton.setFill("blue")
gbutton.draw(win)
rbutton.draw(win)
ybutton.draw(win)
bbutton.draw(win)
ready = Text(Point(50,25),"Ready...")
ready.setTextColor("red")
ready.draw(win)
time.sleep(2)
ready.undraw()
sett = Text(Point(150,25),"Set...")
sett.setTextColor("yellow")
sett.draw(win)
time.sleep(2)
sett.undraw()
go = Text(Point(250,25),"Go!")
go.setTextColor("green")
go.draw(win)
time.sleep(2)
go.undraw()
time.sleep(1)
#loop to start the game
for y in range(o):
# Append 1 color to pattern
score = 0
z = random.randint(1,4)
if z == 1:
pattern.append('green')
elif z == 2:
pattern.append('red')
elif z == 3:
pattern.append('yellow')
else:
pattern.append('blue')
else:
bb.draw(win)
time.sleep(1)
bb.undraw()
time.sleep(0.1)
click = win.getMouse()
p = click.getX()
h = click.getY()
else:
lose = Text(Point(150,20), "You lost! Press E to exit the game.")
lose.setSize(10)
lose.draw(win)
exit = win.getKey()
if(exit == 'e'):
sys.exit()
else:
continue
break
i += 1
score+=1
yes.setText(score)
gbutton = Rectangle(Point(50,50),Point(150,150))
rbutton = Rectangle(Point(150,50),Point(250,150))
ybutton = Rectangle(Point(50,150),Point(150,250))
bbutton = Rectangle(Point(150,150),Point(250,250))
gb = Rectangle(Point(60,60),Point(140,140))
rb = Rectangle(Point(160,60),Point(240,140))
yb = Rectangle(Point(60,160),Point(140,240))
bb = Rectangle(Point(160,160),Point(240,240))
gb.setFill(color_rgb(204,255,204))
rb.setFill(color_rgb(255,204,204))
yb.setFill(color_rgb(255,255,204))
bb.setFill(color_rgb(204,204,255))
gbutton.setFill("green")
rbutton.setFill("red")
ybutton.setFill("yellow")
bbutton.setFill("blue")
gbutton.draw(win)
rbutton.draw(win)
ybutton.draw(win)
bbutton.draw(win)
ready = Text(Point(50,25),"Ready...")
ready.setTextColor("red")
ready.draw(win)
time.sleep(2)
ready.undraw()
sett = Text(Point(150,25),"Set...")
sett.setTextColor("yellow")
sett.draw(win)
time.sleep(2)
sett.undraw()
go = Text(Point(250,25),"Go!")
go.setTextColor("green")
go.draw(win)
time.sleep(2)
go.undraw()
time.sleep(1)
for y in range(o):
# Append 1 color to pattern
score = 0
z = random.randint(1,4)
if z == 1:
pattern.append('green')
elif z == 2:
pattern.append('red')
elif z == 3:
pattern.append('yellow')
else:
pattern.append('blue')
else:
bb.draw(win)
time.sleep(.25)
bb.undraw()
time.sleep(0.1)
click = win.getMouse()
p = click.getX()
h = click.getY()
else:
lose = Text(Point(150,20), "You lost! Press E to exit the game.")
lose.setSize(10)
lose.draw(win)
exit = win.getKey()
if(exit == 'e'):
sys.exit()
else:
continue
break
i += 1
score+=1
yes.setText(score)