-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
59 lines (44 loc) · 1.75 KB
/
main.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
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
import random
class Game(Widget):
check = ObjectProperty(None)
pcchoice = ObjectProperty(None)
userchoice = ObjectProperty(None)
def stone(self):
images = ["img/stone.png", "img/paper.png", "img/scissor.png"]
self.userchoice.source = "img/stone.png"
self.pcchoice.source = random.choice(images)
if self.pcchoice.source == "img/scissor.png":
self.check.text = "YOU WIN :)"
elif self.pcchoice.source == "img/paper.png":
self.check.text = "YOU LOSE :("
else:
self.check.text = "DRAW!"
def paper(self):
images = ["img/stone.png", "img/paper.png", "img/scissor.png"]
self.userchoice.source = "img/paper.png"
self.pcchoice.source = random.choice(images)
# Check who won
if self.pcchoice.source == "img/scissor.png":
self.check.text = "YOU LOSE :("
elif self.pcchoice.source == "img/stone.png":
self.check.text = "YOU WIN! :)"
else:
self.check.text = "DRAW!"
def scissor(self):
images = ["img/stone.png", "img/paper.png", "img/scissor.png"]
self.userchoice.source = "img/scissor.png"
self.pcchoice.source = random.choice(images)
if self.pcchoice.source == "img/stone.png":
self.check.text = "YOU LOSE :("
elif self.pcchoice.source == "img/paper.png":
self.check.text = "YOU WIN :)"
else:
self.check.text = "DRAW!"
class MainApp(App):
def build(self):
return Game()
if __name__ == '__main__':
MainApp().run()