Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 06fee890 authored by PEDERSEN Ny Aina's avatar PEDERSEN Ny Aina
Browse files

Move tileset to optional argument

- Add full path to the default tileset if not given
- Fix default argument in create_map
- Add default tileset constant in `constants.py`
parent dc53c772
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@ TILE_SIZE = 32
UPDATE_RATE = 5
SPRITE_SPEED = 2
TILESET = "[Base]BaseChip_pipo.json"
Direction = Enum("Direction", "DOWN LEFT RIGHT UP")
SPRITE_FRAME = {
......
......@@ -2,17 +2,24 @@
Map edit/creation tools.
"""
from os.path import dirname
from collections import defaultdict
import xml.etree.ElementTree as ET
from typing import Optional
from level.arcade_utils.constants import TILESET
BG_TILE = 2
NOTHING = 0
# pylint: disable=too-many-locals
def create_map(map_dest: str, tileset_path: str, metadata: Optional[dict[str, str]]):
def create_map(
map_dest: str,
tileset_path: Optional[str] = None,
metadata: Optional[dict[str, str]] = None,
) -> None:
"""
Create a xml according to some metadata.
This allows you to create a template that you could edit easily with the
......@@ -22,7 +29,11 @@ def create_map(map_dest: str, tileset_path: str, metadata: Optional[dict[str, st
:param tileset_map: Path to the tileset.
:param metadata_dict: The dictionnary that describes the level.
"""
# Default arguments
metadata = metadata or {}
tileset_path = tileset_path or f"{dirname(__file__)}/resources/tiles/{TILESET}"
# Using defaultdict to avoid checks or KeyError
map_info = defaultdict(lambda: None, metadata)
# Reading variables from the metadata dictionnary
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment