本文整理汇总了Python中Graphics.draw_letters方法的典型用法代码示例。如果您正苦于以下问题:Python Graphics.draw_letters方法的具体用法?Python Graphics.draw_letters怎么用?Python Graphics.draw_letters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics.draw_letters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Graphics [as 别名]
# 或者: from Graphics import draw_letters [as 别名]
def main():
pygame.init()
size = width, height = 300, 350
# speed = [2, 2]
BLACK = 0, 0, 0
WHITE = 255, 255, 255
screen = pygame.display.set_mode(size)
end_it = False
while end_it == False:
screen.fill(BLACK)
myfont = pygame.font.SysFont("Britannic Bold", 30)
nlabel = myfont.render("Welcome to Boggle Boggle", 1, (255, 0, 0))
instructions = myfont.render("Click to play", 1, (255, 0, 0))
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
end_it = True
screen.blit(nlabel, (0, 100))
screen.blit(instructions, (0, 200))
pygame.display.flip()
# LETTER_FONT = pygame.font.SysFont("monospace", 20)
txtbx = eztext.Input(x=0, y=0, maxlength=45, color=(255, 0, 0), prompt="type here: ")
# create the pygame clock
frame_clock = pygame.time.Clock()
time = 180 # in seconds for 3 minutes
pygame.time.set_timer(pygame.USEREVENT + 1, 1000)
fresh_game = game.Game()
fresh_game.pick_letters()
while 1: # this is a loop good for things that will keep going the same like gifs
frame_clock.tick(30)
# events for txtbx
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.USEREVENT + 1:
time -= 1
# if event.key == K_RETURN in event:
# screen.fill(0,0,0)
if time == 0:
screen.fill(BLACK) # doesn't actually break the loop
else:
# clear screen
screen.fill(BLACK)
graphics.draw_timer(screen, time)
graphics.draw_grid(screen)
graphics.draw_letters(screen, fresh_game.sample)
graphics.draw_score(screen)
# update txtbx
val = txtbx.update(events)
if val is not None:
if fresh_game.is_valid(val):
fresh_game.update_score(val)
fresh_game.update_entries(val)
graphics.redraw_score(screen, str(fresh_game.score))
# blit txtbx on the sceen
txtbx.draw(screen)
# refresh the display
pygame.display.flip()