Returning to overworld takes you to the current level ( instead of the

first )
This commit is contained in:
theo@manjaro 2021-11-26 15:39:15 +01:00
parent 1751baf2db
commit 48c083d3ff
1 changed files with 9 additions and 3 deletions

View File

@ -51,12 +51,15 @@ class Levels(BaseObject):
self.names.append(None)
self.animspeed = 7
self.cursor = 0 # Which level is selected
self.playerx = self.nodes[0]["x"]
self.playery = self.nodes[1]["y"]
self.cursor = 0
if "levelname" in self.game.globals.keys():
self.cursor = self.game.globals["levelname"] # Which level is selected
self.playerx = self.nodes[self.cursor]["x"]
self.playery = self.nodes[self.cursor]["y"]
self.tileset = self.game.gameloop.findname("TilesetRenderer")[0]
self.maxwidth = self.tileset.layers[0]["surface"].get_width()
self.movecamera()
def step(self):
for i in range(len(self.flagsindex)):
@ -97,6 +100,9 @@ class Levels(BaseObject):
self.playerx += speedx*4*self.game.dt
self.playery += speedy*4*self.game.dt
self.movecamera()
def movecamera(self):
self.game.globals["camerax"] = self.playerx-self.game.globals["cameraw"]/2
self.game.globals["camerax"] = max(0,self.game.globals["camerax"])
self.game.globals["camerax"] = min(self.maxwidth-self.game.globals["cameraw"],self.game.globals["camerax"])