-
Notifications
You must be signed in to change notification settings - Fork 144
/
gluttonous.py
43 lines (33 loc) · 1.28 KB
/
gluttonous.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
import cocos
import define
from arena import Arena
from gameover import Gameover
class HelloWorld(cocos.layer.Layer):
is_event_handler = True
def __init__(self):
super(HelloWorld, self).__init__()
self.arena = Arena()
self.add(self.arena)
self.score = cocos.text.Label('30',
font_name='Times New Roman',
font_size=24,
color=define.GOLD)
self.score.position = 20, 440
self.add(self.score, 99999)
self.gameover = Gameover()
self.add(self.gameover, 100000)
def update_score(self):
self.score.element.text = str(self.arena.snake.score)
def end_game(self):
self.gameover.visible = True
self.gameover.score.element.text = str(self.arena.snake.score)
def on_mouse_press(self, x, y, buttons, modifiers):
if self.gameover.visible:
self.gameover.visible = False
self.arena.unschedule(self.arena.update)
self.remove(self.arena)
self.arena = Arena()
self.add(self.arena)
self.update_score()
cocos.director.director.init(caption="Gluttonous Python")
cocos.director.director.run(cocos.scene.Scene(HelloWorld()))