-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInventory.py
More file actions
72 lines (59 loc) · 1.96 KB
/
Inventory.py
File metadata and controls
72 lines (59 loc) · 1.96 KB
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
62
63
64
65
66
67
68
69
70
71
72
import pyglet
from pyglet.gl import *
from pyglet.window import key
from Settings import *
class Inventory:
def __init__(self, width, height):
self.base_distance = 65
self.inv_size = 9
self.start_y = 50
self.start_x = (width - self.base_distance * self.inv_size) // 2
self.indice = 0
def draw(self):
for i in range(self.inv_size):
if i == self.indice:
glColor3d(0.9, 0.9, 0.9)
else:
glColor3d(0.7, 0.7, 0.7)
start_x = self.start_x + self.base_distance * i
start_y = self.start_y
self.box = pyglet.graphics.vertex_list(
4,
('v2i',
(start_x, start_y, # LEFT-BOTTOM
start_x + self.base_distance, start_y, # RIGHT-BOTTOM
start_x + self.base_distance, start_y + self.base_distance, # RIGHT-TOP
start_x, start_y + self.base_distance) # LEFT-BOTTOM
)
)
self.box.draw(GL_QUADS)
for i in range(self.inv_size + 1):
glColor3d(0, 0, 0)
start_x = self.start_x + self.base_distance * i
start_y = self.start_y
pyglet.graphics.draw(2, pyglet.gl.GL_LINES,
('v2i',
(start_x, start_y,
start_x, start_y + self.base_distance)
)
)
glColor3d(1, 1, 1)
def update(self, keys):
if keys[key._1]:
self.indice = 0
if keys[key._2]:
self.indice = 1
if keys[key._3]:
self.indice = 2
if keys[key._4]:
self.indice = 3
if keys[key._5]:
self.indice = 4
if keys[key._6]:
self.indice = 5
if keys[key._7]:
self.indice = 6
if keys[key._8]:
self.indice = 7
if keys[key._9]:
self.indice = 8