当前位置: 首页 > news >正文

第四篇【传奇开心果微博系列】Python微项目技术点案例示例:美女颜值判官

传奇开心果微博系列

  • 系列微博目录
    • Python微项目技术点案例示例系列
  • 微博目录
    • 一、微项目目标
    • 二、雏形示例代码
    • 三、扩展思路
    • 四、添加不同类型的美女示例代码
    • 五、增加难度等级示例代码
    • 六、添加特殊道具示例代码
    • 七、设计关卡系统示例代码
    • 八、添加音效和背景音乐示例代码
    • 九、多人游戏模式示例代码
    • 十、排行榜和成就系统示例代码
    • 十一、增加动画效果示例代码

系列微博目录

Python微项目技术点案例示例系列

微博目录

一、微项目目标

在这里插入图片描述
使用pygame实现面向对象的给美女打分小游戏示例代码,给美女打分,鉴赏颜值担当的美女,凑趣逗乐中学编程。

二、雏形示例代码

在这里插入图片描述下面是使用Pygame实现面向对象的给美女打分程序的示例代码:

import pygame
import random# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分")# 定义美女类
class Beauty(pygame.sprite.Sprite):__init__(self, x, y):().__init__()self.image = pygame.image.loadbeauty.png")  # 美女的self.rect = self.image.get_rect()self.rect.center = (x, y)def update(self):pass# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y):super().__init__()self.score = 0self.font = pygame.font.Font(None, 36)self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)def update(self):self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建美女对象
beauty = Beauty(screen_width // 2, screen_height // 2)
all_sprites.add(beauty)# 创建分数对象
score = Score(screen_width // 2, 50)
all_sprites.add(score)# 游戏主循环
running = True
clock = pygame.time.Clock()
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = False# 更新精灵组中的所有精灵all_sprites.update()# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 退出游戏
pygame.quit()

请注意,以上代码中需要准备一张名为"beauty.png"的美女图片作为程序运行所需的资源文件。你可以根据自己的需求替换为其他美女图片。运行代码后,你可以使用鼠标在窗口中打分给美女。程序将在窗口标题栏显示当前得分。

三、扩展思路

在这里插入图片描述使用Pygame实现面向对象的给美女打分程序只是一个简单的示例,扩展思路可以有很多,以下是一些可能的扩展思路:

  1. 添加不同类型的美女:可以创建多个美女对象,并使用不同的图片资源表示不同类型的美女。每个美女可以有自己的得分和特%殊属性。

  2. 增加难度等级:可以根据玩家的得分来调整游戏的难度,例如增加美女的移动速度、出现频率或者增加分数的获取难度。

  3. 添加特殊道具:可以在游戏中添加一些特殊道具,玩家可以通过点击获取道具来增加得分或改变游戏规则。

  4. 设计关卡系统:可以设计多个关卡,每个关卡中有不同的美女和游戏目标。玩家需要按照要求给美女打分才能过关。

  5. 添加音效和背景音乐:可以为游戏添加音效和背景音乐,增加游戏的趣味性和氛围。

  6. 多人游戏模式:可以添加多人游戏模式,允许多个玩家同时参与打分,比较谁的得分更高。

  7. 排行榜和成就系统:可以记录玩家的最高得分,并提供排行榜和成就系统,让玩家之间进行竞争和比较。

  8. 增加动画效果:可以为美女的出现、消失或得分时添加一些动画效果,使游戏更加生动和有趣。

这些只是一些可能的扩展思路,你可以根据自己的创意和需求来设计和实现更多有趣的功能和玩法。使用Pygame提供的丰富功能和灵活性,你可以将这个简单的打分程序扩展成一个有趣的游戏。

四、添加不同类型的美女示例代码

在这里插入图片描述以下是扩展了不同类型美女的示例代码:

import pygame
import random# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800
screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分")# 定义美女类
class Beauty(pygame.sprite.Sprite):def __init__(self, x, y, image, score, special_attribute):super().__init__()self.image = pygame.image.load(image)  # 美女的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.score = score  # 美女的得分self.special_attribute = special_attribute  # 美女的特殊属性def update(self):pass# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y):super().__init__()self.score = 0self.font = pygame.font.Font(None, 36)self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)def update(self):self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建美女对象
beauty1 = Beauty(screen_width // 2 - 100, screen_height // 2, "beauty1.png", 10, "可爱")
beauty2 = Beauty(screen_width // 2 + 100, screen_height // 2, "beauty2.png", 20, "靓丽")
all_sprites.add(beauty1)
all_sprites.add(beauty2)# 创建分数对象
score = Score(screen_width // 2, 50)
all_sprites.add(score)# 游戏主循环
running = True
clock = pygame.time.Clock()
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = False# 更新精灵组中的所有精灵all_sprites.update()# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 退出游戏
pygame.quit()

在这个示例代码中,我们创建了两个不同类型的美女对象:beauty1和beauty2。它们分别使用了不同的图片资源(“beauty1.png"和"beauty2.png”),并且具有不同的得分和特殊属性。你可以根据自己的需要添加更多美女对象,并为每个美女设置不同的属性。

注意:你需要准备相应的美女图片资源,并将其命名为"beauty1.png"和"beauty2.png",并与示例代码放在同一目录下。

五、增加难度等级示例代码

在这里插入图片描述以下是根据玩家得分调整游戏难度的示例代码:

import pygame
import random# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800
screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分")# 定义美女类
class Beauty(pygame.sprite.Sprite):def __init__(self, x, y, image, score, special_attribute, speed):super().__init__()self.image = pygame.image.load(image)  # 美女的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.score = score  # 美女的得分self.special_attribute = special_attribute  # 美女的特殊属性self.speed = speed  # 美女的移动速度def update(self):self.rect.x += self.speed# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y):super().__init__()self.score = 0self.font = pygame.font.Font(None, 36)self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)def update(self):self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建美女对象
beauty1 = Beauty(screen_width // 2 - 100, screen_height // 2, "beauty1.png", 10, "可爱", 2)
beauty2 = Beauty(screen_width // 2 + 100, screen_height // 2, "beauty2.png", 20, "性感", 3)
all_sprites.add(beauty1)
all_sprites.add(beauty2)# 创建分数对象
score = Score(screen_width // 2, 50)
all_sprites.add(score)# 游戏主循环
running = True
clock = pygame.time.Clock()
spawn_timer = 0
difficulty_level = 1
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = False# 更新精灵组中的所有精灵all_sprites.update()# 控制美女的出现频率和移动速度spawn_timer += 1if spawn_timer >= 60 / difficulty_level:beauty = Beauty(screen_width + 50, random.randint(50, screen_height - 50), "beauty1.png", 10, "可爱", random.randint(2, 4))all_sprites.add(beauty)spawn_timer = 0# 碰撞检测collisions = pygame.sprite.spritecollide(beauty1, all_sprites, True)for collision in collisions:score.score += collision.score# 根据得分调整难度if score.score >= 50 and difficulty_level < 3:difficulty_level = 2elif score.score >= 100 and difficulty_level < 4:difficulty_level = 3# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 退出游戏
pygame.quit()

在这个示例代码中,我们引入了一个spawn_timer变量来控制美女的出现频率。每帧递增spawn_timer,当它达到一定值时,创建一个新的美女对象,并将spawn_timer重置为0。随着得分的增加,difficulty_level变量会逐渐增加,从而影响美女的移动速度和出现频率。

注意:你需要准备相应的美女图片资源,并将其命名为"beauty1.png"和"beauty2.png",并与示例代码放在同一目录下。

六、添加特殊道具示例代码

在这里插入图片描述以下是添加特殊道具的示例代码:

import pygame
import random# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800
screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分")# 定义美女类
class Beauty(pygame.sprite.Sprite):def __init__(self, x, y, image, score, special_attribute, speed):super().__init__()self.image = pygame.image.load(image)  # 美女的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.score = score  # 美女的得分self.special_attribute = special_attribute  # 美女的特殊属性self.speed = speed  # 美女的移动速度def update(self):self.rect.x += self.speed# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y):super().__init__()self.score = 0self.font = pygame.font.Font(None, 36)self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)def update(self):self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))# 定义道具类
class PowerUp(pygame.sprite.Sprite):def __init__(self, x, y, image, effect):super().__init__()self.image = pygame.image.load(image)  # 道具的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.effect = effect  # 道具的效果def update(self):pass# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建美女对象
beauty1 = Beauty(screen_width // 2 - 100, screen_height // 2, "beauty1.png", 10, "可爱", 2)
beauty2 = Beauty(screen_width // 2 + 100, screen_height // 2, "beauty2.png", 20, "性感", 3)
all_sprites.add(beauty1)
all_sprites.add(beauty2)# 创建分数对象
score = Score(screen_width // 2, 50)
all_sprites.add(score)# 创建道具对象
power_up = PowerUp(screen_width // 2, screen_height // 2, "power_up.png", "double_score")
all_sprites.add(power_up)# 游戏主循环
running = True
clock = pygame.time.Clock()
spawn_timer = 0
difficulty_level = 1
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = Falseelif event.type == pygame.MOUSEBUTTONDOWN:if power_up.rect.collidepoint(event.pos):if power_up.effect == "double_score":score.score *= 2power_up.kill()# 更新精灵组中的所有精灵all_sprites.update()# 控制美女的出现频率和移动速度spawn_timer += 1if spawn_timer >= 60 / difficulty_level:beauty = Beauty(screen_width + 50, random.randint(50, screen_height - 50), "beauty1.png", 10, "可爱", random.randint(2, 4))all_sprites.add(beauty)spawn_timer = 0# 碰撞检测collisions = pygame.sprite.spritecollide(beauty1, all_sprites, True)for collision in collisions:score.score += collision.score# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 退出游戏
pygame.quit()

在这个示例代码中,我们创建了一个PowerUp类来表示道具,道具可以通过点击获取。在点击道具时,我们根据道具的效果来增加得分或改变游戏规则。在示例中,道具的效果是双倍得分,当玩家点击道具时,得分将会翻倍。

注意:你需要准备相应的美女图片资源(“beauty1.png"和"beauty2.png”)、道具图片资源(“power_up.png”),并将它们与示例代码放在同一目录下。

七、设计关卡系统示例代码

在这里插入图片描述以下是设计关卡系统的示例代码:

import pygame
import random# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800
screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分")# 定义美女类
class Beauty(pygame.sprite.Sprite):def __init__(self, x, y, image, score, special_attribute, speed):super().__init__()self.image = pygame.image.load(image)  # 美女的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.score = score  # 美女的得分self.special_attribute = special_attribute  # 美女的特殊属性self.speed = speed  # 美女的移动速度def update(self):self.rect.x += self.speed# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y, target_score):super().__init__()self.score = 0self.target_score = target_score  # 目标得分self.font = pygame.font.Font(None, 36)self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)def update(self):self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))# 定义关卡类
class Level:def __init__(self, target_score, beauties):self.target_score = target_score  # 目标得分self.beauties = beauties  # 美女列表def is_completed(self, score):return score >= self.target_score# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建关卡列表
levels = [Level(50, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty1.png", 10, "可爱", 2),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty2.png", 20, "性感", 3)]),Level(100, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty3.png", 15, "甜美", 3),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty4.png", 25, "迷人", 4)])
]current_level = 0
level = levels[current_level]# 创建分数对象
score = Score(screen_width // 2, 50, level.target_score)
all_sprites.add(score)# 将当前关卡的美女添加到精灵组中
for beauty in level.beauties:all_sprites.add(beauty)# 游戏主循环
running = True
clock = pygame.time.Clock()
spawn_timer = 0
difficulty_level = 1
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = False# 更新精灵组中的所有精灵all_sprites.update()# 控制美女的出现频率和移动速度spawn_timer += 1if spawn_timer >= 60 / difficulty_level:beauty = random.choice(level.beauties)beauty = Beauty(screen_width + 50, random.randint(50, screen_height - 50), beauty.image, beauty.score, beauty.special_attribute, random.randint(2, 4))all_sprites.add(beauty)spawn_timer = 0# 碰撞检测collisions = pygame.sprite.spritecollide(beauty, all_sprites, True)for collision in collisions:score.score += collision.score# 检查当前关卡是否完成if level.is_completed(score.score):current_level += 1if current_level < len(levels):level = levels[current_level]score = Score(screen_width // 2, 50, level.target_score)all_sprites.add(score)for beauty in level.beauties:all_sprites.add(beauty)else:running = False# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 退出游戏
pygame.quit()

在这个示例代码中,我们创建了一个Level类来表示关卡,每个关卡有一个目标得分和一组美女。在游戏主循环中,我们检查当前关卡的得分是否达到目标得分,如果达到则进入下一个关卡。如果所有关卡都完成,则游戏结束。

注意:你需要准备相应的美女图片资源(“beauty1.png”、“beauty2.png”、“beauty3.png”、“beauty4.png”),并将它们与示例代码放在同一目录下。每个关卡可以根据需求设计不同的美女和目标得分。

八、添加音效和背景音乐示例代码

在这里插入图片描述以下是为游戏添加音效和背景音乐的示例代码:

import pygame
import random# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800
screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分")# 加载背景音乐
pygame.mixer.music.load("background_music.mp3")
pygame.mixer.music.set_volume(0.5)  # 设置音量
pygame.mixer.music.play(-1)  # 循环播放背景音乐# 加载音效
score_sound = pygame.mixer.Sound("score_sound.wav")# 定义美女类
class Beauty(pygame.sprite.Sprite):def __init__(self, x, y, image, score, special_attribute, speed):super().__init__()self.image = pygame.image.load(image)  # 美女的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.score = score  # 美女的得分self.special_attribute = special_attribute  # 美女的特殊属性self.speed = speed  # 美女的移动速度def update(self):self.rect.x += self.speed# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y, target_score):super().__init__()self.score = 0self.target_score = target_score  # 目标得分self.font = pygame.font.Font(None, 36)self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)def update(self):self.text = self.font.render("Score: " + str(self.score), True, (255, 255, 255))# 定义关卡类
class Level:def __init__(self, target_score, beauties):self.target_score = target_score  # 目标得分self.beauties = beauties  # 美女列表def is_completed(self, score):return score >= self.target_score# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建关卡列表
levels = [Level(50, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty1.png", 10, "可爱", 2),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty2.png", 20, "性感", 3)]),Level(100, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty3.png", 15, "甜美", 3),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty4.png", 25, "迷人", 4)])
]current_level = 0
level = levels[current_level]# 创建分数对象
score = Score(screen_width // 2, 50, level.target_score)
all_sprites.add(score)# 将当前关卡的美女添加到精灵组中
for beauty in level.beauties:all_sprites.add(beauty)# 游戏主循环
running = True
clock = pygame.time.Clock()
spawn_timer = 0
difficulty_level = 1
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = False# 更新精灵组中的所有精灵all_sprites.update()# 控制美女的出现频率和移动速度spawn_timer += 1if spawn_timer >= 60 / difficulty_level:beauty = random.choice(level.beauties)beauty = Beauty(screen_width + 50, random.randint(50, screen_height - 50), beauty.image, beauty.score, beauty.special_attribute, random.randint(2, 4))all_sprites.add(beauty)spawn_timer = 0# 碰撞检测collisions = pygame.sprite.spritecollide(beauty, all_sprites, True)for collision in collisions:score.score += collision.scorescore_sound.play()  # 播放得分音效# 检查当前关卡是否完成if level.is_completed(score.score):current_level += 1if current_level < len(levels):level = levels[current_level]score = Score(screen_width // 2, 50, level.target_score)all_sprites.add(score)for beauty in level.beauties:all_sprites.add(beauty)else:running = False# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 停止背景音乐
pygame.mixer.music.stop()# 退出游戏
pygame.quit()

在这个示例代码中,我们使用pygame.mixer.music模块加载并播放背景音乐。我们还使用pygame.mixer.Sound类加载音效文件,并在美女被击中时播放得分音效。

注意:你需要准备相应的音乐文件(“background_music.mp3”)和音效文件(“score_sound.wav”),并将它们与示例代码放在同一目录下。确保音乐文件和音效文件的文件路径正确。

九、多人游戏模式示例代码

在这里插入图片描述以下是添加多人游戏模式的示例代码:

import pygame
import random# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800
screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分 - 多人游戏模式")# 加载背景音乐
pygame.mixer.music.load("background_music.mp3")
pygame.mixer.music.set_volume(0.5)  # 设置音量
pygame.mixer.music.play(-1)  # 循环播放背景音乐# 加载音效
score_sound = pygame.mixer.Sound("score_sound.wav")# 定义美女类
class Beauty(pygame.sprite.Sprite):def __init__(self, x, y, image, score, special_attribute, speed):super().__init__()self.image = pygame.image.load(image)  # 美女的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.score = score  # 美女的得分self.special_attribute = special_attribute  # 美女的特殊属性self.speed = speed  # 美女的移动速度def update(self):self.rect.x += self.speed# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y, player_name):super().__init__()self.score = 0self.player_name = player_name  # 玩家名称self.font = pygame.font.Font(None, 36)self.text = self.font.render(self.player_name + ": " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)def update(self):self.text = self.font.render(self.player_name + ": " + str(self.score), True, (255, 255, 255))# 定义关卡类
class Level:def __init__(self, target_score, beauties):self.target_score = target_score  # 目标得分self.beauties = beauties  # 美女列表def is_completed(self, score):return score >= self.target_score# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建关卡列表
levels = [Level(50, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty1.png", 10, "可爱", 2),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty2.png", 20, "性感", 3)]),Level(100, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty3.png", 15, "甜美", 3),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty4.png", 25, "迷人", 4)])
]num_players = 2  # 玩家数量
players = []  # 玩家列表# 创建玩家对象和分数对象
for i in range(num_players):player_name = "Player " + str(i+1)player_score = Score(screen_width // 2, 50 + i*50, player_name)players.append(player_score)all_sprites.add(player_score)current_level = 0
level = levels[current_level]# 将当前关卡的美女添加到精灵组中
for beauty in level.beauties:all_sprites.add(beauty)# 游戏主循环
running = True
clock = pygame.time.Clock()
spawn_timer = 0
difficulty_level = 1
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = Falseelif event.type == pygame.MOUSEBUTTONDOWN:mouse_pos = pygame.mouse.get_pos()clicked_sprites = [s for s in all_sprites if s.rect.collidepoint(mouse_pos)]for sprite in clicked_sprites:if isinstance(sprite, Beauty):for player in players:if player.rect.collidepoint(mouse_pos):player.score += sprite.scorescore_sound.play()  # 播放得分音效# 更新精灵组中的所有精灵all_sprites.update()# 控制美女的出现频率和移动速度spawn_timer += 1if spawn_timer >= 60 / difficulty_level:beauty = random.choice(level.beauties)beauty = Beauty(screen_width + 50, random.randint(50, screen_height - 50), beauty.image, beauty.score, beauty.special_attribute, random.randint(2, 4))all_sprites.add(beauty)spawn_timer = 0# 检查当前关卡是否完成if level.is_completed(players[0].score):current_level += 1if current_level < len(levels):level = levels[current_level]for player in players:player.score = 0for beauty in level.beauties:all_sprites.add(beauty)else:running = False# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 停止背景音乐
pygame.mixer.music.stop()# 退出游戏
pygame.quit()

在这个示例代码中,我们创建了一个players列表来存储多个玩家的得分对象。在游戏主循环中,我们检查鼠标点击事件,并根据点击位置和美女对象的碰撞检测来增加玩家的得分。每个玩家都有自己的得分对象,并在屏幕上显示出来。

注意:你需要准备相应的美女图片资源(“beauty1.png”、“beauty2.png”、“beauty3.png”、“beauty4.png”),并将它们与示例代码放在同一目录下。你可以根据需要调整玩家数量和相关设置。

十、排行榜和成就系统示例代码

在这里插入图片描述以下是添加排行榜和成就系统的示例代码:

import pygame
import random
import json# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800
screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分 - 多人游戏模式")# 加载背景音乐
pygame.mixer.music.load("background_music.mp3")
pygame.mixer.music.set_volume(0.5)  # 设置音量
pygame.mixer.music.play(-1)  # 循环播放背景音乐# 加载音效
score_sound = pygame.mixer.Sound("score_sound.wav")# 定义美女类
class Beauty(pygame.sprite.Sprite):def __init__(self, x, y, image, score, special_attribute, speed):super().__init__()self.image = pygame.image.load(image)  # 美女的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.score = score  # 美女的得分self.special_attribute = special_attribute  # 美女的特殊属性self.speed = speed  # 美女的移动速度def update(self):self.rect.x += self.speed# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y, player_name):super().__init__()self.score = 0self.player_name = player_name  # 玩家名称self.font = pygame.font.Font(None, 36)self.text = self.font.render(self.player_name + ": " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)def update(self):self.text = self.font.render(self.player_name + ": " + str(self.score), True, (255, 255, 255))# 定义关卡类
class Level:def __init__(self, target_score, beauties):self.target_score = target_score  # 目标得分self.beauties = beauties  # 美女列表def is_completed(self, score):return score >= self.target_score# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建关卡列表
levels = [Level(50, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty1.png", 10, "可爱", 2),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty2.png", 20, "性感", 3)]),Level(100, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty3.png", 15, "甜美", 3),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty4.png", 25, "迷人", 4)])
]num_players = 2  # 玩家数量
players = []  # 玩家列表# 创建玩家对象和分数对象
for i in range(num_players):player_name = "Player " + str(i+1)player_score = Score(screen_width // 2, 50 + i*50, player_name)players.append(player_score)all_sprites.add(player_score)current_level = 0
level = levels[current_level]# 将当前关卡的美女添加到精灵组中
for beauty in level.beauties:all_sprites.add(beauty)# 加载排行榜数据
leaderboard_data = {}
try:with open("leaderboard.json", "r") as f:leaderboard_data = json.load(f)
except FileNotFoundError:pass# 游戏主循环
running = True
clock = pygame.time.Clock()
spawn_timer = 0
difficulty_level = 1
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = Falseelif event.type == pygame.MOUSEBUTTONDOWN:mouse_pos = pygame.mouse.get_pos()clicked_sprites = [s for s in all_sprites if s.rect.collidepoint(mouse_pos)]for sprite in clicked_sprites:if isinstance(sprite, Beauty):for player in players:if player.rect.collidepoint(mouse_pos):player.score += sprite.scorescore_sound.play()  # 播放得分音效# 更新精灵组中的所有精灵all_sprites.update()# 控制美女的出现频率和移动速度spawn_timer += 1if spawn_timer >= 60 / difficulty_level:beauty = random.choice(level.beauties)beauty = Beauty(screen_width + 50, random.randint(50, screen_height - 50), beauty.image, beauty.score, beauty.special_attribute, random.randint(2, 4))all_sprites.add(beauty)spawn_timer = 0# 检查当前关卡是否完成if level.is_completed(players[0].score):current_level += 1if current_level < len(levels):level = levels[current_level]for player in players:player.score = 0for beauty in level.beauties:all_sprites.add(beauty)else:running = False# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 停止背景音乐
pygame.mixer.music.stop()# 更新排行榜数据
for player in players:if player.player_name not in leaderboard_data:leaderboard_data[player.player_name] = player.scoreelse:leaderboard_data[player.player_name] = max(leaderboard_data[player.player_name], player.score)# 保存排行榜数据
with open("leaderboard.json", "w") as f:json.dump(leaderboard_data, f)# 输出排行榜
sorted_leaderboard = sorted(leaderboard_data.items(), key=lambda x: x[1], reverse=True)
print("排行榜:")
for i, (player_name, score) in enumerate(sorted_leaderboard):print(f"{i+1}. {player_name}: {score}")# 退出游戏
pygame.quit()

在这个示例代码中,我们使用json模块来加载和保存排行榜数据。在游戏主循环结束后,我们根据玩家的得分更新排行榜数据,并将排行榜数据保存到leaderboard.json文件中。最后,我们对排行榜数据进行排序,并输出排行榜的内容。

注意:你需要准备相应的美女图片资源(“beauty1.png”、“beauty2.png”、“beauty3.png”、“beauty4.png”),并将它们与示例代码放在同一目录下。确保音乐文件和音效文件的文件路径正确。

十一、增加动画效果示例代码

在这里插入图片描述以下是为美女的出现、消失和得分时添加动画效果的示例代码:

import pygame
import random# 初始化游戏
pygame.init()# 设置窗口大小和标题
screen_width = 800
screen_height = 600
window = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("给美女打分 - 多人游戏模式")# 加载背景音乐
pygame.mixer.music.load("background_music.mp3")
pygame.mixer.music.set_volume(0.5)  # 设置音量
pygame.mixer.music.play(-1)  # 循环播放背景音乐# 加载音效
score_sound = pygame.mixer.Sound("score_sound.wav")# 定义美女类
class Beauty(pygame.sprite.Sprite):def __init__(self, x, y, image, score, special_attribute, speed):super().__init__()self.image = pygame.image.load(image)  # 美女的图片资源self.rect = self.image.get_rect()self.rect.center = (x, y)self.score = score  # 美女的得分self.special_attribute = special_attribute  # 美女的特殊属性self.speed = speed  # 美女的移动速度self.animation_timer = 0self.animation_duration = 30def update(self):self.rect.x += self.speed# 美女出现动画效果if self.animation_timer < self.animation_duration:self.rect.y -= 2self.animation_timer += 1# 定义分数类
class Score(pygame.sprite.Sprite):def __init__(self, x, y, player_name):super().__init__()self.score = 0self.player_name = player_name  # 玩家名称self.font = pygame.font.Font(None, 36)self.text = self.font.render(self.player_name + ": " + str(self.score), True, (255, 255, 255))self.rect = self.text.get_rect()self.rect.center = (x, y)self.animation_timer = 0self.animation_duration = 30def update(self):# 分数增加动画效果if self.animation_timer < self.animation_duration:self.rect.y -= 2self.animation_timer += 1# 定义关卡类
class Level:def __init__(self, target_score, beauties):self.target_score = target_score  # 目标得分self.beauties = beauties  # 美女列表def is_completed(self, score):return score >= self.target_score# 创建精灵组
all_sprites = pygame.sprite.Group()# 创建关卡列表
levels = [Level(50, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty1.png", 10, "可爱", 2),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty2.png", 20, "性感", 3)]),Level(100, [Beauty(screen_width // 2 - 100, screen_height // 2, "beauty3.png", 15, "甜美", 3),Beauty(screen_width // 2 + 100, screen_height // 2, "beauty4.png", 25, "迷人", 4)])
]num_players = 2  # 玩家数量
players = []  # 玩家列表# 创建玩家对象和分数对象
for i in range(num_players):player_name = "Player " + str(i+1)player_score = Score(screen_width // 2, 50 + i*50, player_name)players.append(player_score)all_sprites.add(player_score)current_level = 0
level = levels[current_level]# 将当前关卡的美女添加到精灵组中
for beauty in level.beauties:all_sprites.add(beauty)# 加载排行榜数据
leaderboard_data = {}
try:with open("leaderboard.json", "r") as f:leaderboard_data = json.load(f)
except FileNotFoundError:pass# 游戏主循环
running = True
clock = pygame.time.Clock()
spawn_timer = 0
difficulty_level = 1
while running:clock.tick(60)# 事件处理for event in pygame.event.get():if event.type == pygame.QUIT:running = Falseelif event.type == pygame.MOUSEBUTTONDOWN:mouse_pos = pygame.mouse.get_pos()clicked_sprites = [s for s in all_sprites if s.rect.collidepoint(mouse_pos)]for sprite in clicked_sprites:if isinstance(sprite, Beauty):for player in players:if player.rect.collidepoint(mouse_pos):player.score += sprite.scorescore_sound.play()  # 播放得分音效# 更新精灵组中的所有精灵all_sprites.update()# 控制美女的出现频率和移动速度spawn_timer += 1if spawn_timer >= 60 / difficulty_level:beauty = random.choice(level.beauties)beauty = Beauty(screen_width + 50, random.randint(50, screen_height - 50), beauty.image, beauty.score, beauty.special_attribute, random.randint(2, 4))all_sprites.add(beauty)spawn_timer = 0# 检查当前关卡是否完成if level.is_completed(players[0].score):current_level += 1if current_level < len(levels):level = levels[current_level]for player in players:player.score = 0for beauty in level.beauties:all_sprites.add(beauty)else:running = False# 绘制背景window.fill((0, 0, 0))# 绘制所有精灵all_sprites.draw(window)# 刷新屏幕pygame.display.flip()# 停止背景音乐
pygame.mixer.music.stop()# 更新排行榜数据
for player in players:if player.player_name not in leaderboard_data:leaderboard_data[player.player_name] = player.scoreelse:leaderboard_data[player.player_name] = max(leaderboard_data[player.player_name], player.score)# 保存排行榜数据
with open("leaderboard.json", "w") as f:json.dump(leaderboard_data, f)# 输出排行榜
sorted_leaderboard = sorted(leaderboard_data.items(), key=lambda x: x[1], reverse=True)
print("排行榜:")
for i, (player_name, score) in enumerate(sorted_leaderboard):print(f"{i+1}. {player_name}: {score}")# 退出游戏
pygame.quit()

在这个示例代码中,我们为美女的出现和得分时添加了动画效果。在Beauty类和Score类中,我们增加了animation_timeranimation_duration属性,用于控制动画的持续时间和当前时间。在update方法中,我们根据动画的进度来修改美女和分数对象的位置,以实现动画效果。
在这里插入图片描述

注意:你需要准备相应的美女图片资源(“beauty1.png”、“beauty2.png”、“beauty3.png”、“beauty4.png”),并将它们与示例代码放在同一目录下。确保音乐文件和音效文件的文件路径正确。

相关文章:

第四篇【传奇开心果微博系列】Python微项目技术点案例示例:美女颜值判官

传奇开心果微博系列 系列微博目录Python微项目技术点案例示例系列 微博目录一、微项目目标二、雏形示例代码三、扩展思路四、添加不同类型的美女示例代码五、增加难度等级示例代码六、添加特殊道具示例代码七、设计关卡系统示例代码八、添加音效和背景音乐示例代码九、多人游戏…...

Python学习之路-初识爬虫:requests

Python学习之路-初识爬虫:requests requests的作用 作用&#xff1a;发送网络请求&#xff0c;返回响应数据 中文文档 &#xff1a; http://docs.python-requests.org/zh_CN/latest/index.html 为什么学requests而不是urllib requests的底层实现就是urllibrequests在pytho…...

Linux 常用的命令

① 基本命令 uname -m 显示机器的处理器架构uname -r 显示正在使用的内核版本dmidecode -q 显示硬件系统部件(SMBIOS / DMI) hdparm -i /dev/hda 罗列一个磁盘的架构特性hdparm -tT /dev/sda 在磁盘上执行测试性读取操作系统信息arch 显示机器的处理器架构uname -m 显示机器的处…...

假期作业 10

1.整理磁盘操作的完整流程&#xff0c;如何接入虚拟机&#xff0c;是否成功识别&#xff0c;对磁盘分区工具的使用&#xff0c;格式化&#xff0c;挂载以及取消挂载 U盘接入虚拟机 在虚拟机--->可移动设备--->找到U盘---->连接 检测U盘是否被虚拟机识别 ls /dev/s…...

【洛谷 P3367】【模板】并查集 题解(并查集+路径压缩)

【模板】并查集 题目描述 如题&#xff0c;现在有一个并查集&#xff0c;你需要完成合并和查询操作。 输入格式 第一行包含两个整数 N , M N,M N,M ,表示共有 N N N 个元素和 M M M 个操作。 接下来 M M M 行&#xff0c;每行包含三个整数 Z i , X i , Y i Z_i,X_i,Y…...

Netty应用(一) 之 NIO概念 基本编程

目录 第一章 概念引入 1.分布式概念引入 第二章 Netty基础 - NIO 1.引言 1.1 什么是Netty&#xff1f; 1.2 为什么要学习Netty&#xff1f; 2.NIO编程 2.1 传统网络通信中开发方式及问题&#xff08;BIO&#xff09; 2.1.1 多线程版网络编程 2.1.2 线程池版的网络编程…...

tkinter-TinUI-xml实战(10)展示画廊

tkinter-TinUI-xml实战&#xff08;10&#xff09;展示画廊 引言声明文件结构核心代码主界面统一展示控件控件展示界面单一展示已有展示多类展示 最终效果在这里插入图片描述 ![](https://img-blog.csdnimg.cn/direct/286fcaa2fa5648a992a0ac79b4efad82.png) ………… 结语 引言…...

LeetCode二叉树的垂序遍历

题目描述 给你二叉树的根结点 root &#xff0c;请你设计算法计算二叉树的 垂序遍历 序列。 对位于 (row, col) 的每个结点而言&#xff0c;其左右子结点分别位于 (row 1, col - 1) 和 (row 1, col 1) 。树的根结点位于 (0, 0) 。 二叉树的 垂序遍历 从最左边的列开始直到…...

[linux c]linux do_div() 函数用法

linux do_div() 函数用法 do_div() 是一个 Linux 内核中的宏&#xff0c;用于执行 64 位整数的除法操作&#xff0c;并将结果存储在给定的变量中&#xff0c;同时将余数存储在另一个变量中。这个宏通常用于内核编程中&#xff0c;特别是在处理大整数和性能敏感的场合。 函数原…...

Python学习之路-爬虫提高:常见的反爬手段和解决思路

Python学习之路-爬虫提高:常见的反爬手段和解决思路 常见的反爬手段和解决思路 明确反反爬的主要思路 反反爬的主要思路就是&#xff1a;尽可能的去模拟浏览器&#xff0c;浏览器在如何操作&#xff0c;代码中就如何去实现。浏览器先请求了地址url1&#xff0c;保留了cookie…...

python_numpy库_ndarray的聚合操作、矩阵操作等

一、ndarray的聚合操作 1、求和np.sum() import numpy as np ​ n np.arange(10) print(n) ​ s np.sum(n) print(s) ​ n np.random.randint(0,10,size(3,5)) print(n) s1 np.sum(n) print(s1) #全部数加起来 s2 np.sum(n,axis0) print(s2) #表示每一列的多行求和 …...

python-自动化篇-终极工具-用GUI自动控制键盘和鼠标-pyautogui

文章目录 用GUI自动控制键盘和鼠标pyautogui 模块鼠标屏幕位置——移动地图——pyautogui.size鼠标位置——自身定位——pyautogui.position()移动鼠标——pyautogui.moveTo拖动鼠标滚动鼠标 键盘按下键盘释放键盘 开始与结束通过注销关闭所有程序 用GUI自动控制键盘和鼠标 在…...

面试:大数据和深度学习之间的关系是什么?

大数据与深度学习之间存在着紧密的相互关系&#xff0c;它们在当今技术发展中相辅相成。 大数据的定义与特点:大数据指的是规模(数据量)、多样性(数据类型)和速度(数据生成及处理速度)都超出了传统数据处理软件和硬件能力范围的数据集。它具有四个主要特点&#xff0c;通常被称…...

航芯ACM32G103开发板评测 08 ADC Timer外设测试

航芯ACM32G103开发板评测 08 ADC Timer外设测试 1. 软硬件平台 ACM32G103 Board开发板MDK-ARM Keil 2. 定时器Timer 在一般的MCU芯片中&#xff0c;定时器这个外设资源是非常重要的&#xff0c;一般可以分为SysTick定时器&#xff08;系统滴答定时器&#xff09;、常规定时…...

【Linux学习】生产者-消费者模型

目录 22.1 什么是生产者-消费者模型 22.2 为什么要用生产者-消费者模型? 22.3 生产者-消费者模型的特点 22.4 BlockingQueue实现生产者-消费者模型 22.4.1 实现阻塞队列BlockQueue 1) 添加一个容器来存放数据 2)加入判断Blocking Queue情况的成员函数 3)实现push和pop方法 4)完…...

三、案例 - MySQL数据迁移至ClickHouse

MySQL数据迁移至ClickHouse 一、生成测试数据表和数据1.在MySQL创建数据表和数据2.在ClickHouse创建数据表 二、生成模板文件1.模板文件内容2.模板文件参数详解2.1 全局设置2.2 数据读取&#xff08;Reader&#xff09;2.3 数据写入&#xff08;Writer&#xff09;2.4 性能设置…...

[WinForm开源]概率计算器 - Genshin Impact(V1.0)

创作目的&#xff1a;为方便旅行者估算自己拥有的纠缠之缘能否达到自己的目的&#xff0c;作者使用C#开发了一款小型软件供旅行者参考使用。 创作说明&#xff1a;此软件所涉及到的一切概率与规则完全按照游戏《原神》(V4.4.0)内公示的概率与规则&#xff08;包括保底机制&…...

vscode 代码调试from IPython import embed

一、讲解 这种代码调试方法非常的好用。 from IPython import embed上面的代码片段是用于Python中嵌入一个交互式IPython shell的方法。这可以在任何Python脚本或程序中实现&#xff0c;允许在执行到该点时暂停程序&#xff0c;并提供一个交互式环境&#xff0c;以便于检查、…...

双活工作关于nacos注册中心的数据迁移

最近在做一个双活的项目&#xff0c;在纠结一个注册中心是在双活机房都准备一个&#xff0c;那主机房的数据如果传过去呢&#xff0c;查了一些资料&#xff0c;最终在官网查到了一个NacosSync 的组件&#xff0c;主要用来做数据传输的&#xff0c;并且支持在线替换注册中心的&a…...

5G NR 信道号计算

一、5G NR的频段 增加带宽是增加容量和传输速率最直接的方法&#xff0c;目前5G最大带宽将会达到400MHz&#xff0c;考虑到目前频率占用情况&#xff0c;5G将不得不使用高频进行通信。 3GPP协议定义了从Sub6G(FR1)到毫米波(FR2)的5G目标频谱。 其中FR1是5G的核心频段&#xff0…...

01-Spring实现重试和降级机制

主要用于在模块调用中&#xff0c;出现失败、异常情况下&#xff0c;仍需要进行重复调用。并且在最终调用失败时&#xff0c;可以采用降级措施&#xff0c;返回一般结果。 1、重试机制 我们采用spring 提供的retry 插件&#xff0c;其原理采用aop机制&#xff0c;所以需要额外…...

docker部署showdoc

目录 安装 1.拉取镜像 2.创建容器 使用 1.选择语言 2.默认账户/密码:showdoc/123456​编辑 3.登陆 4.首页 安装 1.拉取镜像 docker pull star7th/showdoc 2.创建容器 mkdir -p /opt/showdoc/html docker run -d --name showdoc --userroot --privilegedtrue -p 1005…...

2.14作业

1.请编程实现二维数组的杨辉三角。 2.请编程实现二维数组计算每一行的和以及列和。 3.请编程实现二维数组计算第二大值。 4.请使用非函数方法实现系统函数strcat,strcmp,strcpy,strlen. strcat: strcmp: strcpy: strlen:...

01.数据结构篇-链表

1.找出两个链表的交点 160. Intersection of Two Linked Lists (Easy) Leetcode / 力扣 例如以下示例中 A 和 B 两个链表相交于 c1&#xff1a; A: a1 → a2↘c1 → c2 → c3↗ B: b1 → b2 → b3 但是不会出现以下相交的情况&#xff0c;因为每个节点只有一个…...

揭秘产品迭代计划制定:从0到1打造完美迭代策略

产品迭代计划是产品团队确保他们能够交付满足客户需求的产品以及实现其业务目标的重要工具。开发一个成功的产品迭代计划需要仔细考虑产品的目标、客户需求、市场趋势和可用资源。以下是帮助您创建产品迭代计划的一些步骤&#xff1a;建立产品目标、收集客户反馈、分析市场趋势…...

Python进阶--下载想要的格言(基于格言网的Python爬虫程序)

注&#xff1a;由于上篇帖子&#xff08;Python进阶--爬取下载人生格言(基于格言网的Python3爬虫)-CSDN博客&#xff09;篇幅长度的限制&#xff0c;此篇帖子对上篇做一个拓展延伸。 目录 一、爬取格言网中想要内容的url 1、找到想要的内容 2、抓包分析&#xff0c;找到想…...

C语言--------数据在内存中的存储

1.整数在内存中的存储 整数在内存是以补码的形式存在的&#xff1b; 整型家族包括char,int ,long long,short类型&#xff1b; 因为char类型是以ASCII值形式存在&#xff0c;所以也是整形家族&#xff1b; 这四种都包括signed,unsigned两种&#xff0c;即有符号和无符号&am…...

【Java】零基础蓝桥杯算法学习——线性动态规划(一维dp)

线性dp——一维动态规划 1、考虑最后一步可以由哪些状态得到&#xff0c;推出转移方程 2、考虑当前状态与哪些参数有关系&#xff0c;定义几维数组来表示当前状态 3、计算时间复杂度&#xff0c;判断是否需要进行优化。 一维动态规划例题&#xff1a;最大上升子序列问题 Java参…...

Excel模板1:彩色甘特图

Excel模板1&#xff1a;彩色甘特图 分享地址 当前效果&#xff1a;只需要填写进度&#xff0c; 其余效果都是自动完成的 。 阿里网盘永久分享&#xff1a;https://www.alipan.com/s/cXhq1PNJfdm ​省心。能用公式的绝不使用手动输入。 ​​ 这个区域以及标题可以手动输入…...

如何重新安装 macOS

你可以使用电脑的内建恢复系统“macOS 恢复”来重新安装 Mac 操作系统。不但简单快捷&#xff0c;而且重新安装后不会移除你的个人数据。 将 Mac 关机 选取苹果菜单  >“关机”&#xff0c;然后等待 Mac 关机。如果你无法将 Mac 关机&#xff0c;请按住它的电源按钮最长 …...

论文阅读-Pegasus:通过网络内一致性目录容忍分布式存储中的偏斜工作负载

论文名称&#xff1a;Pegasus: Tolerating Skewed Workloads in Distributed Storage with In-Network Coherence Directories 摘要 高性能分布式存储系统面临着由于偏斜和动态工作负载引起的负载不平衡的挑战。本文介绍了Pegasus&#xff0c;这是一个利用新一代可编程交换机…...

【PTA|编程题|期末复习】字符串(一)

【C语言/期末复习】字符和字符串函数&#xff08;附思维导图/例题) 目录 7-1 组织星期信息 输入样例 (repeat3) : 输出样例: 代码 7-2 查找指定字符 输入格式&#xff1a; 输出格式&#xff1a; 输入样例1&#xff1a; 输出样例1&#xff1a; 输入样例2&#xff1a; …...

数据库基本操作2

一.DML&#xff08;Data Manipulation Language&#xff09; 用来对数据库中表的数据记录进行更新 关键字&#xff1a;增删改 插入insert 删除delete 更新update 1.数据插入 insert into 表&#xff08;列名1&#xff0c;列名2&#xff0c;列名3……&#xff09;values&a…...

BTC破5W+QAQ

比特币突破5万美元 创2021年来最高 比特币在龙年伊始涨超6.8%。在大年初四&#xff08;2月13日&#xff09;一度最高涨至5万零383美元。 今年1月&#xff0c;当市场期待已久的现货比特币交易所挂牌基金&#xff08;ETF&#xff09;推出后&#xff0c;比特币遭抛售&#xff0c…...

Xubuntu16.04系统中修改系统语言和系统时间

1.修改系统语言 问题&#xff1a;下图显示系统语言不对 查看系统中可用的所有区域设置的命令 locale -a修改/etc/default/locale文件 修改后如下&#xff1a; # File generated by update-locale LANG"en_US.UTF-8" LANGUAGE"en_US:en"LANG"en_US…...

内网穿透 | 推荐两个免费的内网穿透工具

目录 1、简介 2、Ngrok 2.1、下载安装 2.2、运行 2.3、固定域名 2.4、配置多服务 3、cpolar 3.1、下载安装 3.2、运行 &#x1f343;作者介绍&#xff1a;双非本科大三网络工程专业在读&#xff0c;阿里云专家博主&#xff0c;专注于Java领域学习&#xff0c;擅长web应…...

Android中代码生成图片高级部分

1、引言 上一篇文章已经介绍了使用bitmap对象生成图片&#xff0c;但android中不仅仅可以直接使用bitmap对象生成图片&#xff0c;也能借助bitmap对象将布局文件转化为图片&#xff0c;实际应用时&#xff0c;我们需要将两者结合起来&#xff0c;只有这样才能生成更加绚丽的图片…...

计算机网络——09Web-and-HTTP

Web and HTTP 一些术语 Web页&#xff1a;由一些对象组成对象可以是HTML文件、JPEG图像&#xff0c;JAVA小程序&#xff0c;声音剪辑文件等Web页含有一个基本的HTML文件&#xff0c;该基本HTML文件又包含若干对象的引用&#xff08;链接&#xff09;通过URL对每个对象进行引用…...

【教程】MySQL数据库学习笔记(一)——认识与环境搭建(持续更新)

写在前面&#xff1a; 如果文章对你有帮助&#xff0c;记得点赞关注加收藏一波&#xff0c;利于以后需要的时候复习&#xff0c;多谢支持&#xff01; 【MySQL数据库学习】系列文章 第一章 《认识与环境搭建》 第二章 《数据类型》 文章目录 【MySQL数据库学习】系列文章一、认…...

软件测试-测试用例研究-如何编写一份优秀的测试用例

什么是测试用例 测试用例是一组由测试输入、执行条件、预期结果等要素组成&#xff0c;以完成对某个特定需求或者目标测试的数据&#xff0c;体现测试方案、方法、技术和策略的文档。测试用例是软件测试的核心&#xff0c;它把测试系统的操作步骤用文档的形式描述出来&#xf…...

计网day1

RTT&#xff1a;往返传播时延&#xff08;越大&#xff0c;游戏延迟&#xff09; 一.算机网络概念 网络&#xff1a;网样的东西&#xff0c;网状系统 计算机网络&#xff1a;是一个将分散得、具有独立功能的计算机系统&#xff0c;通过通信设备与线路连接起来&#xff0c;由功…...

vLLM vs Text Generation Interface:大型语言模型服务框架的比较

在大型语言模型&#xff08;LLM&#xff09;的世界中&#xff0c;有两个强大的框架用于部署和服务LLM&#xff1a;vLLM 和 Text Generation Interface (TGI)。这两个框架都有各自的优势&#xff0c;适用于不同的使用场景。在这篇博客中&#xff0c;我们将对这两个框架进行详细的…...

[AIGC] 上传文件:后端处理还是直接阿里云OSS?

在构建Web应用时&#xff0c;我们经常需要处理用户上传的文件。这可能是图片、视频、文档等各种各样的文件。但是&#xff0c;上传文件的方式有很多种&#xff0c;最常见的两种方式是&#xff1a;通过后端处理&#xff0c;或者直接上传至云存储服务&#xff0c;如阿里云OSS。那…...

速盾cdn:香港服务器如何用国内cdn

在国内使用香港服务器的情况下&#xff0c;可以考虑使用速盾CDN来提供加速服务。速盾CDN是一种专业的内容分发网络解决方案&#xff0c;可以通过使用不同节点的服务器来提供高速的内容传输和访问。 首先&#xff0c;使用速盾CDN可以帮助解决香港服务器与国内用户之间的延迟和带…...

深入学习Pandas:数据连接、合并、加入、添加、重构函数的全面指南【第72篇—python:数据连接】

深入学习Pandas&#xff1a;数据连接、合并、加入、添加、重构函数的全面指南 Pandas是Python中最强大且广泛使用的数据处理库之一&#xff0c;提供了丰富的函数和工具&#xff0c;以便更轻松地处理和分析数据。在本文中&#xff0c;我们将深入探讨Pandas中一系列数据连接、合…...

IDEA中mybatis配置文件表名显示红色,提示 Unable to resolve table ‘xxx‘

问题&#xff1a;IDEA中mybatis配置文件表名显示红色&#xff0c;提示 Unable to resolve table ‘xxx’ 解决方法&#xff1a; 使用快捷提示键 Alt Enter&#xff0c;选择 Go to SQL Resolution Scopes&#xff08;转到SQL的解析范围&#xff09;...

Python基于大数据的电影预测分析系统

博主介绍&#xff1a;✌程序员徐师兄、7年大厂程序员经历。全网粉丝30W、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精彩专栏推荐订阅&#x1f447;…...

【MATLAB】小波神经网络回归预测算法

有意向获取代码&#xff0c;请转文末观看代码获取方式~也可转原文链接获取~ 1 基本定义 小波神经网络回归预测算法是一种利用小波变换和人工神经网络相结合的方法&#xff0c;用于解决回归预测问题。下面将详细介绍该算法的原理与方法&#xff1a; 小波变换&#xff1a; 小波变…...

最新Burp Suite入门讲解

Burp Suite的安装 Burp Suite是一款集成化的渗透测试工具&#xff0c;包含了很多功能&#xff0c;可以帮助我们高效地完成对Web应用程序的渗透测试和安全检测。 Burp Suite由Java语言编写&#xff0c;Java自身的跨平台性使我们能更方便地学习和使用这款软件。不像其他自动化测…...

【C++】模版初阶

目录 泛函编程 函数模版 概念 格式 原理 实例化 模版函数的匹配原则 类模板 定义格式 泛函编程 如何实现一个通用的交换函数呢&#xff1f; void Swap(int& left, int& right) {int temp left;left right;right temp; } void Swap(double& left, dou…...