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
|
import pygame
import helper
from blocks import blocks
import audio
def show(mouse):
surface = pygame.Surface((1280, 720))
surface.fill((0, 0, 0, 128))
surface.blit(helper.text("Select a block:", 20, (255, 255, 255)), (50, 50))
x = 50
y = 85
for block in list(filter(lambda i: blocks[i]['placeable'], blocks.keys())):
if x <= mouse[0] <= x + 42 and y <= mouse[1] <= y + 42:
surface.fill((255, 255, 255), (x - 5, y - 5, 52, 52))
surface.blit(helper.draw_texture(blocks[block]['texture']), (x, y))
x += 52
if x >= 1040:
x = 50
y += 52
x = 50
y = 85
for block in list(filter(lambda i: blocks[i]['placeable'], blocks.keys())):
if x <= mouse[0] <= x + 42 and y <= mouse[1] <= y + 42:
text = pygame.font.Font("./assets/font/main.ttf", 20).render(blocks[block]['name'], False, (0, 0, 0), (255, 255, 255))
surface.blit(text, (x - (text.get_width() / 2) + 21, y - text.get_height() - 5))
x += 52
if x >= 1040:
x = 50
y += 52
return surface
def click(mouse, screen, picker, selected_block):
x = 50
y = 85
for block in list(filter(lambda i: blocks[i]['placeable'], blocks.keys())):
if x <= mouse[0] <= x + 42 and y <= mouse[1] <= y + 42:
audio.play_sfx("action")
selected_block = block
picker = False
x += 52
if x >= 1040:
x = 50
y += 52
return mouse, screen, picker, selected_block
|