Fix du rendu dans les chunks à des coordonnées négatives
This commit is contained in:
parent
43f9ba682c
commit
739f7a984a
3261
maps/map3.tmj
Normal file
3261
maps/map3.tmj
Normal file
File diff suppressed because it is too large
Load diff
|
@ -19,8 +19,6 @@ class MapManager:
|
|||
chunks[(chunk["x"]//self.chunk_width, chunk["y"]//self.chunk_height)] = chunk["data"]
|
||||
self.map_layers.append(chunks)
|
||||
|
||||
print(self.map_layers)
|
||||
|
||||
def get_tile_at(self, x: int, y: int, layer_id: int):
|
||||
"""Donne l'id de la tile aux coordonnées données et à la couche choisie."""
|
||||
|
||||
|
|
|
@ -143,8 +143,8 @@ class Renderer:
|
|||
y_middle_offset = display.get_window_size()[1] / 2 / self.engine.camera.zoom
|
||||
|
||||
# On calcule le décalage du début de rendu des tiles
|
||||
x_map_offset = int((self.engine.camera.x - x_middle_offset) / self.tile_size)
|
||||
y_map_offset = int((self.engine.camera.y - y_middle_offset) / self.tile_size)
|
||||
x_map_offset = math.floor((self.engine.camera.x - x_middle_offset) / self.tile_size)
|
||||
y_map_offset = math.floor((self.engine.camera.y - y_middle_offset) / self.tile_size)
|
||||
|
||||
# On itère pour chaque couche, toutes les tiles visibles par la caméra
|
||||
for x in range(x_map_offset, x_map_offset + x_map_range):
|
||||
|
|
16
src/main.py
16
src/main.py
|
@ -7,7 +7,7 @@ from src.engine.engine import Engine
|
|||
class Game(Engine):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.map_manager.load_new("maps/map2.tmj")
|
||||
self.map_manager.load_new("maps/map3.tmj")
|
||||
|
||||
self.renderer.load_tile_set("assets/textures/tiles.png", 16)
|
||||
|
||||
|
@ -23,19 +23,5 @@ class Game(Engine):
|
|||
|
||||
self.camera.follow_entity(player)
|
||||
|
||||
for i in range(20):
|
||||
anim = Anim(0.5)
|
||||
anim.load_animation_from_directory("assets/textures/entities/player/none")
|
||||
self.renderer.register_animation(anim, f"player_none_{i}")
|
||||
|
||||
test = self.entity_manager.register_entity(f"test_{i}")
|
||||
test.x = random.randint(0, 200)
|
||||
test.y = random.randint(0, 200)
|
||||
test.link_animation(f"player_none_{i}")
|
||||
test.collision_rect = [-7, -7, 7, 7]
|
||||
|
||||
test.set_default_life(10)
|
||||
|
||||
|
||||
game = Game()
|
||||
game.loop()
|
||||
|
|
Loading…
Reference in a new issue