代码
import pygame
import random
# 初始化Pygame
pygame.init()
# 屏幕大小
screen_width = 800
screen_height = 600
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("打地鼠游戏")
# 颜色定义
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
# 地鼠类
class Mole:
def __init__(self):
self.x = random.randint(50, screen_width - 50)
self.y = random.randint(50, 150)
self.speed = random.randint(1, 3)
self.radius = 20
def draw(self, screen):
<
python小游戏2——打地鼠”游戏
于 2024-10-12 23:37:08 首次发布