本文整理汇总了Python中Game.Game.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Game.draw方法的具体用法?Python Game.draw怎么用?Python Game.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Game
的用法示例。
在下文中一共展示了Game.draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import draw [as 别名]
class WerewolfTagClient:
game = None
window = None
display = pygame.display
event = pygame.event
mixer = pygame.mixer # for sound
frameRate = 60
screenWidth = 640
screenHeight = 480
fullScreen = False
currentState = GameState.GAME
def __init__(self):
pygame.init()
self.window = self.display.set_mode([self.screenWidth, self.screenHeight], pygame.FULLSCREEN if self.fullScreen else pygame.RESIZABLE)
self.display.set_caption("Werewolf Tag Training Mode")
pygame.mouse.set_visible(False)
self.mixer.init()
self.game = Game(self)
def run(self):
isDone = False
while isDone == False:
self.window.fill((0, 0, 0))
key = pygame.key.get_pressed()
for event in pygame.event.get():
if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
isDone = True
if self.currentState == GameState.GAME:
self.game.update(key)
elif self.currentState == GameState.EXIT:
isDone = True
if self.currentState == GameState.GAME:
self.game.draw()
self.display.flip()
def setState(self, state):
# end current state
if self.currentState == GameState.GAME:
self.game.end()
# initialize next state
if state == GameState.GAME:
state = self.game.init()
# update current state
self.currentState = state
def end(self):
self.mixer.quit()
self.display.quit()
pygame.quit()
示例2: exit_requested
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import draw [as 别名]
# Functions
def exit_requested(event):
return event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE)
def set_caption_to_frame_time(game_name):
pygame.display.set_caption(game_name + ': ' + str(clock.get_rawtime()) + 'ms/Frame')
# Game Loop
while game_running:
# Clear Display
display.fill(game.SCREEN_CLEAR_COLOR)
# Handle Events
key_events = []
for event in pygame.event.get():
if event.type == KEYDOWN:
key_events.append(event)
game_running = not exit_requested(event)
# Update/Draw
delta = clock.get_time() * game.time_scale
game.update(delta, key_events)
game.draw(display)
# Show Display
pygame.display.update()
clock.tick()
set_caption_to_frame_time(game.GAME_NAME)
# Cleanup
pygame.quit()
示例3: Game
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import draw [as 别名]
resolutionY = 800
black = (0,0,0)
white = (255,255,255)
screen = pygame.display.set_mode((resolutionX, resolutionY))
cellGame = Game(screen, clock)
cellGame.gameState = gameState.MENU_STATE
keypress = pygame.key.get_pressed()
while(keypress[pygame.K_ESCAPE] == False):
keypress = pygame.key.get_pressed()
screen.fill(black) #Clears the screen
msElapsed = clock.tick(30) #Frames per second
cellGame.update(screen) #tells the game to update its objects
if(cellGame.gameState == gameState.PLAY_STATE):
cellGame.draw(screen)
cellGame.drawHUD(screen)
#updates our display with all of the changes
#gamePrint(screen, str(clock.get_fps()), 0,0, white)
pygame.display.update()
for event in pygame.event.get(): #Exits the program if the X is pressed.
if event.type == pygame.QUIT:
pygame.quit(); sys.exit();
pygame.quit() #Exits if loop is broken (Esc pressed)
sys.exit()