-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodeScreen.py
85 lines (73 loc) · 2.9 KB
/
modeScreen.py
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
try: from cmu_cs3_graphics import *
except: from cmu_graphics import *
from runAppWithScreens import *
from Buttons import *
from State import *
from boardScreen import *
##################################
# mainScreen
##################################
def modeScreen_onScreenStart(app):
app.modeScreenButtons = [] #(msg, top, left, length, height, hover)
setAllButtons(app)
def modeScreen_onKeyPress(app, key):
print('this is the mode screen key press')
if key == 'space':
# app.currScreen = 'boardScreen'
setActiveScreen('mainScreen')
def modeScreen_redrawAll(app):
drawTitle(app, "Mode Selection",)
drawAllButtons(app.modeScreenButtons)
drawLabel(f'Your current mode is {app.currMode.upper()}', app.width/2, 200, size =14)
def modeScreen_onMouseMove(app, mouseX, mouseY):
buttonClickedIndex = getButtonClicked(app.modeScreenButtons, mouseX, mouseY)
if buttonClickedIndex != None:
app.modeScreenButtons[buttonClickedIndex]['hover'] =True
else:
setAllButtonHoverFalse(app.modeScreenButtons)
def drawTitle(app, msg, size =40):
centerX = app.width/2
drawLabel(msg, centerX, 150, size = size, bold = True, fill = app.settingDict['Titles Color']) #titlesColor
def modeScreen_onMouseMove(app, mouseX, mouseY):
buttonClickedIndex = getButtonClicked(app.modeScreenButtons, mouseX, mouseY)
if buttonClickedIndex != None:
app.modeScreenButtons[buttonClickedIndex]['hover'] =True
else:
setAllButtonHoverFalse(app.modeScreenButtons)
def modeScreen_onMousePress(app, mouseX, mouseY):
buttonClickedIndex = getButtonClicked(app.modeScreenButtons, mouseX, mouseY)
prevMode = app.currMode
if buttonClickedIndex ==0:
# Easy
app.currMode = 'easy'
elif buttonClickedIndex ==1:
#Medium
app.currMode = 'medium'
elif buttonClickedIndex ==2:
#hard
app.currMode = 'hard'
elif buttonClickedIndex ==3:
#Expert
app.currMode = 'expert'
elif buttonClickedIndex ==4:
#evil
app.currMode = 'evil'
elif buttonClickedIndex ==5:
setActiveScreen('twoPlayerScreen')
elif buttonClickedIndex ==6:
#back
setActiveScreen('mainScreen')
#was changed load new board
if app.currMode != prevMode:
restartBoardScreen(app)
#for main screen
def setAllButtons(app):
startX = 100
centerY = app.height/2 - 50/2
setButton(app.modeScreenButtons, 'EASY', startX+200*0, centerY)
setButton(app.modeScreenButtons, 'MEDIUM', startX+200*1, centerY)
setButton(app.modeScreenButtons, 'HARD', startX+200*2, centerY)
setButton(app.modeScreenButtons, 'EXPERT', startX +200*0, centerY+100)
setButton(app.modeScreenButtons, 'EVIL', startX+200*1, centerY+100)
setButton(app.modeScreenButtons, '2 Player', startX+200*2, centerY+100)
setButton(app.modeScreenButtons, 'Back',50 , 40, length =60, height =40)