當前位置: 首頁>>代碼示例>>Python>>正文


Python Message.next方法代碼示例

本文整理匯總了Python中Message.next方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.next方法的具體用法?Python Message.next怎麽用?Python Message.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Message的用法示例。


在下文中一共展示了Message.next方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Game

# 需要導入模塊: import Message [as 別名]
# 或者: from Message import next [as 別名]
class Game(pyglet.window.Window):
  def __init__(self):
    super(Game, self).__init__()
    self.map = Map(data)
    self.pathfinding = AStar(self.map)
    pyglet.clock.schedule_interval(self.update, 1/120.0)
    self.pause = False
    self.message = Message(["Well hello there, you sexy beast. This is long text...", "You bastard"]);
    self.player = Player(self, self.map.grid[2,1], 0, 0)
    self.npc = NPC(self, self.map.grid[2,1], self.map.get_tile(7,5))
    self.player.create_animations()
    self.npc.create_animations()
    self.enemy = Enemy(self, self.map.grid[2,1], self.map.get_tile(1,5))
    self.enemy.create_animations()

    #little hack to get the viewport centered and then to follow the player
    temp_size = self.get_size()
    self.viewport_x = temp_size[0]/2
    self.viewport_y = 0

    self.offset_x = 0
    self.offset_y = 0
    
    self.update_viewport(temp_size[0]/2, 0)
    self.viewport_y = temp_size[1]/2
 
  def update(self, dt):
    self.clear()
    self.map.draw()
    self.player.draw()
    self.enemy.draw()
    self.npc.draw()
    self.player.inventory.update(self.offset_x, self.offset_y)

    if not self.message.finished:
      self.pause = True
      self.message.show()
    else:
      self.pause = False
    if self.pause:
      return  
    self.player.update(dt)
    if self.enemy.is_alive():
      if not self.enemy.tasks.has_tasks(): 
        self.enemy.calculate_next_move()
        if self.enemy.next_move != self.enemy.tile:
          self.enemy.tasks.add_task(self.enemy.next_move, TASK_WALK)
    self.enemy.update(dt)

  def update_viewport(self, x = -1, y = -1):
    x_pos, y_pos = x, y
    if x == -1:
      x_pos = -self.player.x + self.viewport_x
    if y == -1:
      y_pos = -self.player.y + self.viewport_y

    self.offset_x = x_pos
    self.offset_y = y_pos
    
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glTranslatef(x_pos, y_pos, 1.0)
    glPushMatrix()
    glPopMatrix()
    

  def on_mouse_press(self, x, y, button, modifiers):
    x_pos = x - self.offset_x
    y_pos = y - self.offset_y

    
    if button == LEFT_CLICK:
      if self.message:
        self.message.next()
    if self.pause:
      return
    if button == RIGHT_CLICK:
      for tile in self.map.tiles:
        if(tile.contains(tile.image, x_pos, y_pos) == True):
          if tile.is_passable():
            move_loc = tile.get_move_loc()
            tasks = self.pathfinding.calcShortest(self.map.get_tile(self.player.grid_x, self.player.grid_y), self.map.get_tile(move_loc[0], move_loc[1]))
            if tasks:
              if len(tasks) > 1:
                self.player.tasks.clear_tasks()
                tasks.reverse()
                tasks.pop(0)
                index = len(tasks) - 1
                for task in tasks:
                  self.player.tasks.add_task(task, TASK_WALK)

                if type(tasks[index].person) == NPC:
                  action = self.player.tasks.add_task(tasks[index].person, TASK_SPEAK)
                if type(tasks[index].person) == Enemy:
                  tasks[index].person.under_attack = True
                  self.player.tasks = TaskQueue()
                  self.player.tasks.add_task(tasks[index].person, TASK_GOTO)
                  print "Task Attack"
                  self.player.tasks.add_task(tasks[index].person, TASK_ATTACK)
                  
#.........這裏部分代碼省略.........
開發者ID:edbrown,項目名稱:LD24,代碼行數:103,代碼來源:main.py


注:本文中的Message.next方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。