Progression on the map

This commit is contained in:
theo@manjaro 2021-11-23 18:08:17 +01:00
parent 564a5a664c
commit c5848a12ca
2 changed files with 14 additions and 5 deletions

View File

@ -51,7 +51,9 @@ class EndFlag(Ennemy):
steps = 5 steps = 5
offsetx = self.game.lib.randint(-10*steps,10*steps)/(steps) offsetx = self.game.lib.randint(-10*steps,10*steps)/(steps)
offsety = self.game.lib.randint(-5,5) 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) self.game.addParticle(sprites,self.rect.center[0]+offsetx,self.rect.center[1]+offsety,velx=velx,vely=vely,modvely=0.1,fps=2)
if not self.game.globals["levelname"] in self.game.globals["finishedlevels"]:
self.game.globals["finishedlevels"].append(self.game.globals["levelname"])
self.sfx.play() self.sfx.play()
if self.ended: if self.ended:

View File

@ -9,12 +9,14 @@ class Levels(BaseObject):
self.nodes = nodes self.nodes = nodes
self.customvalues = customvalues self.customvalues = customvalues
self.launched = False
self.blueflags = self.game.getSpriteDir("flags/blue/") self.blueflags = self.game.getSpriteDir("flags/blue/")
self.greenflags= self.game.getSpriteDir("flags/green/") self.greenflags= self.game.getSpriteDir("flags/green/")
self.flagbase = self.game.sprite_lib["flags/base.png"] self.flagbase = self.game.sprite_lib["flags/base.png"]
self.playerwalking = self.game.getSpriteDir("player/walking/") self.playerwalking = self.game.getSpriteDir("player/walking/")
self.playerstill = self.game.sprite_lib["player/still.png"] self.playerstill = self.game.sprite_lib["player/still.png"]
self.flip = False self.flip = False
self.moving = False self.moving = False
self.spriteindex = 0 self.spriteindex = 0
@ -58,8 +60,9 @@ class Levels(BaseObject):
for i in range(len(self.flagsindex)): for i in range(len(self.flagsindex)):
self.flagsindex[i]+=self.animspeed*self.game.dt self.flagsindex[i]+=self.animspeed*self.game.dt
if not self.moving: if not self.moving and not self.launched:
if self.game.inputs["keys"]["right"]["timer"]>0: if self.game.inputs["keys"]["right"]["timer"]>0:
if "Level "+str(self.cursor+1) in self.game.globals["finishedlevels"]:
self.cursor+=1 self.cursor+=1
self.flip = False self.flip = False
if self.game.inputs["keys"]["left"]["timer"]>0: if self.game.inputs["keys"]["left"]["timer"]>0:
@ -68,6 +71,8 @@ class Levels(BaseObject):
if self.game.inputs["keys"]["up"]["timer"]==1: if self.game.inputs["keys"]["up"]["timer"]==1:
# Launch the level # Launch the level
t = Transition(self.game,level = "Level "+str(self.cursor+1)) t = Transition(self.game,level = "Level "+str(self.cursor+1))
self.launched = True
self.game.globals["levelname"] = "Level "+str(self.cursor+1)
self.game.gameloop.summon(t) self.game.gameloop.summon(t)
self.cursor = min(self.cursor,len(self.nodes)-1) self.cursor = min(self.cursor,len(self.nodes)-1)
self.cursor = max(0,self.cursor) self.cursor = max(0,self.cursor)
@ -90,6 +95,8 @@ class Levels(BaseObject):
def draw(self): def draw(self):
for i,v in enumerate(self.nodes): # Draw flags for i,v in enumerate(self.nodes): # Draw flags
sprites = self.blueflags sprites = self.blueflags
if "Level "+str(i+1) in self.game.globals["finishedlevels"]:
sprites = self.greenflags
sprite = sprites[int(self.flagsindex[i])%len(sprites)] sprite = sprites[int(self.flagsindex[i])%len(sprites)]
x = v["x"]-sprite.get_width()/2-self.game.globals["camerax"]+8 x = v["x"]-sprite.get_width()/2-self.game.globals["camerax"]+8
y = v["y"]-sprite.get_height()-self.game.globals["cameray"] y = v["y"]-sprite.get_height()-self.game.globals["cameray"]