小编Ani*_*boy的帖子

如何在 Pygame 中创建暂停按钮?

我一直在尝试制作一个游戏,到目前为止,除了暂停按钮之外,所有内容都有效,按下按钮 P 时应暂停,按下 S 时应继续。我有点理解这个问题,一旦进入主代码中的 while 循环,它就不会退出。我尝试将暂停函数放入 while 循环中。如果可能的话,请提供帮助或提供修复提示,谢谢。

import pygame

# Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
Blue = (2,55,55)



def recursive_draw(x, y, width, height):
    """ Recursive rectangle function. """
    pygame.draw.rect(screen, WHITE,
                     [x, y, width, height],
                     1)
    speed = [10,0]
    rect_change_x = 10
    rect_change_y = 10




    # Is the rectangle wide enough to draw again?
    if (width > 25):
        # Scale down
        x += width * .1
        y += height * .1
        width *= …
Run Code Online (Sandbox Code Playgroud)

python pygame python-2.7

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

pygame ×1

python ×1

python-2.7 ×1