Added flag at the end of the levels

This commit is contained in:
theo@manjaro 2021-11-23 11:11:13 +01:00
parent f3e0ee8fdc
commit 109e84dfbb
14 changed files with 589 additions and 40 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -1,6 +1,6 @@
{
"ogmoVersion": "3.4.0",
"width": 1392,
"width": 1536,
"height": 432,
"offsetX": 0,
"offsetY": 0,
@ -12,7 +12,7 @@
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 87,
"gridCellsX": 96,
"gridCellsY": 27,
"tileset": "base.png",
"dataCoords2D": [
@ -103,6 +103,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -192,6 +201,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -281,6 +299,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -370,6 +397,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -459,6 +495,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -548,6 +593,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -637,6 +691,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -726,6 +789,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -815,6 +887,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -904,6 +985,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -993,6 +1083,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[5, 4],
[6, 4],
[5, 4],
[6, 4],
[4, 4],
[-1],
[-1]
],
[
@ -1082,6 +1181,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[5, 5],
[6, 5],
[5, 5],
[6, 5],
[4, 5],
[-1],
[-1]
],
[
@ -1171,6 +1279,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[7, 4],
[8, 4],
[7, 4],
[8, 4],
[4, 5],
[-1],
[-1]
],
[
@ -1260,6 +1377,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[7, 5],
[8, 5],
[7, 5],
[8, 5],
[4, 5],
[-1],
[-1]
],
[
@ -1349,6 +1475,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[7, 4],
[8, 4],
[7, 4],
[8, 4],
[4, 5],
[-1],
[-1]
],
[
@ -1438,6 +1573,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[7, 5],
[8, 5],
[7, 5],
[8, 5],
[4, 5],
[-1],
[-1]
],
[
@ -1527,6 +1671,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 5],
[1, 5],
[7, 4],
[8, 4],
[4, 6],
[-1],
[-1]
],
[
@ -1616,6 +1769,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 6],
[1, 6],
[7, 5],
[8, 5],
[-1],
[-1],
[-1]
],
[
@ -1705,6 +1867,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 5],
[1, 5],
[-1],
[-1],
[-1]
],
[
@ -1794,6 +1965,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[0, 6],
[1, 6],
[-1],
[-1],
[-1]
],
[
@ -1883,6 +2063,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -1972,6 +2161,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2061,6 +2259,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2150,6 +2357,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2239,6 +2455,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2328,6 +2553,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2417,6 +2651,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
]
],
@ -2430,7 +2673,7 @@
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 87,
"gridCellsX": 96,
"gridCellsY": 27,
"tileset": "base.png",
"dataCoords2D": [
@ -2521,6 +2764,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2610,6 +2862,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2699,6 +2960,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2788,6 +3058,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2877,6 +3156,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -2966,6 +3254,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -3055,6 +3352,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -3144,6 +3450,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -3233,6 +3548,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -3322,6 +3646,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -3357,6 +3690,9 @@
[-1],
[-1],
[-1],
[6, 6],
[7, 6],
[8, 6],
[-1],
[-1],
[-1],
@ -3388,6 +3724,12 @@
[-1],
[-1],
[-1],
[9, 8],
[-1],
[9, 8],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
@ -3446,6 +3788,15 @@
[-1],
[-1],
[-1],
[6, 7],
[7, 7],
[8, 7],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
@ -3509,13 +3860,13 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[10, 6],
[9, 6],
[10, 6],
[9, 6],
[10, 6],
[9, 6],
[10, 6],
[-1],
[-1],
[-1],
@ -3534,11 +3885,11 @@
[15, 0],
[14, 0],
[15, 0],
[-1],
[-1],
[-1],
[-1],
[-1],
[9, 8],
[6, 8],
[7, 8],
[8, 8],
[9, 8],
[15, 0],
[14, 0],
[15, 0],
@ -3579,6 +3930,15 @@
[-1],
[-1],
[-1],
[9, 8],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
@ -3598,13 +3958,13 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[10, 7],
[9, 7],
[10, 7],
[9, 7],
[10, 7],
[9, 7],
[10, 7],
[-1],
[-1],
[-1],
@ -3678,6 +4038,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -3767,6 +4136,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -3856,6 +4234,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -3945,6 +4332,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4034,6 +4430,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4123,6 +4528,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4212,6 +4626,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4301,6 +4724,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4390,6 +4822,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4479,6 +4920,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4568,6 +5018,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4657,6 +5116,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4746,6 +5214,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
],
[
@ -4835,6 +5312,15 @@
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1],
[-1]
]
],
@ -4848,7 +5334,7 @@
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 87,
"gridCellsX": 96,
"gridCellsY": 27,
"entities": [
{"name": "Solid", "id": 25, "_eid": "17026310", "x": 16, "y": 224, "width": 208, "height": 80, "originX": 0, "originY": 0},
@ -4868,7 +5354,8 @@
{"name": "SemiSolid", "id": 40, "_eid": "59763689", "x": 832, "y": 208, "width": 64, "height": 16, "originX": 0, "originY": 0},
{"name": "SemiSolid", "id": 42, "_eid": "59763689", "x": 1040, "y": 176, "width": 80, "height": 16, "originX": 0, "originY": 0},
{"name": "SemiSolid", "id": 43, "_eid": "59763689", "x": 1184, "y": 208, "width": 80, "height": 16, "originX": 0, "originY": 0},
{"name": "Solid", "id": 44, "_eid": "17026310", "x": 832, "y": 336, "width": 16, "height": 32, "originX": 0, "originY": 0}
{"name": "Solid", "id": 44, "_eid": "17026310", "x": 832, "y": 336, "width": 16, "height": 32, "originX": 0, "originY": 0},
{"name": "SemiSolid", "id": 45, "_eid": "59763689", "x": 1424, "y": 160, "width": 80, "height": 16, "originX": 0, "originY": 0}
]
},
{
@ -4878,7 +5365,7 @@
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 87,
"gridCellsX": 96,
"gridCellsY": 27,
"entities": [
{"name": "Spawns", "id": 4, "_eid": "25816588", "x": 64, "y": 176, "originX": 0, "originY": 0}
@ -4891,7 +5378,7 @@
"offsetY": 0,
"gridCellWidth": 16,
"gridCellHeight": 16,
"gridCellsX": 87,
"gridCellsX": 96,
"gridCellsY": 27,
"entities": [
{
@ -4923,20 +5410,20 @@
},
{"name": "Balloon", "id": 36, "_eid": "16494694", "x": 1296, "y": 176, "originX": 0, "originY": 0},
{"name": "Balloon", "id": 37, "_eid": "16494694", "x": 1360, "y": 160, "originX": 0, "originY": 0},
{"name": "Balloon", "id": 38, "_eid": "16494694", "x": 1264, "y": 128, "originX": 0, "originY": 0},
{
"name": "WaterChange",
"id": 40,
"_eid": "48957583",
"x": 208,
"y": 208,
"x": 64,
"y": 176,
"originX": 0,
"originY": 0,
"nodes": [
{"x": 240, "y": 240}
{"x": 96, "y": 240}
],
"values": {"Speed": 1}
}
},
{"name": "End", "id": 42, "_eid": "65940624", "x": 1456, "y": 128, "originX": 0, "originY": 0}
]
}
]

View File

@ -0,0 +1,59 @@
from gamedata.objects.ingame.ennemies.ennemy import Ennemy
class EndFlag(Ennemy):
def __init__(self,*args):
super().__init__(*args)
self.blueflags = self.game.getSpriteDir("flags/blue/")
self.greenflags = self.game.getSpriteDir("flags/green/")
self.confettis = {}
self.confettiscolors = ["red","blue","yellow"]
for i in self.confettiscolors:
self.confettis[i] = self.game.getSpriteDir("particles/confetti/"+i+"/")
self.sprites = self.blueflags
self.depth = -1
self.spriteindex = 0
self.animspeed = 10
self.rect[2],self.rect[3] = self.sprites[0].get_size()
self.candie = False
self.canhit = False
self.endtimer = self.game.lib.Timer(3)
self.ended = False
def step(self):
super().step()
self.spriteindex+=self.animspeed*self.game.dt
if self.player:
if self.player.rect.colliderect(self.rect):
self.sprites = self.greenflags
self.player.canmove = False
if not self.ended:
self.ended = True
nb = 30
for i in range(nb):
color = self.game.lib.choice(self.confettiscolors)
sprites = self.confettis[color]
velx = self.game.lib.randint(-1,1)
vely = self.game.lib.randint(-5,-4)/3
steps = 5
offsetx = self.game.lib.randint(-10*steps,10*steps)/(steps)
offsety = self.game.lib.randint(-5,5)
self.game.addParticle(sprites,self.rect.center[0]+offsetx,self.rect.center[1]+offsety,velx=velx,vely=vely,modvely=0.05,fps=2)
if self.ended:
if self.endtimer.tick(self.game.dt):
self.game.scene = self.game.scenes.overworld
def draw(self):
sprite = self.sprites[int(self.spriteindex)%len(self.sprites)]
self.game.window.blit(sprite,[self.rect[0]-self.game.globals["camerax"],self.rect[1]-self.game.globals["cameray"]])

View File

@ -15,12 +15,12 @@ class Player(Movable):
self.spritefalling = game.sprite_lib["player/falling.png"] # Descending
self.spritehurt = game.sprite_lib["player/hurt.png"] # Being hurted
self.spritelanding = game.sprite_lib["player/landing.png"]
self.testsprites = self.game.getchars("Test")
self.landingtimer = 0
self.maxlandtime = 0.15
self.spriteindex = 0
self.flipx = False
self.animationspeed = 2.5
self.canmove = True
self.sprite = self.spritestill
collisionratio = 0.7
@ -116,6 +116,7 @@ class Player(Movable):
keys = self.game.inputs["keys"]
self.horspd = 0
if canmove:
if self.canmove:
self.horspd=(keys["right"]["pressed"]-keys["left"]["pressed"])*self.game.dt*self.speed
if self.landingtimer<=0:
@ -193,7 +194,7 @@ class Player(Movable):
self.jumped = False
if self.onground or self.leaptimer<0:
if 0<keys["up"]["timer"]<=3:
if self.canmove and 0<keys["up"]["timer"]<=3:
self.verspd= self.jump*self.gravityway
if self.leaptimer<0 and not self.onground:
self.verspd = -abs(self.verspd) # Small leap
@ -224,7 +225,7 @@ class Player(Movable):
self.verkb = min(0,self.verkb+self.reducekb)*self.game.dt
# Je passe en dessous des semi-plateformes
if keys["down"]["timer"]==1:
if self.canmove and keys["down"]["timer"]==1:
falled = False
if not self.checkcollisions(0,1,semi=False):
semi = self.checkcollisions(0,1,classic=False)
@ -277,7 +278,3 @@ class Player(Movable):
flipy = self.fastfall<0
sprite = self.game.pygame.transform.flip(self.sprite,self.flipx,flipy)
self.game.window.blit(sprite,[self.rect[0]-self.game.globals["camerax"]-self.spriteoffset,self.rect[1]-self.game.globals["cameray"]])
for i,spr in enumerate(self.testsprites):
if spr:
self.game.window.blit(spr,[self.rect[0]+i*9-self.game.globals["camerax"]-self.spriteoffset,self.rect[1]-self.game.globals["cameray"]])

View File

@ -4,6 +4,7 @@ from gamedata.objects.ingame.ennemies.crate import Crate
from gamedata.objects.ingame.ennemies.balloon import Balloon
from gamedata.objects.ingame.ennemies.spring import Spring
from gamedata.objects.ingame.ennemies.waterchange import WaterChange
from gamedata.objects.ingame.endflag import EndFlag
from gamedata.objects.levels import Levels
class TilesetRenderer(BaseObject):
@ -14,6 +15,7 @@ class TilesetRenderer(BaseObject):
self.tilew = 64
self.tileh = 64
self.depth = -2
self.level = game.levels_lib[mapfoldername]
self.reinit(self.level)
@ -70,7 +72,7 @@ class TilesetRenderer(BaseObject):
self.layers = []
self.spawns = []
spawnlists = {"Spawns":self.spawns}
ennemies = {"Robot":Robot,"Crate":Crate,"Balloon":Balloon,"Spring":Spring,"WaterChange":WaterChange,"Levels":Levels}
ennemies = {"Robot":Robot,"Crate":Crate,"Balloon":Balloon,"Spring":Spring,"WaterChange":WaterChange,"Levels":Levels,"End":EndFlag}
self.queue = [] # For spawning ennemies after beeing initialized
if "layers" in json.keys() and type(json["layers"]).__name__=="list":
solidlayer = False

View File

@ -20,6 +20,8 @@ def main(game):
def ingame(game,level="Level 2"):
game.scaleCamera(416,234)
game.globals["camerax"] = 0
game.globals["cameray"] = 0
game.gameloop.reinit()
tileset = TilesetRenderer(0,0,game,level)
game.gameloop.summon(tileset)
@ -30,6 +32,8 @@ def ingame(game,level="Level 2"):
def overworld(game):
game.scaleCamera(416,234)
game.globals["camerax"] = 0
game.globals["cameray"] = 0
game.gameloop.reinit()
tileset = TilesetRenderer(0,0,game,"Overworld")
game.gameloop.summon(tileset)