-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
61 lines (48 loc) · 1.52 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
60
61
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
from kivy.lang import Builder
import random
Builder.load_file("main.kv")
class Game(Widget):
check = ObjectProperty(None)
pcimage = ObjectProperty(None)
userimage = ObjectProperty(None)
def rock(self):
images = ["img/rock.jpg","img/papper.png","img/scissor.jpg"]
self.userimage.source = "img/rock.jpg"
self.pcimage.source = random.choice(images)
# Check who won
if self.pcimage.source == "img/papper.png":
self.check.text = "You lose!"
elif self.pcimage.source == "img/scissor.jpg":
self.check.text = "You won!"
else:
self.check.text = "Draw!"
def papper(self):
images = ["img/rock.jpg","img/papper.png","img/scissor.jpg"]
self.userimage.source = "img/papper.png"
self.pcimage.source = random.choice(images)
# Check who won
if self.pcimage.source == "img/scissor.jpg":
self.check.text = "You lose!"
elif self.pcimage.source == "img/rock.jpg":
self.check.text = "You won!"
else:
self.check.text = "Draw!"
def scissor(self):
images = ["img/rock.jpg","img/papper.png","img/scissor.jpg"]
self.userimage.source = "img/scissor.jpg"
self.pcimage.source = random.choice(images)
# Check who won
if self.pcimage.source == "img/rock.jpg":
self.check.text = "You lose!"
elif self.pcimage.source == "img/papper.png":
self.check.text = "You won!"
else:
self.check.text = "Draw!"
class MainApp(App):
def build(self):
return Game()
if __name__ == '__main__':
MainApp().run()