Ajout d'un fond

This commit is contained in:
theo@manjaro 2021-07-02 22:10:01 +02:00
parent 69c591aaae
commit 40cb691157
6 changed files with 469 additions and 307 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -34,6 +34,7 @@ class Game():
mapdico = {} mapdico = {}
mapdico["name"] = mapfolder.split(os.sep)[-1] mapdico["name"] = mapfolder.split(os.sep)[-1]
mapdico["cover"] = None mapdico["cover"] = None
mapdico["background"] = None
mapdico["data"] = None mapdico["data"] = None
mapdico["tilesets"] = {} mapdico["tilesets"] = {}
scanner = os.scandir(path=mapfolder) scanner = os.scandir(path=mapfolder)
@ -43,6 +44,8 @@ class Game():
if name.endswith(".png"): if name.endswith(".png"):
if name=="cover.png": if name=="cover.png":
mapdico["cover"] = pygame.image.load(i.path) mapdico["cover"] = pygame.image.load(i.path)
elif name=="background.png":
mapdico["background"] = pygame.image.load(i.path)
else: else:
mapdico["tilesets"][i.name] = pygame.image.load(i.path) mapdico["tilesets"][i.name] = pygame.image.load(i.path)
except: except:

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,7 +1,7 @@
{ {
"ogmoVersion": "3.4.0", "ogmoVersion": "3.4.0",
"width": 512, "width": 592,
"height": 240, "height": 272,
"offsetX": 0, "offsetX": 0,
"offsetY": 0, "offsetY": 0,
"layers": [ "layers": [
@ -12,8 +12,8 @@
"offsetY": 0, "offsetY": 0,
"gridCellWidth": 16, "gridCellWidth": 16,
"gridCellHeight": 16, "gridCellHeight": 16,
"gridCellsX": 32, "gridCellsX": 37,
"gridCellsY": 15, "gridCellsY": 17,
"tileset": "base.png", "tileset": "base.png",
"dataCoords2D": [ "dataCoords2D": [
[ [
@ -48,6 +48,11 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1] [-1]
], ],
[ [
@ -69,6 +74,11 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[12, 6],
[13, 6],
[-1],
[-1],
[-1],
[-1], [-1],
[-1], [-1],
[-1], [-1],
@ -103,37 +113,8 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1], [12, 7],
[-1], [13, 7],
[-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],
@ -153,91 +134,6 @@
[-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],
@ -252,9 +148,74 @@
[-1], [-1],
[-1], [-1],
[0, 0], [0, 0],
[2, 0] [1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[2, 0],
[-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],
[5, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[3, 1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
[-1],
[-1],
[-1],
[-1],
[-1], [-1],
[-1], [-1],
[-1], [-1],
@ -263,6 +224,156 @@
[-1], [-1],
[-1], [-1],
[0, 0], [0, 0],
[1, 0],
[5, 2],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[3, 2],
[1, 0],
[2, 0],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[3, 0],
[1, 2],
[1, 2],
[1, 2],
[1, 2],
[1, 2],
[1, 2],
[5, 0],
[1, 1],
[1, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 2],
[1, 2],
[1, 2],
[1, 2],
[2, 2],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 2],
[1, 2],
[1, 2],
[1, 2],
[2, 2],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
[-1],
[-1],
[-1],
[9, 7],
[-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],
[8, 7],
[-1],
[-1],
[9, 7],
[-1]
],
[
[0, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[2, 0], [2, 0],
[-1], [-1],
[-1], [-1],
@ -282,12 +393,214 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 0], [0, 0],
[1, 0], [1, 0],
[1, 0], [1, 0],
[5, 2], [1, 0],
[1, 0],
[1, 0],
[2, 0]
],
[
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[-1],
[-1],
[10, 6],
[11, 6],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[10, 6],
[11, 6],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1] [2, 1]
], ],
[
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[8, 7],
[-1],
[10, 7],
[11, 7],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[10, 7],
[11, 7],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1]
],
[
[0, 2],
[1, 2],
[5, 0],
[1, 1],
[1, 1],
[1, 1],
[3, 2],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[2, 0],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[5, 2],
[1, 1],
[1, 1],
[1, 1],
[3, 0],
[1, 2],
[2, 2]
],
[
[-1],
[-1],
[0, 2],
[1, 2],
[1, 2],
[5, 0],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[3, 0],
[1, 2],
[1, 2],
[2, 2],
[-1],
[-1]
],
[
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 2],
[1, 2],
[1, 2],
[1, 2],
[5, 0],
[1, 1],
[1, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 1],
[1, 1],
[1, 1],
[3, 0],
[1, 2],
[1, 2],
[1, 2],
[2, 2],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[ [
[-1], [-1],
[-1], [-1],
@ -296,7 +609,12 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1],
[-1],
[0, 2], [0, 2],
[1, 2],
[1, 2],
[1, 2],
[2, 2], [2, 2],
[-1], [-1],
[-1], [-1],
@ -308,25 +626,22 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[0, 2],
[1, 2],
[1, 2],
[2, 2],
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1], [-1],
[0, 0], [-1],
[1, 0], [-1],
[5, 2], [-1]
[1, 1],
[1, 1],
[1, 1],
[2, 1]
], ],
[ [
[-1], [-1],
[0, 0],
[1, 0],
[2, 0],
[-1], [-1],
[-1], [-1],
[-1], [-1],
@ -346,21 +661,6 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[0, 0],
[1, 0],
[5, 2],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1]
],
[
[-1],
[0, 1],
[1, 1],
[2, 1],
[-1], [-1],
[-1], [-1],
[-1], [-1],
@ -369,32 +669,6 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[0, 0],
[1, 0],
[1, 0],
[1, 0],
[2, 0],
[-1],
[-1],
[-1],
[0, 0],
[1, 0],
[1, 0],
[5, 2],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1]
],
[
[-1],
[0, 1],
[1, 1],
[2, 1],
[-1], [-1],
[-1], [-1],
[-1], [-1],
@ -403,128 +677,7 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[5, 1], [-1]
[1, 1],
[1, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1]
],
[
[-1],
[0, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[5, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1]
],
[
[-1],
[0, 1],
[1, 1],
[2, 1],
[-1],
[-1],
[0, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[1, 0],
[5, 2],
[1, 1],
[1, 1],
[6, 0],
[7, 0],
[8, 0],
[-1],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1]
],
[
[-1],
[0, 1],
[1, 1],
[6, 0],
[8, 0],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[6, 0],
[11, 2],
[7, 1],
[8, 1],
[-1],
[-1],
[0, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[1, 1],
[2, 1]
] ]
], ],
"exportMode": 1, "exportMode": 1,
@ -537,19 +690,20 @@
"offsetY": 0, "offsetY": 0,
"gridCellWidth": 16, "gridCellWidth": 16,
"gridCellHeight": 16, "gridCellHeight": 16,
"gridCellsX": 32, "gridCellsX": 37,
"gridCellsY": 15, "gridCellsY": 17,
"entities": [ "entities": [
{"name": "Solid", "id": 1, "_eid": "17026310", "x": 16, "y": 144, "width": 48, "height": 96, "originX": 0, "originY": 0}, {"name": "Solid", "id": 12, "_eid": "17026310", "x": 208, "y": 48, "width": 192, "height": 64, "originX": 0, "originY": 0},
{"name": "Solid", "id": 2, "_eid": "17026310", "x": 112, "y": 112, "width": 32, "height": 32, "originX": 0, "originY": 0}, {"name": "Solid", "id": 13, "_eid": "17026310", "x": 176, "y": 80, "width": 80, "height": 48, "originX": 0, "originY": 0},
{"name": "Solid", "id": 3, "_eid": "17026310", "x": 192, "y": 160, "width": 80, "height": 48, "originX": 0, "originY": 0}, {"name": "Solid", "id": 14, "_eid": "17026310", "x": 352, "y": 80, "width": 80, "height": 48, "originX": 0, "originY": 0},
{"name": "Solid", "id": 4, "_eid": "17026310", "x": 96, "y": 208, "width": 192, "height": 32, "originX": 0, "originY": 0}, {"name": "Solid", "id": 15, "_eid": "17026310", "x": 480, "y": 144, "width": 112, "height": 64, "originX": 0, "originY": 0},
{"name": "Solid", "id": 6, "_eid": "17026310", "x": 64, "y": 224, "width": 16, "height": 16, "originX": 0, "originY": 0}, {"name": "Solid", "id": 16, "_eid": "17026310", "x": 384, "y": 192, "width": 64, "height": 64, "originX": 0, "originY": 0},
{"name": "Solid", "id": 7, "_eid": "17026310", "x": 320, "y": 160, "width": 48, "height": 80, "originX": 0, "originY": 0}, {"name": "Solid", "id": 17, "_eid": "17026310", "x": 448, "y": 192, "width": 64, "height": 48, "originX": 0, "originY": 0},
{"name": "Solid", "id": 8, "_eid": "17026310", "x": 368, "y": 144, "width": 32, "height": 96, "originX": 0, "originY": 0}, {"name": "Solid", "id": 18, "_eid": "17026310", "x": 512, "y": 192, "width": 48, "height": 32, "originX": 0, "originY": 0},
{"name": "Solid", "id": 9, "_eid": "17026310", "x": 400, "y": 128, "width": 80, "height": 112, "originX": 0, "originY": 0}, {"name": "Solid", "id": 19, "_eid": "17026310", "x": 0, "y": 144, "width": 112, "height": 64, "originX": 0, "originY": 0},
{"name": "Solid", "id": 10, "_eid": "17026310", "x": 432, "y": 112, "width": 48, "height": 16, "originX": 0, "originY": 0}, {"name": "Solid", "id": 20, "_eid": "17026310", "x": 144, "y": 192, "width": 80, "height": 64, "originX": 0, "originY": 0},
{"name": "Solid", "id": 11, "_eid": "17026310", "x": 480, "y": 96, "width": 32, "height": 144, "originX": 0, "originY": 0} {"name": "Solid", "id": 21, "_eid": "17026310", "x": 80, "y": 192, "width": 64, "height": 48, "originX": 0, "originY": 0},
{"name": "Solid", "id": 22, "_eid": "17026310", "x": 32, "y": 208, "width": 48, "height": 16, "originX": 0, "originY": 0}
] ]
} }
] ]

View File

@ -12,7 +12,12 @@ class TilesetRenderer(BaseObject):
self.level = game.levels_lib[mapfoldername] self.level = game.levels_lib[mapfoldername]
self.reinit(self.level) self.reinit(self.level)
self.bg = game.sprite_lib["fallbackground.png"]
if self.level["background"]:
self.bg = self.level["background"]
def draw(self): def draw(self):
self.game.window.blit(self.game.pygame.transform.scale(self.bg,(self.game.globals["cameraw"],self.game.globals["camerah"])),[0,0])
for layer in self.layers: for layer in self.layers:
self.game.window.blit(layer["surface"],(layer["offsets"][0]-self.game.globals["camerax"],layer["offsets"][1]-self.game.globals["cameray"])) self.game.window.blit(layer["surface"],(layer["offsets"][0]-self.game.globals["camerax"],layer["offsets"][1]-self.game.globals["cameray"]))