找回密码
 中文实名注册
搜索
查看: 264|回复: 0

水果忍者(下)

[复制链接]

23

主题

11

回帖

746

积分

高级会员

积分
746
发表于 2025-7-22 10:44:16 | 显示全部楼层 |阅读模式

# 刀光效果类


class SlashEffect:
    def __init__(self, start, end):
        self.start = start
        self.end = end
        self.alpha = 255
        self.fade_speed = 10

    def update(self):
        self.alpha -= self.fade_speed
        return self.alpha <= 0

    def draw(self, win):
        if self.alpha > 0:
            # 创建临时表面绘制透明线条
            s = pygame.Surface((WIDTH, HEIGHT), pygame.SRCALPHA)
            color = (255, 255, 255, self.alpha)
            pygame.draw.line(s, color, self.start, self.end, 3)
            win.blit(s, (0, 0))

# 显示文字


def draw_text(win, text, size, x, y, color=WHITE):
    font = pygame.font.SysFont("simsun", size)
    text_surface = font.render(text, True, color)
    text_rect = text_surface.get_rect()
    text_rect.midtop = (x, y)
    win.blit(text_surface, text_rect)

# 主函数


def main():
    clock = pygame.time.Clock()

    # 游戏变量
    fruits = []
    bombs = []
    slashes = []
    score = 0
    lives = 3
    spawn_timer = 0
    spawn_interval = 60  # 生成水果的间隔(帧)
    game_over = False

    # 背景色
    bg_color = (50, 50, 50)

    # 主循环
    running = True
    mouse_down = False
    last_mouse_pos = (0, 0)

    while running:
        clock.tick(60)



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 中文实名注册

本版积分规则

快速回复 返回顶部 返回列表