Ajout de spawnpoints
This commit is contained in:
parent
0d27a09e0c
commit
1a435b80fb
@ -26,7 +26,7 @@ class TilesetRenderer(BaseObject):
|
|||||||
name = level["name"]
|
name = level["name"]
|
||||||
self.rects = []
|
self.rects = []
|
||||||
self.layers = []
|
self.layers = []
|
||||||
self.spawns = []
|
self.spawns = [[self.game.DISPLAY_WIDTH//2,self.game.DISPLAY_HEIGHT//2]] # Valeur par défaut
|
||||||
if "layers" in json.keys() and type(json["layers"]).__name__=="list":
|
if "layers" in json.keys() and type(json["layers"]).__name__=="list":
|
||||||
solidlayer = False
|
solidlayer = False
|
||||||
for layer in json["layers"]:
|
for layer in json["layers"]:
|
||||||
@ -35,6 +35,8 @@ class TilesetRenderer(BaseObject):
|
|||||||
if layer["name"] == "Solids" and "entities" in layer.keys() : # Je trouve les collisions
|
if layer["name"] == "Solids" and "entities" in layer.keys() : # Je trouve les collisions
|
||||||
solidlayer = layer
|
solidlayer = layer
|
||||||
elif layer["name"] == "Spawns" and "entities" in layer.keys() : # Je trouve les spawns
|
elif layer["name"] == "Spawns" and "entities" in layer.keys() : # Je trouve les spawns
|
||||||
|
if len(layer["entities"])>0:
|
||||||
|
self.spawns = [] # J'enlève la valeur par défaut
|
||||||
for entity in layer["entities"]:
|
for entity in layer["entities"]:
|
||||||
x,y = entity["x"],entity["y"]
|
x,y = entity["x"],entity["y"]
|
||||||
w,h = layer["gridCellWidth"],layer["gridCellHeight"]
|
w,h = layer["gridCellWidth"],layer["gridCellHeight"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user