-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
38 lines (30 loc) · 1 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
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.image import Image
from kivy.uix.behaviors import ButtonBehavior
from kivy.vector import Vector
from kivy.properties import NumericProperty
from kivy.core.audio import SoundLoader
class CookieButton(ButtonBehavior, Image):
sound = SoundLoader.load('crunch.wav')
def __init__(self, **kwargs):
super(CookieButton, self).__init__(**kwargs)
self.source = 'cookie.png'
self.original_size = Vector(self.size)
self.clicked_size = Vector(self.size) * 1.2
def on_press(self):
self.parent.score += 1
self.size = self.clicked_size
self.center = self.parent.center
self.sound.play()
def on_release(self):
self.size = self.original_size
self.center = self.parent.center
class ClickerGame(Widget):
score = NumericProperty(0)
pass
class ClickerApp(App):
def build(self):
return ClickerGame()
if __name__ == '__main__':
ClickerApp().run()