Exemple #1
0
 def update(self):
     self.space.step(1 / 120.0)
     if self.victory() and self.finished == False:
         Gui.create_popup(
             self.window, self.batch, "Congratulation, you finished the level", on_escape=self.window.switch_level
         )
         self.finished = True
     for element in self.elements:
         element.update()
     for area in self.areas:
         area.update()
Exemple #2
0
 def update(self):
     self.space.step(1 / 120.0)
     if self.victory() and self.finished == False:
         Gui.create_popup(self.window,
                          self.batch,
                          "Congratulation, you finished the level",
                          on_escape=self.window.switch_level)
         self.finished = True
     for element in self.elements:
         element.update()
     for area in self.areas:
         area.update()
Exemple #3
0
 def switch_level(self, level=None):
     """ Switch to level, if level=None switch to next level"""
     if self.level is not None:
         self.level.delete()
     if level is None:
         level = self.levels.next_level()
         if level is None:
             Gui.create_popup(self, self.batch, "Congratulation you have won the game!",
                          on_escape=self.close)
         else:
             self.run_level(level)
     else:
         self.run_level(level)
Exemple #4
0
 def switch_level(self, level=None):
     """ Switch to level, if level=None switch to next level"""
     if self.level is not None:
         self.level.delete()
     if level is None:
         level = self.levels.next_level()
         if level is None:
             Gui.create_popup(self, self.batch, "Congratulation you have won the game!",
                          on_escape=self.close)
         else:
             self.run_level(level)
     else:
         self.run_level(level)
Exemple #5
0
    def on_key_press(self, symbol, modifiers):
        if symbol == pyglet.window.key.M:
            import objgraph

            objgraph.show_growth()
            m = objgraph.by_type("Molecule")
            print("nr of Molecule:", len(m))
            # for n in m:
            #    objgraph.show_backrefs(n)
        elif symbol == pyglet.window.key.ESCAPE:
            self.window.close()
        elif symbol == pyglet.window.key.S:
            Gui.create_popup(self.window, self.batch, "Skipping level, Cheater!", on_escape=self.window.switch_level)
        elif symbol == pyglet.window.key.R:
            self.window.reset_level()
        elif symbol == pyglet.window.key.D:
            self.window.DEBUG_GRAPHICS = not self.window.DEBUG_GRAPHICS
Exemple #6
0
 def on_key_press(self, symbol, modifiers):
     if symbol == pyglet.window.key.M:
         import objgraph
         objgraph.show_growth()
         m = objgraph.by_type("Molecule")
         print("nr of Molecule:", len(m))
         #for n in m:
         #    objgraph.show_backrefs(n)
     elif symbol == pyglet.window.key.ESCAPE:
         self.window.close()
     elif symbol == pyglet.window.key.S:
         Gui.create_popup(self.window,
                          self.batch,
                          "Skipping level, Cheater!",
                          on_escape=self.window.switch_level)
     elif symbol == pyglet.window.key.R:
         self.window.reset_level()
     elif symbol == pyglet.window.key.D:
         self.window.DEBUG_GRAPHICS = not self.window.DEBUG_GRAPHICS
     elif symbol == pyglet.window.key.H:
         hint = self.window.level.cml.hint
         Gui.create_popup(self.window, self.batch, hint)