summaryrefslogtreecommitdiff
path: root/src/picker.py
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-09-02 15:32:03 +0200
committerRaindropsSys <contact@minteck.org>2023-09-02 15:32:03 +0200
commit6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956 (patch)
treed425cdef328ed268fb149d6e2b139c9b2c26dbd2 /src/picker.py
parentc2f1ed6a85c3895483d36af0f64e2829c3fa3263 (diff)
downloadblocks-6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956.tar.gz
blocks-6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956.tar.bz2
blocks-6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956.zip
Updated 13 files and added 2 files (automated)
Diffstat (limited to 'src/picker.py')
-rw-r--r--src/picker.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/picker.py b/src/picker.py
new file mode 100644
index 0000000..d23b8c3
--- /dev/null
+++ b/src/picker.py
@@ -0,0 +1,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 \ No newline at end of file