summaryrefslogtreecommitdiff
path: root/src/helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper.py')
-rw-r--r--src/helper.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/helper.py b/src/helper.py
index e391212..46f831a 100644
--- a/src/helper.py
+++ b/src/helper.py
@@ -6,6 +6,7 @@ from pathlib import Path
import os
texture_map = pygame.image.load('./assets/textures/texture_atlas.png')
+controls_map = pygame.image.load('./assets/textures/controls.png')
def get_data_path():
path = str(Path.home()) + "/.blocks"
@@ -38,7 +39,7 @@ def transparent(surface, percentage):
return screen
def text(text, size, color):
- return pygame.font.Font("./assets/font/main.ttf", size).render(text, False, color)
+ return pygame.Surface.convert_alpha(pygame.font.Font("./assets/font/main.ttf", size).render(text, False, color))
def get_block_texture(block):
return blocks[block]['texture']
@@ -49,4 +50,24 @@ def draw_texture(id):
else:
pos = (42 * (id - (floor(((id + 1) / 10) - 1) * 10)), 42 * (floor(((id + 1) / 10) - 1)))
- return texture_map.subsurface((pos[0], pos[1], 42, 42)) \ No newline at end of file
+ return texture_map.subsurface((pos[0], pos[1], 42, 42))
+
+def draw_control(id):
+ if id < 10:
+ pos = (17 * id, 0)
+ else:
+ pos = (17 * (id - (floor(((id + 1) / 10) - 1) * 10)), 17 * (floor(((id + 1) / 10) - 1)))
+
+ return pygame.Surface.convert_alpha(controls_map.subsurface((pos[0], pos[1], 17, 17)))
+
+def get_chunk_regions(chunks):
+ data = []
+
+ for x in range(len(chunks)):
+ for y in range(len(chunks)):
+ data.append({
+ "file": str(x) + "," + str(y) + ".bcr",
+ "range": (16 * x, 16 * y, 15 + 16 * x, 15 + 16 * y)
+ })
+
+ return data \ No newline at end of file