From 1c3d6a7d90edd3d8c677b29b37a5e0c06eb69477 Mon Sep 17 00:00:00 2001 From: yannis300307 Date: Fri, 22 Dec 2023 21:34:42 +0100 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20de=20rendu=20de=20la=20map=20et=20?= =?UTF-8?q?d=C3=A9placement=20de=20la=20cam=C3=A9ra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/tiles.tsx | 4 + maps/map1.tmj | 563 +++++++++++++++++++++++++++++++++++++++++++ src/engine.py | 8 +- src/event_handler.py | 22 +- src/map_manager.py | 36 ++- src/renderer.py | 42 +++- 6 files changed, 658 insertions(+), 17 deletions(-) create mode 100644 assets/tiles.tsx create mode 100644 maps/map1.tmj diff --git a/assets/tiles.tsx b/assets/tiles.tsx new file mode 100644 index 0000000..ce65c59 --- /dev/null +++ b/assets/tiles.tsx @@ -0,0 +1,4 @@ + + + + diff --git a/maps/map1.tmj b/maps/map1.tmj new file mode 100644 index 0000000..8a0981d --- /dev/null +++ b/maps/map1.tmj @@ -0,0 +1,563 @@ +{ "compressionlevel":-1, + "height":20, + "infinite":true, + "layers":[ + { + "chunks":[ + { + "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1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, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], + "height":16, + "width":16, + "x":48, + "y":80 + }], + "height":96, + "id":1, + "name":"Calque de Tuiles 1", + "opacity":1, + "startx":0, + "starty":0, + "type":"tilelayer", + "visible":true, + "width":64, + "x":0, + "y":0 + }], + "nextlayerid":2, + "nextobjectid":1, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.10.1", + "tileheight":16, + "tilesets":[ + { + "firstgid":1, + "source":"..\/assets\/tiles.tsx" + }], + "tilewidth":16, + "type":"map", + "version":"1.10", + "width":30 +} \ No newline at end of file diff --git a/src/engine.py b/src/engine.py index ac34e71..072843e 100644 --- a/src/engine.py +++ b/src/engine.py @@ -1,3 +1,4 @@ +from src.camera import Camera from src.event_handler import EventHandler from src.map_manager import MapManager from src.renderer import Renderer @@ -7,7 +8,7 @@ import pygame class Engine: """Classe principale qui regroupe tous les composants du programme (Renderer, MapManager, EventHandler, etc ...)""" def __init__(self): - # L'initialisation de Pygame est nécéssaire pour tous les modules + # L'initialisation de Pygame est nécessaire pour tous les modules pygame.init() self.clock = pygame.time.Clock() @@ -16,8 +17,9 @@ class Engine: self.renderer = Renderer(self) self.event_handler = EventHandler(self) self.map_manager = MapManager() + self.camera = Camera() - self.map_manager.load_new("maps/map0.tmj") + self.map_manager.load_new("maps/map1.tmj") self.renderer.load_tile_set("assets/tiles.png", 16) @@ -36,6 +38,6 @@ class Engine: self.event_handler.update() def stop(self): - """Arrete le programme.""" + """Arrête le programme.""" self.running = False pygame.quit() diff --git a/src/event_handler.py b/src/event_handler.py index 689239c..9bfb7dc 100644 --- a/src/event_handler.py +++ b/src/event_handler.py @@ -1,5 +1,5 @@ from pygame import event -from pygame.locals import QUIT +from pygame.locals import * import src.engine as engine @@ -8,9 +8,29 @@ class EventHandler: """Classe utilisée pour traiter les pygame.event.get() et gérer les interactions avec le reste du programme.""" def __init__(self, core: 'engine.Engine'): self.engine = core + self.key_pressed = [] def update(self): """Vérifie s'il y a de nouvelles interactions et les traites.""" + + # Récupère les événements for e in event.get(): if e.type == QUIT: self.engine.stop() + elif e.type == KEYDOWN: + self.key_pressed.append(e.key) + elif e.type == KEYUP: + self.key_pressed.remove(e.key) + + if K_RIGHT in self.key_pressed: + self.engine.camera.x += 2 + if K_LEFT in self.key_pressed: + self.engine.camera.x -= 2 + if K_UP in self.key_pressed: + self.engine.camera.y -= 2 + if K_DOWN in self.key_pressed: + self.engine.camera.y += 2 + if K_x in self.key_pressed: + self.engine.camera.zoom *= 1.01 + if K_c in self.key_pressed: + self.engine.camera.zoom *= 0.99 diff --git a/src/map_manager.py b/src/map_manager.py index 0f3af86..db9d8ce 100644 --- a/src/map_manager.py +++ b/src/map_manager.py @@ -4,18 +4,44 @@ import json class MapManager: """Stocke les cartes du jeu.""" def __init__(self): - # structure : [layers[chunks[x, y]{width, height, data [tiles id]}] + # structure : [layers{chunks[x, y][data]} self.map_layers = [] + self.chunk_width = 16 + self.chunk_height = 16 def load_new(self, file_path: str): """Charge une map infinie au format tiled.""" with open(file_path, "r") as file: data = json.loads(file.read()) for layer in data["layers"]: - self.map_layers.append(layer["chunks"]) + chunks = {} + for chunk in layer["chunks"]: + 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: int): - """Done l'id de la tile aux coordonnées données et à la couche choisie.""" - return \ No newline at end of file + 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.""" + + # On récupère la couche demandée + layer = self.map_layers[layer_id] + + # On calcule les coordonées du chunk + coordinates = (x//self.chunk_width, y//self.chunk_height) + + # On transforme les coordonnées globales en coordonnées dans le chunk + x %= 16 + y %= 16 + + if coordinates not in layer: + return 0 + + chunk = layer[coordinates] + + # On vérifie que la tile demandée existe sinon on répond "vide" + if x >= self.chunk_width or x < 0 or y >= self.chunk_height or y < 0: + return 0 + + # On calcule l'index et on renvoie la tile + return chunk[x+y*self.chunk_width] diff --git a/src/renderer.py b/src/renderer.py index e04c724..816931f 100644 --- a/src/renderer.py +++ b/src/renderer.py @@ -1,4 +1,5 @@ -from pygame import display, image +from pygame import display, image, surface, transform +from pygame.locals import RESIZABLE import src.engine as engine @@ -7,19 +8,22 @@ class Renderer: """Classe contenant le moteur de rendu. On utilise, pour cela la bibliothèque Pygame.""" def __init__(self, core: 'engine.Engine'): self.engine = core - self.window = display.set_mode((600, 600)) + self.window = display.set_mode((600, 600), RESIZABLE) self.tiles = [] + self.tile_size = 0 def load_tile_set(self, file_path: str, tile_size: int): """Charge le jeu de tuiles en utilisant le fichier donné et la taille donnée.""" tile_set = image.load(file_path).convert_alpha() + self.tile_size = tile_size + # Scan tout le tile set et le découpe pour créer des tiles de {tile_size} px de hauteur et de largeur for y in range(tile_set.get_height()//tile_size): for x in range(tile_set.get_width()//tile_size): tile = tile_set.subsurface((x*tile_size, y*tile_size, tile_size, tile_size)) self.tiles.append(tile) - print(self.tiles) + #print(self.tiles) def update(self): """Fait le rendu du jeu.""" @@ -30,11 +34,33 @@ class Renderer: display.update() def render_map(self): - x_offset = 0 - y_offset = 0 + x_map_range = int(display.get_window_size()[0] // 16 // self.engine.camera.zoom) + 2 + y_map_range = int(display.get_window_size()[1] // 16 // self.engine.camera.zoom) + 2 + x_map_offset = int(self.engine.camera.x) + y_map_offset = int(self.engine.camera.y) - for i in range(4): - self.window.blit(self.tiles[i], (i*16, 0)) + rendered_surface_size = (x_map_range*self.tile_size, y_map_range*self.tile_size) - self.rendered_surface = None + # On crée une surface temporaire qui nous permettra de la redimensionner + rendered_surface = surface.Surface(rendered_surface_size) + + # On itère pour chaque couche, toutes les tiles visibles par la caméra + for i in range(len(self.engine.map_manager.map_layers)): + for x in range(x_map_offset, x_map_offset + x_map_range): + for y in range(y_map_offset, y_map_offset + y_map_range): + + # On récupère l'id de la tile à la position donnée + tile_id = self.engine.map_manager.get_tile_at(x, y, i) + + # Si l'id est 0, il s'agit de vide donc on saute le rendu + if tile_id == 0: + continue + + # Puis, on cherche à quelle image elle correspond et on la colle sur notre surface + rendered_surface.blit(self.tiles[tile_id-1], + ((x-self.engine.camera.x/self.engine.camera.zoom)*self.tile_size, + (y-self.engine.camera.y/self.engine.camera.zoom)*self.tile_size)) + + # Enfin, on redimensionne notre surface et on la colle sur la fenêtre principale + self.window.blit(transform.scale(rendered_surface, (rendered_surface_size[0]*self.engine.camera.zoom, rendered_surface_size[1]*self.engine.camera.zoom)), (0, 0))