-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasy 수정중
149 lines (133 loc) · 6.07 KB
/
easy 수정중
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
142
143
144
145
146
147
148
149
from PyQt5 import QtCore, QtGui, QtWidgets, QtTest
import random
class Ui_Dialog(object):
def __init__(self):
self.realBreak = True
self.number = 0 # 생성자
self.numlist = [] # 랜덤난수 리스트
self.numlist_user = [] # 내가 입력한수 리스트
self.roundcnt = 1
self.counting = 0
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(960, 743)
font = QtGui.QFont()
font.setBold(False)
font.setWeight(50)
Dialog.setFont(font)
Dialog.setStyleSheet("background-color:rgb(230, 255, 230);")
self.label = QtWidgets.QLabel(Dialog) # memory game
self.label.setGeometry(QtCore.QRect(350, 120, 291, 51))
self.label.setStyleSheet("font: 75 18pt \"한컴 말랑말랑 Bold\";\n""")
self.label.setTextFormat(QtCore.Qt.AutoText)
self.label.setObjectName("label")
self.pushButton = QtWidgets.QPushButton(Dialog) # e 버튼
self.pushButton.setGeometry(QtCore.QRect(60, 430, 161, 161))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(23)
self.pushButton.setFont(font)
self.pushButton.setStyleSheet("background-color:rgb(204, 242, 255);")
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(lambda: self.countingnum(1))
self.pushButton_2 = QtWidgets.QPushButton(Dialog) # a 버튼
self.pushButton_2.setGeometry(QtCore.QRect(290, 430, 161, 161))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(23)
self.pushButton_2.setFont(font)
self.pushButton_2.setStyleSheet("background-color:rgb(204, 242, 255);")
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_2.clicked.connect(lambda: self.countingnum(2))
self.pushButton_3 = QtWidgets.QPushButton(Dialog) # s 버튼
self.pushButton_3.setGeometry(QtCore.QRect(520, 430, 161, 161))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(23)
self.pushButton_3.setFont(font)
self.pushButton_3.setStyleSheet("background-color:rgb(204, 242, 255);")
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton_3.clicked.connect(lambda: self.countingnum(3))
self.pushButton_4 = QtWidgets.QPushButton(Dialog) # y 버튼
self.pushButton_4.setGeometry(QtCore.QRect(750, 430, 161, 161))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(23)
self.pushButton_4.setFont(font)
self.pushButton_4.setStyleSheet("background-color:rgb(204, 242, 255);")
self.pushButton_4.setObjectName("pushButton_4")
self.pushButton_4.clicked.connect(lambda: self.countingnum(4))
self.label_2 = QtWidgets.QLabel(Dialog) # level:
self.label_2.setGeometry(QtCore.QRect(70, 240, 81, 31))
font = QtGui.QFont()
font.setPointSize(15)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEdit = QtWidgets.QLineEdit(Dialog) # level 옆 lineedit
self.lineEdit.setGeometry(QtCore.QRect(160, 240, 113, 31))
self.lineEdit.setText("")
self.lineEdit.setObjectName("lineEdit")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
self.playGame()
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Memory Game"))
self.pushButton.setText(_translate("Dialog", "1"))
self.pushButton_2.setText(_translate("Dialog", "2"))
self.pushButton_3.setText(_translate("Dialog", "3"))
self.pushButton_4.setText(_translate("Dialog", "4"))
self.label_2.setText(_translate("Dialog", "Level:"))
def playGame(self):
breaktime = 500
if self.roundcnt % 3 == 0:
breaktime -= 100
self.number = random.choices(range(1, 5), k=1)[0]
self.numlist.append(self.number)
self.lineEdit.setText(str(self.roundcnt))
if not self.realBreak:
print("GameOver")
else:
for k in range(len(self.numlist)):
if len(self.numlist) == 1:
print(self.numlist[0])
if self.numlist[k] == 1:
self.pushButton.setStyleSheet("background-color: #0067a3")
QtTest.QTest.qWait(breaktime)
self.pushButton.setStyleSheet("background-color:rgb(204, 242, 255);")
elif self.numlist[k] == 2:
self.pushButton_2.setStyleSheet("background-color: #0067a3")
QtTest.QTest.qWait(breaktime)
self.pushButton_2.setStyleSheet("background-color:rgb(204, 242, 255);")
elif self.numlist[k] == 3:
self.pushButton_3.setStyleSheet("background-color: #0067a3")
QtTest.QTest.qWait(breaktime)
self.pushButton_3.setStyleSheet("background-color:rgb(204, 242, 255);")
elif self.numlist[k] == 4:
self.pushButton_4.setStyleSheet("background-color: #0067a3")
QtTest.QTest.qWait(breaktime)
self.pushButton_4.setStyleSheet("background-color:rgb(204, 242, 255);")
def countingnum(self, key):
print(key)
self.numlist_user.append(key)
if self.numlist_user[self.counting] == self.numlist[self.counting]:
self.counting += 1
if len(self.numlist) == len(self.numlist_user):
self.numlist_user.clear()
self.counting = 0
self.roundcnt += 1
self.playGame()
else:
pass
else:
self.realBreak = False
self.playGame()
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())