-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameOver.py
60 lines (36 loc) · 1.34 KB
/
GameOver.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
'''
GameOver.py
This module contains the class "GameOver"
last modified: August 19, 2021
by: Freeman Sun (GunesOzgur)
GitHub: GunesOzgur
---------------------------------------
GameOver class has these data attributes:
- GameOver.cnvs: Canvas() object that the "Game Over"
will be on
- GameOver.x: horizontal position of the "Game Over"
- GameOver.y: vertical position of the "Game Over"
- GameOver.img: "Game Over" image
- GameOver.ID: "Game Over" ID for Canvas
-----------------------------------------
ScoreTable class has these methods:
- GameOver.display(): display "Game Over"
VALUE
- GameOver.close(): close (make invisible) "Game Over"
----------------------------------------
'''
import tkinter as tk
src = "src/"
class GameOver:
def __init__(self, cnvs, x, y):
self.cnvs = cnvs
self.x = x+240
self.y = y
self.img = tk.PhotoImage(file=src+"GameOver.png")
self.ID = self.cnvs.create_image(self.x, self.y, anchor=tk.NE,
image=self.img, state='hidden')
def display(self):
self.cnvs.itemconfig(self.ID, state='normal')
self.cnvs.tag_raise(self.ID)
def close(self):
self.cnvs.itemconfig(self.ID, state='hidden')