def on_key_down(self, unicode, key, mod): if key == K_g: # Toggle grid. self.show_grid = not self.show_grid elif key == K_ESCAPE: context.pop() elif key in (K_PLUS,K_EQUALS): # Resize world using smaller cell size. Minimum size is # max(*Thing.size). cell_size = self.cell_size * 3/4 if cell_size < max(*GeomBehavior.size): cell_size = max(*GeomBehavior.size) self.cell_size = cell_size self.make_space() for thing in self.things: State.world.add(thing) elif key == K_MINUS: # Resize world using larger cell size. Maximum size is # max(*State.world.rect.size). cell_size = self.cell_size * 4/3 if cell_size > max(*State.world.rect.size): cell_size = max(*State.world.rect.size) self.cell_size = cell_size self.make_space() for thing in self.things: State.world.add(thing)
def on_key_down(self, unicode, key, mod): # Turn on key-presses. if key == K_g: State.show_grid = not State.show_grid elif key == K_l: State.show_labels = not State.show_labels elif key == K_ESCAPE: context.pop()
def on_key_down(self, unicode, key, mod): if key == K_DOWN: self.movey += self.scroll_speed elif key == K_UP: self.movey += -self.scroll_speed elif key == K_RIGHT: self.movex += self.scroll_speed elif key == K_LEFT: self.movex += -self.scroll_speed elif key in (K_EQUALS,K_PLUS): self._add_pick() elif key == K_MINUS: self._remove_pick() elif key == K_ESCAPE: context.pop()
def on_key_down(self, unicode, key, mod): if key == K_DOWN: self.movey += State.speed elif key == K_UP: self.movey += -State.speed elif key == K_RIGHT: self.movex += State.speed elif key == K_LEFT: self.movex += -State.speed elif key in (COLLAPSE_KEYS): clevel = key - K_0 for mh in State.map.handlers.values(): mh.collapse(clevel) elif key == K_ESCAPE: context.pop()
def on_key_down(self, unicode, key, mod): # Turn on key-presses. if key == K_DOWN: self.move_y = 1 * State.speed elif key == K_UP: self.move_y = -1 * State.speed elif key == K_RIGHT: self.move_x = 1 * State.speed elif key == K_LEFT: self.move_x = -1 * State.speed elif key == K_ESCAPE: context.pop()
def on_key_down(self, unicode, key, mod): if key == K_g: # Toggle grid. self.show_grid = not self.show_grid elif key == K_ESCAPE: context.pop() elif key in (K_PLUS,K_EQUALS): self.inc_cells() print State.world self.stop_auto_tune() elif key == K_MINUS: self.dec_cells() print State.world self.stop_auto_tune() elif key == K_SPACE: self.inc_things() elif key == K_BACKSPACE: self.dec_things()
def on_key_down(self, unicode, key, mod): # Turn on key-presses. if key == K_DOWN: self.move_y = 1 * State.speed elif key == K_UP: self.move_y = -1 * State.speed elif key == K_RIGHT: self.move_x = 1 * State.speed elif key == K_LEFT: self.move_x = -1 * State.speed elif key == K_h: State.hud.visible = not State.hud.visible elif key == K_TAB: # Select the next state name and and restore it. State.restore(self.next_state[State.name]) State.screen.clear() elif key == K_ESCAPE: context.pop()
def on_key_down(self, unicode, key, mod): # Turn on key-presses. if key == K_g: State.show_grid = not State.show_grid elif key == K_l: State.show_labels = not State.show_labels elif K_0 <= key <= K_9+1: if key == K_0: n = 10 else: n = key - K_0 if n == self.collapse: return self.map = TiledMap(self.map_file_name, (n,n)) State.world.rect = self.map.rect.copy() State.map = self.map self.collapse = n self.grid_cache.clear() elif key == K_ESCAPE: context.pop()
def on_key_down(self, unicode, key, mod): # Turn on key-presses. if key == K_DOWN: self.move_y = 1 * State.speed elif key == K_UP: self.move_y = -1 * State.speed elif key == K_RIGHT: self.move_x = 1 * State.speed elif key == K_LEFT: self.move_x = -1 * State.speed elif key == K_TAB: ## Select the next state name and and restore it. ## Note that Camera class has a state_restored() method which is ## called by State.restore(). If it did not, you would see strange ## video behavior when swapping in a camera with stale innards. You ## may need to do this for your own classes if you integrate them ## with State.save() and State.restore(). State.restore(self.next_state[State.name]) State.screen.clear() elif key == K_ESCAPE: context.pop()
def on_quit(self): context.pop()
def on_key_down(self, unicode, key, mod): if key == K_DOWN: self.movey += State.speed elif key == K_UP: self.movey += -State.speed elif key == K_RIGHT: self.movex += State.speed elif key == K_LEFT: self.movex += -State.speed elif key == K_ESCAPE: context.pop()
def on_quit(self): self.app_salvata=context.top() context.pop()
def on_key_down_incondizionato(self, unicode, key, mod): if key == K_DOWN or key == K_s: self.cammina=True self.camera.target.giocatore_animato=self.animato['front_walk'] self.movey += State.speed if self.corsa: self.movey += State.speed self.camera.target.giocatore_animato=self.animato['front_run'] self.direzione_avatar='front' elif key == K_UP or key == K_w: self.cammina=True self.camera.target.giocatore_animato=self.animato['back_walk'] self.movey += -State.speed if self.corsa: self.movey += -State.speed self.camera.target.giocatore_animato=self.animato['back_run'] self.direzione_avatar='back' elif key == K_RIGHT or key == K_d: self.cammina=True self.camera.target.giocatore_animato=self.animato['right_walk'] self.movex += State.speed if self.corsa: self.camera.target.giocatore_animato=self.animato['right_run'] self.movex += State.speed self.direzione_avatar='right' elif key == K_LEFT or key == K_a: self.cammina=True self.camera.target.giocatore_animato=self.animato['left_walk'] self.movex += -State.speed if self.corsa: self.movex += -State.speed self.camera.target.giocatore_animato=self.animato['left_run'] self.direzione_avatar='left' elif key==pygame.K_l: if self.tipofreccia=='l': self.tipofreccia='f' else: self.tipofreccia='l' elif key==pygame.K_h: #print "h" selettore=Selettore(motore=self) elif key == pygame.K_F2: #salva la situazione del gioco salvataggio=Salvataggio() salvataggio.salvataggio_manuale(motore=self) del salvataggio elif key == pygame.K_F3: #ricarica la situazione del gioco dal file print "F3" elif key == pygame.K_F4: print 'f4' dialog = DialogoAvvisi(testo='pippo F4') elif key == pygame.K_F5: if not self.godebug: self.godebug=True else: self.godebug=False elif key == pygame.K_F6: #self.wx.testo.SetLabel(label=str(self.avatar.hitbox)) self.wx.Show(True) #mostra la finestra wxpython #print pygame.display.get_wm_info() elif key == pygame.K_e: pgu=PguApp(self,inizio="animali") elif key == pygame.K_t: pgu=PguApp(self,inizio="inventario") elif key == pygame.K_m: pgu=PguApp(self,inizio="mappa") elif key == pygame.K_F9: print 'f9' self.beast_sprite_group.empty() elif key == K_g: State.show_grid = not State.show_grid elif key == K_l: State.show_labels = not State.show_labels elif key >= K_0 and key <= K_9: self.toggle_layer(key - K_0) elif key == pygame.K_F1: pgu=PguApp(self, inizio="salvataggi") elif key == K_ESCAPE: context.pop()
def on_quit(self): ## Pop the top context, which is self. This exits the program because it ## is the last context on the stack. context.pop()
def on_key_down(self, unicode, key, mod): ## Pop the top context (which happens to be self), and push the next ## context. The next context automatically runs. context.pop() context.push(Game())