soft-summer-2021 / summer2021

程序设计实践 (2021夏季学期)
34 stars 6 forks source link

代码165行显示的‘Level up'时间太短,不知道怎样延长 #25

Closed DHUAVY closed 3 years ago

DHUAVY commented 3 years ago

https://bhpan.buaa.edu.cn:443/link/3A50429FD35B318BFD605DE97FD265F2

rootczd980303 commented 3 years ago

还是把项目包整体上传下,麻烦同学

DHUAVY commented 3 years ago

https://bhpan.buaa.edu.cn:443/link/A61D6831A1AA803DF12E2020BF664BE1 然后现在是218行

DHUAVY commented 3 years ago

现在可能变成210行了,如果是时事的话。。

hzy1721 commented 3 years ago

可以设置一个计数器 show_level_up,表示显示 Level Up 的循环次数,如果不为 0 就 blit 一次,并且减 1,直到减为 0。如果碰到新的升级,就重置为 SHOW_LEVEL_UP_LOOP_NUM

SHOW_LEVEL_UP_LOOP_NUM = 50
show_level_up = 0

# 游戏难度升级
def development():
    global score, number_of_enemies, times, show_level_up, font_64, SHOW_LEVEL_UP_LOOP_NUM
    if show_level_up > 0:
        text = f'Level Up'
        score_render = font_64.render(text, True, (255, 0, 0))
        screen.blit(score_render, (270, 250))
        show_level_up -= 1
    if score >= 100 * times:
        times += 1
        show_level_up = SHOW_LEVEL_UP_LOOP_NUM
        number_of_enemies += 2
        enemies.append(Enemy())
        enemies.append(Enemy())
        for e in enemies:
            e.step += 1

font_64 = pygame.font.Font('freesansbold.ttf', 64)