Esempio n. 1
0
 def on_key_press(self, symbol, modifier):
     '''Add the pressed key to the list to be later used in updateCameraPosition'''
     if symbol not in self.pressedKeys:
         self.pressedKeys.append(symbol)
     if symbol == key.ESCAPE:  # EXIT APPLICATION
         from pyglet import app
         app.exit()
Esempio n. 2
0
 def on_mouse_press(self, x, y, button, modifiers):
     if self.active and self.world.state == Resources.states[
             self.curr_state]:
         if button == mouse.LEFT or button == 0:
             if self.hit_test(x, y):
                 self.fx.play()
                 exit()
Esempio n. 3
0
 def on_key_press(self, symbol, modifiers):
     if symbol == key.ESCAPE:
         app.exit()
     elif symbol == key.RIGHT:
         if self.paused:
             self._do_simulate(1)
         else:
             self.toggle_pause()
     elif symbol == key.SPACE:
         self.toggle_pause()
     else:
         self.groups.on_key_press(symbol, modifiers)
Esempio n. 4
0
File: main.py Progetto: Tythos/hypyr
	def on_key_press(self, symbol, modifiers):
		k = window.key
		if symbol == k.R:
			rot = linal.Vec3()
		elif symbol == k.ESCAPE or symbol == k.Q:
			app.exit()
			return event.EVENT_HANDLED
		elif symbol == k.A:
			self.camera.sphericalRotation(-0.1, 0.)
			particles.Sprite.isFirstPassRender = True
		elif symbol == k.S:
			self.camera.sphericalRotation(0., -0.1)
		elif symbol == k.W:
			self.camera.sphericalRotation(0., 0.1)
		elif symbol == k.D:
			self.camera.sphericalRotation(0.1, 0.)
		elif symbol == k.EQUAL:
			self.camera.zoom(0.9)
		elif symbol == k.MINUS:
			self.camera.zoom(1.1)
Esempio n. 5
0
def on_window_close(win):
    app.exit()
    asd('exit')
Esempio n. 6
0
 def on_quit(self):
     app.exit()
Esempio n. 7
0
 def on_mouse_press(self, x, y, button, modifiers):
     if self.active and self.world.state == Resources.states[self.curr_state]:
         if button == mouse.LEFT or button == 0:
             if self.hit_test(x,y):
                 self.fx.play()
                 exit()
Esempio n. 8
0
 def on_quit( self ):
     exit()
Esempio n. 9
0
 def quit(self):
         '''Shutdown the platform specific stuff'''
         print("GUIToolkit.quit() called")
         app.exit()
Esempio n. 10
0
def quit():
    window.close()
    app.exit() 
Esempio n. 11
0
def on_key_press(symbol, modifiers):
  if (symbol == 65307):
    app.exit()
  else:
    print symbol
Esempio n. 12
0
 def on_quit(self):
     # It seems odd that I need a function that literally just calls the exit function but...
     exit()
Esempio n. 13
0
        glPopMatrix()

    def line(self, x1=0, y1=0, x2=0, y2=0, pos1=None, pos2=None):
        ''' Draw a single line. Either with xy values, or two position (that
            contain x and y values). Uses existing colour and stroke values. '''
        if pos1 is not None and pos2 is not None:
            x1, y1, x2, y2 = pos1[0], pos1[1], pos2[0], pos2[1]
        glBegin(GL_LINES)
        glVertex2f(x1, y1)
        glVertex2f(x2, y2)
        glEnd()


if __name__ == '__main__':

    with open("./logs/spike11Results.txt", 'w') as file:
        file.write(
            "Results of wins on 100 maps between Rando and Simple Strategic\n")

    x = 0
    while x < 100:
        gamestate = open('./maps/map{0}.txt'.format(x)).read()
        players = ['Simple_Strategic', 'Rando']
        window = PlanetWarsWindow(gamestate=gamestate,
                                  players=players,
                                  max_game_length=5000)
        app.run()
        app.exit()
        #window.game.logger.flush()
        x = x + 1
 def on_quit( self ):
     exit()
Esempio n. 15
0
 def on_quit(self):
     # It seems odd that I need a function that literally just calls the exit function but...
     exit()
Esempio n. 16
0
 def update(self, dt):
     super().update(dt)
     self.t += 1
     # Animate background:
     self.background.x = -15 + 11*sin(0.021*self.t)
     self.background.y = -15 + 10*sin(0.024*self.t)
     self.background2.opacity = 70 + 60*sin(0.01*self.t)
     # Manage input:
     if self.menu is 0: # Main menu
         if KEYS['up'] in self.keys and self.keys[KEYS['up']] is KEY_PRESSED and self.main_index > 0:
             self.main_index -= 1
         elif KEYS['down'] in self.keys and self.keys[KEYS['down']] is KEY_PRESSED and self.main_index < 4:
             self.main_index += 1
         elif KEYS['shoot'] in self.keys and self.keys[KEYS['shoot']] is KEY_PRESSED:
             if self.main_index is 0: # Start
                 self.window.change_scene(SceneGame)
             if self.main_index is 1: # Practice
                 self.menu = 2
             if self.main_index is 2: # Scores
                 pass
             if self.main_index is 3: # Config
                 self.menu = 4
             if self.main_index is 4: # Exit
                 app.exit()
     if self.menu is 2: # Practice menu
         if KEYS['up'] in self.keys and self.keys[KEYS['up']] is KEY_PRESSED and self.practice_index > 0:
             self.practice_index -= 1
         elif KEYS['down'] in self.keys and self.keys[KEYS['down']] is KEY_PRESSED and self.practice_index < 4:
             self.practice_index += 1
         elif KEYS['bomb'] in self.keys and self.keys[KEYS['bomb']] is KEY_PRESSED:
             self.menu = 0
             self.practice_index = 0
     if self.menu is 4: # Config menu
         if KEYS['up'] in self.keys and self.keys[KEYS['up']] is KEY_PRESSED and self.config_index > 0:
             self.config_index -= 1
         elif KEYS['down'] in self.keys and self.keys[KEYS['down']] is KEY_PRESSED and self.config_index < 2:
             self.config_index += 1
         elif KEYS['bomb'] in self.keys and self.keys[KEYS['bomb']] is KEY_PRESSED:
             self.menu = 0
             self.config_index = 0
     # Animate labels:
     for i in range(len(self.main_options)):
         l = self.main_options[i]
         s = self.main_options_shadow[i]
         if self.menu is 0 and l.color[3] < 255:
             l.color = (l.color[0], l.color[1], l.color[2], l.color[3] + 5)
         if self.menu is 0 and s.color[3] < 100:
             s.color = (s.color[0], s.color[1], s.color[2], s.color[3] + 5)
         if self.menu is not 0 and l.color[3] > 110:
             l.color = (l.color[0], l.color[1], l.color[2], l.color[3] - 5)
         if self.menu is not 0 and s.color[3] > 40:
             s.color = (s.color[0], s.color[1], s.color[2], s.color[3] - 5)
         if l.x < 210 and self.main_index == i:
             l.x += 1
         elif l.x > 200 and self.main_index != i:
             l.x -= 1
         if s.x > 189 and self.main_index == i:
             s.x -= 1
         elif s.x < 199 and self.main_index != i:
             s.x += 1
     for i in range(len(self.practice_options)):
         l = self.practice_options[i]
         s = self.practice_options_shadow[i]
         if self.menu is 2 and l.color[3] < 255:
             l.color = (l.color[0], l.color[1], l.color[2], l.color[3] + 5)
         if self.menu is 2 and s.color[3] < 100:
             s.color = (s.color[0], s.color[1], s.color[2], s.color[3] + 5)
         if self.menu is not 2 and l.color[3] > 0:
             l.color = (l.color[0], l.color[1], l.color[2], l.color[3] - 5)
         if self.menu is not 2 and s.color[3] > 0:
             s.color = (s.color[0], s.color[1], s.color[2], s.color[3] - 5)
         if l.x < 510 and self.practice_index == i:
             l.x += 1
         elif l.x > 500 and self.practice_index != i:
             l.x -= 1
         if s.x > 489 and self.practice_index == i:
             s.x -= 1
         elif s.x < 499 and self.practice_index != i:
             s.x += 1
     for i in range(len(self.config_options)):
         l = self.config_options[i]
         s = self.config_options_shadow[i]
         if self.menu is 4 and l.color[3] < 255:
             l.color = (l.color[0], l.color[1], l.color[2], l.color[3] + 5)
         if self.menu is 4 and s.color[3] < 100:
             s.color = (s.color[0], s.color[1], s.color[2], s.color[3] + 5)
         if self.menu is not 4 and l.color[3] > 0:
             l.color = (l.color[0], l.color[1], l.color[2], l.color[3] - 5)
         if self.menu is not 4 and s.color[3] > 0:
             s.color = (s.color[0], s.color[1], s.color[2], s.color[3] - 5)
         if l.x < 510 and self.config_index == i:
             l.x += 1
         elif l.x > 500 and self.config_index != i:
             l.x -= 1
         if s.x > 489 and self.config_index == i:
             s.x -= 1
         elif s.x < 499 and self.config_index != i:
             s.x += 1
Esempio n. 17
0
 def on_key_press(self, k, modifiers):
     if key.SPACE == k:
         self.start()
     elif key.ESCAPE == k:
         exit()
Esempio n. 18
0
 def _end_pyglet(_):
     app.exit()
Esempio n. 19
0
def exit_callback(dt):
    if player.playing != True:
        app.exit()