本文整理汇总了Python中Game.Game.display方法的典型用法代码示例。如果您正苦于以下问题:Python Game.display方法的具体用法?Python Game.display怎么用?Python Game.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Game
的用法示例。
在下文中一共展示了Game.display方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: play_old_vs_new
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import display [as 别名]
def play_old_vs_new(self,tronEvo):
# redefine some globals
globals()['BOARD_SIZE'] = 60
globals()['DISPLAY'] = True
player1 = random.choice(tronEvo.last_pop)
player2 = random.choice(tronEvo.last_pop)
print 'Player 1 weights:', player1.heuristic.weights
print 'Player 2 weights:', player2.heuristic.weights
g = Game(player1, player2, BOARD_SIZE)
g.display = DISPLAY
g.initialize_board()
g.play(True)
raw_input('Hit enter to exit..')
示例2: test_game
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import display [as 别名]
def test_game(self):
p1 = Player()
p1.name = 'p1'
p1.pos = [BOARD_SIZE/2,BOARD_SIZE/4]
p1.heuristic = Heuristic()
p1.heuristic.weights.append(1000)
p1.heuristic.weights.append(20)
p1.heuristic.weights.append(20)
p2 = Player()
p2.name = 'p2'
p2.pos = [BOARD_SIZE/2,3*BOARD_SIZE/4]
p2.heuristic = Heuristic()
p2.heuristic.weights.append(-20)
p2.heuristic.weights.append(20)
p2.heuristic.weights.append(20)
g = Game(p1, p2, BOARD_SIZE)
g.display = True
g.initialize_board()
#g.describe_board(g.board)
g.play()
示例3: __init__
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import display [as 别名]
class Interface:
real_time = 0
fps_limit = 40
time_mousebuttondown = 0
button_mousebuttondown = ''
pos_mousebuttondown = 0
time_keydown = 0
key_keydown = ''
mod_keydown = ''
game_offset = pymunk.Vec2d(0, 0)
game_edge_scroll_size = 20
game_edge_scroll_rate = 4
game_edge_scroll_on = True
game_zooming_rate = 1.1
game_zooming_on = True
def __init__(self):
# Defining some basic colors
self.black = 0, 0, 0
self.white = 255, 255, 255
red = 255, 0, 0
green = 0, 255, 0
blue = 0, 0, 255
yellow = 255, 255, 0
cyan = 0, 255, 255
magenta = 255, 0, 255
self.colors = [self.black, red, green, blue, yellow, cyan, magenta]
# Defining the screen size
self.screen_size = self.screen_width, self.screen_height = 900, 600
# Setting the display and getting the Surface object
self.screen = pygame.display.set_mode(self.screen_size)
# Getting the Clock object
self.clock = pygame.time.Clock()
# Setting a title to the window
pygame.display.set_caption('SixX')
self.game = Game(self)
def click(self, point):
return self.game.select_objects_at_point(point)
def command(self, point):
return self.game.move_selected(point)
def hover(self, point):
return self.game.hover_over_point(point)
def step(self):
# Get any user input
for event in pygame.event.get():
if event.type == pygame.QUIT:
return False
if event.type == pygame.MOUSEBUTTONDOWN:
self.pos_mousebuttondown = event.pos
self.button_mousebuttondown = event.button
self.time_mousebuttondown = self.real_time
if event.type == pygame.MOUSEBUTTONUP:
self.pos_mousebuttondown = 0
self.button_mousebuttondown = ''
self.time_mousebuttondown = 0
mouse_click = mouse_x, mouse_y = event.pos
mouse_button = event.button
if mouse_button == 1:
if (self.click(mouse_click) == 0):
self.command(mouse_click)
continue
if mouse_button == 4:
self.game.zoom(self.game_zooming_rate, mouse_click)
continue
if mouse_button == 5:
self.game.zoom((1/self.game_zooming_rate), mouse_click)
continue
if event.type == pygame.MOUSEMOTION:
mouse_pos = mouse_x, mouse_y = event.pos
self.hover(mouse_pos)
# No longer checking for pygame events.
mouse_pos = mouse_x, mouse_y = pygame.mouse.get_pos()
if (self.game_edge_scroll_on):
if (mouse_x < self.screen_width and mouse_x > self.screen_width - self.game_edge_scroll_size):
self.game.scroll(self.game_edge_scroll_rate, 0)
elif (mouse_x > 0 and mouse_x < self.game_edge_scroll_size):
self.game.scroll(-self.game_edge_scroll_rate, 0)
if (mouse_y < self.screen_height and mouse_y > self.screen_height - self.game_edge_scroll_size):
self.game.scroll(0, self.game_edge_scroll_rate)
elif (mouse_y > 0 and mouse_y < self.game_edge_scroll_size):
self.game.scroll(0, -self.game_edge_scroll_rate)
#.........这里部分代码省略.........