diff options
author | RaindropsSys <contact@minteck.org> | 2023-09-02 15:32:03 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-09-02 15:32:03 +0200 |
commit | 6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956 (patch) | |
tree | d425cdef328ed268fb149d6e2b139c9b2c26dbd2 /src/helper.py | |
parent | c2f1ed6a85c3895483d36af0f64e2829c3fa3263 (diff) | |
download | blocks-6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956.tar.gz blocks-6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956.tar.bz2 blocks-6a20ab31ef4d9f6bb0e008b9f1b8d3fbeb6bd956.zip |
Updated 13 files and added 2 files (automated)
Diffstat (limited to 'src/helper.py')
-rw-r--r-- | src/helper.py | 25 |
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 |