本文整理匯總了Python中HelperFunctions.makeTextRect方法的典型用法代碼示例。如果您正苦於以下問題:Python HelperFunctions.makeTextRect方法的具體用法?Python HelperFunctions.makeTextRect怎麽用?Python HelperFunctions.makeTextRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HelperFunctions
的用法示例。
在下文中一共展示了HelperFunctions.makeTextRect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update
# 需要導入模塊: import HelperFunctions [as 別名]
# 或者: from HelperFunctions import makeTextRect [as 別名]
def update(self):
# handle all updates - ALL CODE BELOW:
self.handleKeyPress()
if self.userEscape:
ourFont = pygame.font.SysFont('Arial', 28)
text = HelperFunctions.makeTextRect('Paused. Score: ' + str(self.gameScore) + '. Press q to quit, ESC to unpause.', (0,255,0), (400, 300), Config.screen, ourFont, True)
# draw a rectangle big enough for the text background
pygame.draw.rect(Config.screen, Config.BACKGROUND_COLOUR, (text.x, text.y, text.width, text.height), 1)
pygame.display.update([text])
return
self.clock.tick(Config.FPS)
self.handleCollisions()
self.handleExpiry()
self.handleRandoms()
### ---------------- NEEDS TO BE SORTED OUT --------------
# while >=0 aka not active
if self.freezeActiveBallsTimer > 0:
self.freezeActiveBallsTimer -= Config.FPS
if self.gameOver == False:
movement = self.snake.move(Config.DEFAULT_SCREEN_SIZE[0],
Config.DEFAULT_SCREEN_SIZE[1])
if movement != False:
self.handleUpdates()
else:
self.gameOver = True
self.exitGame()
if ((self.gameOver == True) or (self.userEscape == True)):
self.exitGame()
示例2: main
# 需要導入模塊: import HelperFunctions [as 別名]
# 或者: from HelperFunctions import makeTextRect [as 別名]
#.........這裏部分代碼省略.........
if showUpdates:
screen.fill((0, 0, 0))
text = ourFont.render(playerName, True, (255,
0, 0))
block = text.get_rect()
block.center = (400, 300) # dead center
rect_list.append(screen.blit(text, block))
text = \
ourFont.render('Please type your name, press enter to finish, and backspace to remove characters. '
, True, (255, 255, 255))
block = text.get_rect()
block.center = (400, 250)
# block.center[1] -= 100
rect_list.append(screen.blit(text, block))
pygame.display.update(rect_list)
showUpdates = False
# end while
print 'Final name', playerName
HelperFunctions.appendHighScore(playerScore, playerName)
state = STATE_HIGH_SCORE_TRY_AGAIN
elif state == STATE_LEVEL_CREATOR:
screen.fill((0, 0, 0))
rect_list.append(HelperFunctions.makeTextRect(
'Please follow the instructions in the console.',
(255, 255, 255),
(400, 250),
screen,
ourFont,
True,
))
rect_list.append(HelperFunctions.makeTextRect(
'Once complete, please restart the menu. ',
(255, 255, 255),
(400, 300),
screen,
ourFont,
True,
))
pygame.display.update(rect_list)
os.system(sys.executable + ' level_creator.py')
state = STATE_EXIT
elif state == STATE_HIGH_SCORES:
# print 'High Scores'
(rect_list, state) = high_scores_menu.update(e, state)
highScoresList = HelperFunctions.getHighScores()
yOffset = 220