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
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)
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()
if self.ended:

View File

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