本文整理汇总了Python中map.Map.next_turn方法的典型用法代码示例。如果您正苦于以下问题:Python Map.next_turn方法的具体用法?Python Map.next_turn怎么用?Python Map.next_turn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.next_turn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import next_turn [as 别名]
class Game:
def __init__(self):
interface.add_from_file('gui.glade')
interface.connect_signals(self)
self.players = []
self.window = interface.get_object('window1')
self.window.set_title("Easy strategy")
self.window.connect("destroy", gtk.main_quit)
self.side_panel = SidePanel(self)
hbox = interface.get_object('hbox1')
hbox.pack2(self.side_panel)
self.window.set_default_size(800, 500)
self.window.show_all()
def expose_handler(self, widget, event):
xgc = widget.window.new_gc()
if self.map:
self.map.draw(widget.window, xgc)
def button_press_event(self, widget, event):
if self.map:
self.map.button_pressed(event.x, event.y)
widget.queue_draw()
widget.grab_focus()
def key_pressed_event(self, widget, event):
if self.map:
self.map.key_pressed(event)
widget.queue_draw()
def push_new(self, widget):
config_player.ConfigPlayer(self)
def new_game(self, players):
self.players = players
self.current_player = 0
case_size=40
map_size=(20,15)
self.map = Map(self, map_size, case_size)
self.side_panel.refresh_turn()
self.area = gtk.DrawingArea()
self.area.set_flags(gtk.CAN_FOCUS)
self.area.set_size_request(map_size[0] * case_size, map_size[1] * case_size)
self.area.connect("expose-event", self.expose_handler)
self.area.connect("button_press_event", self.button_press_event)
self.area.connect("key_press_event", self.key_pressed_event)
self.area.set_events(gtk.gdk.EXPOSURE_MASK
| gtk.gdk.LEAVE_NOTIFY_MASK
| gtk.gdk.BUTTON_PRESS_MASK
| gtk.gdk.POINTER_MOTION_MASK
| gtk.gdk.POINTER_MOTION_HINT_MASK
| gtk.gdk.KEY_PRESS_MASK)
scroll_panel = interface.get_object('scrolledwindow1')
scroll_panel.add_with_viewport(self.area)
self.window.queue_draw()
self.window.show_all()
def get_current_player(self):
if not self.players:
return Player('', 'black')
return self.players[self.current_player]
def next_turn(self):
self.map.next_turn() # if current player = 0 then next turn of the case
self.current_player = (self.current_player + 1) % len(self.players)
self.side_panel.refresh_turn()