本文整理匯總了Python中GUI.render_all方法的典型用法代碼示例。如果您正苦於以下問題:Python GUI.render_all方法的具體用法?Python GUI.render_all怎麽用?Python GUI.render_all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GUI
的用法示例。
在下文中一共展示了GUI.render_all方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: play_game
# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import render_all [as 別名]
def play_game():
player_action = None
GameState.mouse = libtcod.Mouse()
GameState.key = libtcod.Key()
#main loop
while not libtcod.console_is_window_closed():
libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, GameState.key, GameState.mouse)
#render the screen
GUI.render_all()
libtcod.console_flush()
#level up if needed
check_level_up()
#erase all objects at their old locations, before they move
for object in GameState.objects:
object.clear()
#handle keys and exit game if needed
player_action = handle_keys()
if player_action == 'exit':
save_game()
break
#let monsters take their turn
if GameState.game_state == 'playing' and player_action != 'didnt-take-turn':
for object in objects:
if object.ai:
object.ai.take_turn()
示例2: target_tile
# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import render_all [as 別名]
def target_tile(max_range=None):
#return the position of a tile left-clicked in player's FOV (optionally in a range), or (None,None) if right-clicked.
while True:
#render the screen. this erases the inventory and shows the names of objects under the mouse.
libtcod.console_flush()
libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, GameState.key, GameState.mouse)
GUI.render_all()
(x, y) = (GameState.mouse.cx, GameState.mouse.cy)
if GameState.mouse.rbutton_pressed or GameState.key.vk == libtcod.KEY_ESCAPE:
return (None, None) #cancel if the player right-clicked or pressed Escape
#accept the target if the player clicked in FOV, and in case a range is specified, if it's in that range
if (GameState.mouse.lbutton_pressed and libtcod.map_is_in_fov(GameState.fov_map, x, y) and
(max_range is None or GameState.player.distance(x, y) <= max_range)):
return (x, y)
示例3: play_game
# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import render_all [as 別名]
def play_game():
player_action = None
GameState.mouse = libtcod.Mouse()
GameState.key = libtcod.Key()
#main loop
while not libtcod.console_is_window_closed():
libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, GameState.key, GameState.mouse)
#render the screen
GUI.render_all()
libtcod.console_flush()
#level up if needed
#TODO: Add level system
#check_level_up()
#erase all objects at their old locations, before they move
for object in GameState.objects:
object.clear()
#handle keys and exit game if needed
player_action = handle_keys()
if player_action == 'exit':
save_game()
break
#let monsters take their turn
if GameState.game_state == 'playing' and player_action != 'didnt-take-turn':
Obj = Object()
for Obj in GameState.objects:
if Obj.ai != None:
#print "Beginning " + str(Obj) + " Move"
if Obj.ai.currentState.action != None:
Obj.ai.currentStateAction()
#print str(Obj) + " Finished Action"
Obj.ai.checkCurrentState()