本文整理汇总了Python中GameState.render_ui方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.render_ui方法的具体用法?Python GameState.render_ui怎么用?Python GameState.render_ui使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameState
的用法示例。
在下文中一共展示了GameState.render_ui方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import render_ui [as 别名]
def draw(self):
Render.clear_layer(5)
self.opened = True
print self.width, self.height
x = 5
y = 5
button_text = 'Close'
button = Button(button_text,
self.width / 2,
self.height - 3,
function=close_window,
target=Render.layers['overlay_console'])
dragging = False
click_x = None
mouse = Input.mouse
while True:
Input.update()
Render.clear_layer(Render.layers['overlay_console'])
Render.draw_rect(Render.layers['overlay_console'], x, y,
self.width,
self.height,
frame=True,
f_color=terminal.color_from_argb(255, 100, 100, 255),
bk_color=terminal.color_from_argb(192, 32, 32, 128),
title="POP_UP TEST!")
Render.print_rect(Render.layers['overlay_console'], x + 2, y + 2, self.width - 4, self.height - 4, self.text)
if mouse.lbutton and x <= mouse.cx <= x + self.width and (mouse.cy == y or dragging):
if click_x is None:
click_x = mouse.cx - x
x = mouse.cx - click_x # (width / 2)
y = mouse.cy
dragging = True
else:
dragging = False
click_x = None
if button.draw(x, y) == 'close':
self.opened = False
Render.clear_layer(Render.layers['overlay_console'])
return
# libtcod.console_flush()
# graphics.draw_image(x, y, enlarge=True)
# graphics.draw_image(x + 1, y + 1, enlarge=True)
# graphics.clear()
# graphics.draw_font(0,0)
GameState.render_ui()
示例2: take_turn
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import render_ui [as 别名]
def take_turn(self):
global vCount
GameState.render_all()
mouse = Input.mouse
while True:
# print "Waiting for input"
"""
On player turn this loops continuasouly waiting for user input
"""
Input.update()
key = Input.key
GameState.render_ui()
"""
Check mouse status
"""
mouse_click_value = self.process_mouse_clicks(mouse)
mouse_hover_value = self.process_mouse_hover(mouse)
if mouse_click_value > 0:
return self.end_turn(mouse_click_value)
if mouse_hover_value > 0:
return self.end_turn(mouse_hover_value)
"""
Auto-Walking
"""
# TODO: Make autowalk pathing calculate paths based on NO monsters. Otherwise you can tell when paths are blocked. Stop when encounter...
if GameState.continue_walking:
self.owner.walk_path()
# print "Auto-Walking"
return self.end_turn(Constants.TURN_COST)
elif not GameState.continue_walking:
self.owner.clear_path()
"""
Basic User Input
"""
# TODO: Make movement cost relative to terrain. (add terrain cost to TILE) WATER / TAR / OIL / SAND = Slower, Road / Trail = Fsater
# TODO: Make turns not pass as you bumb into walls.
# TODO: Add 'Auto-Explore' --- Search for Not self.Explored, path to it as if you right clicked.
if key == terminal.TK_KP_8 or key == terminal.TK_UP:
GameState.player_move_or_interact(0, -1)
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_KP_2 or key == terminal.TK_DOWN:
GameState.player_move_or_interact(0, 1)
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_KP_4 or key == terminal.TK_LEFT:
GameState.player_move_or_interact(-1, 0)
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_KP_6 or key == terminal.TK_RIGHT:
GameState.player_move_or_interact(1, 0)
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_KP_7: # or (terminal.TK_LEFT and terminal.TK_UP):
GameState.player_move_or_interact(-1, -1)
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_KP_9:
GameState.player_move_or_interact(1, -1)
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_KP_1:
GameState.player_move_or_interact(-1, 1)
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_KP_3:
GameState.player_move_or_interact(1, 1)
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_KP_5:
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_X:
GameState.current_level.require_recompute()
Constants.DEBUG = not Constants.DEBUG
GameState.render_all()
elif key == terminal.TK_G:
# pick up an item
for object in GameState.current_level.get_all_objects(): # look for an item in the player's tile
if object.x == self.owner.x and object.y == self.owner.y and object.item:
object.item.pick_up()
break
elif key == terminal.TK_F:
for obj in GameState.get_all_equipped(self.owner):
if obj.owner.ranged:
outcome = obj.owner.ranged.fire()
if outcome == 'cancelled':
return 0
else:
return self.end_turn(Constants.TURN_COST)
elif key == terminal.TK_B:
title = "Beastiary"
text = '\n\nDrag Header to move window\n\n'
#.........这里部分代码省略.........
示例3: target_mode
# 需要导入模块: import GameState [as 别名]
# 或者: from GameState import render_ui [as 别名]
#.........这里部分代码省略.........
bk_color=terminal.color_from_name('transparent'),
title="Targeting Mode - Right Click/ESC to Cancel")
# """
''' Get Inputs '''
Input.update()
key = Input.key
''' determine if mouse moved, otherwise use auto-target '''
if mouse.cx != mouse_last_x or mouse.cy != mouse_last_y:
mouse_moved = True
moues_last_x, mouse_last_y = mouse.cx, mouse.cy
if mouse_moved:
target_x, target_y = Utils.to_map_coordinates(mouse.cx, mouse.cy)
elif target:
target_x, target_y = target.x, target.y
else:
target_x, target_y = source.x, source.y
''' determine line of fire (You may not be able to hit every enemy you see) '''
line = Utils.get_line((source.x, source.y),
(target_x, target_y),
walkable=True,
ignore_mobs=True,
max_length=ranged_componenet.max_range)
for point in line:
if point == (None, None):
break
point = Utils.to_camera_coordinates(point[0], point[1])
#libtcod.console_set_char_background(0, point[0], point[1], libtcod.lighter_blue, libtcod.BKGND_SET)
Render.draw_char(layers['overlay_console'], point[0], point[1], 0x2588, terminal.color_from_argb(128, 64, 64, 255))
if len(line) > 0:
index = Utils.find_element_in_list((None, None), line)
if index is None:
point = line[-1]
else:
point = line[index - 1]
circle = Utils.get_circle_points(point[0], point[1], ranged_componenet.aoe)
if circle:
tile_effected = set(circle)
for points in circle:
points = Utils.to_camera_coordinates(points[0], points[1])
Render.draw_char(layers['overlay_console'], points[0], points[1], 0x2588, terminal.color_from_argb(128, 200, 32, 32))
Render.draw_char(layers['overlay_console'], points[0], points[1], 0xE000, terminal.color_from_argb(128, 255, 0, 0))
if mouse.lbutton_pressed or key == terminal.TK_SPACE:
# target_tile = (target_x, target_y)
# print tile_effected
for target in tile_effected:
# target = Map.to_map_coordinates(target[0], target[1])
monster = GameState.current_level.get_monster_at((target[0], target[1]))
if monster is not None:
print "Monster: " + str(monster) + " at " + str(target)
targets.append(monster)
break
if mouse.rbutton_pressed or key == terminal.TK_ESCAPE:
break
if key == terminal.TK_F:
if target_list:
target = next(target_list)[0]
GameState.render_ui()
if not targets: # no enemy found within maximum range
Utils.message('Cancelled.', Color('red'))
Render.clear_layer(layers['overlay_console'])
return 'cancelled'
else:
targets = GameState.current_level.get_monsters_in_range_at(target, ranged_componenet.aoe)
Render.clear_layer(layers['overlay_console'])
# TODO: Allow targeting Empty tiles
# zap it!
if ranged_componenet.animation:
ranged_componenet.animation_params['origin'] = (source.x, source.y)
ranged_componenet.animation_params['target'] = (target_x, target_y)
ranged_componenet.animation_params['target_angle'] = Utils.get_angle(source.x, source.y, target_x, target_y)
GameState.add_animation(ranged_componenet.animation, ranged_componenet.animation_params)
for target in targets:
if target.fighter:
# TODO: Combat should handle all messages......
Utils.message('[color={1}]{2} [color={0}]takes [color={3}]{4} damage[color={0}].'
''.format(Constants.COMBAT_MESSAGE_DEFAULT_COLOR,
Constants.COMBAT_MESSAGE_MONSTER_NAME_COLOR,
target.name,
Constants.COMBAT_MESSAGE_DAMAGE_COLOR,
ranged_componenet.owner.equipment.power_bonus))
target.fighter.take_damage(ranged_componenet.owner.equipment.power_bonus)
Render.clear_layer(5)
return 'fired'