Python实现水果忍者(开源)

news/2024/9/20 7:27:26/ 标签: pygame, python, 开源

一、整体介绍:

1.1 前言:

游戏代码基于Python制作经典游戏案例-水果忍者做出一些改动,优化并增加了一些功能。作为自己Python阶段学习的结束作品,文章最后有源码链接。

1.2 Python主要知识:

(1)面向对象编程 

类的定义与实例化、封装、继承(使用 pygame.sprite.Sprite 作为基类)

(2)模块与库

导入标准库(time, math, random)、导入第三方库( pygame

(3)事件处理

事件监听(pygame.event.get() 处理用户输入和游戏事件)、响应事件(根据不同事件,如关闭窗口、定时器事件,执行相应操作)

(4)图形绘制

图像加载( pygame.image.load() 加载图像)、图像绘制(blit() 方法将图像绘制到窗口上)、图像旋转( pygame.transform.rotate() 旋转图像)

(5)随机数生成

(6)计时与帧率控制

使用 pygame.time.Clock() 控制游戏的帧率

(7)文件操作

使用 open() 读取和写入文本文件,保存和读取最佳分数、逐行读取文件内容并解析数据

(8)碰撞检测

(9)Sprite 和 Group

使用 pygame.sprite.Sprite 创建精灵(如水果、刀光、背景)、使用 pygame.sprite.Group 管理和更新多个精灵,方便批量处理

(10)数学运算

使用三角函数,math.sin() 和 math.cos(),计算水果的抛出轨迹

(11)音频处理

使用 pygame.mixer 播放背景音乐和音效,增强游戏体验

(12)逻辑控制

(13)字体与文本渲染

使用 pygame.font.Font() 创建字体对象,并使用 render() 方法渲染文本以显示分数和信息

(14)参数传递与返回值

1.3 游戏素材

二、完善功能:

(1)优化游戏参数

例如:首页旋转圆环速度,水果上抛高度等,使游戏体验更加平滑。

(2)禅宗模式倒计时

禅宗模式在游戏右上方增加了时间倒计时的图形化界面。

(3)增加额外音效

由于pygame同时播放音乐,会有覆盖现象。即后播放音乐会覆盖之前播放音乐,导致原版游戏结束,bgm.play_over被bgm.play_menu覆盖,播放不出来。使用独立线程对代码要求较高,取巧,利用睡眠(time.sleep)。玩家切到炸弹结束游戏,暂停0.3s画面,而不是原版的突然重新开始。

(4)游戏历史最高分数

利用IO流逐行读取txt文件,和原版分数一样的window.blit函数绘制在游戏界面,不过分数的更新要在结束程序后会执行。

Bug:

游戏的局部和实例变量较多,有些资源可能会被程序占用而无法释放。目前主要bug,在游戏碰撞检测的时候,偶尔会出现分数停止更新的情况。本人才疏学浅,至今没有有效解决,希望大佬们多多包涵,最好能够帮助解决,完善游戏。

三、代码设计:

python">import time
import math
import random
import pygame
from pygame.constants import *pygame.init()""" 背景图片 """
class Background(pygame.sprite.Sprite):def __init__(self, window, x, y, image_path):pygame.sprite.Sprite.__init__(self)self.window = windowself.image = pygame.image.load(image_path)self.rect = self.image.get_rect()self.rect.x = xself.rect.y = ydef update(self):self.window.blit(self.image, self.rect)""" 被抛出的水果类 """
class ThrowFruit(pygame.sprite.Sprite):def __init__(self, window, image_path, speed, turn_angel, flag):pygame.sprite.Sprite.__init__(self)# 游戏窗口self.window = window# 导入水果图像并获取其矩形区域self.image = pygame.image.load(image_path)self.rect = self.image.get_rect()# 水果抛出时x坐标取随机数self.rect.x = random.randint(0, Manager.WIDTH - 10)# 水果初始y坐标self.rect.y = Manager.HEIGHT# 抛出时速度self.speed = speed# 旋转速度self.turn_angel = turn_angel# 水果抛出时与窗口下水平线的夹角弧度,因为要用到随机函数, 所以取整数, 使用时除以100self.throw_angel = 157# 水果抛出后所经历的时间, 初始化为0self.fruit_t = 0# 旋转的总角度self.v_angel = 0# 水果抛出时的初速度self.v0 = 6# 水果标记self.flag = flagdef update(self):""" 水果运动状态更新 """# 在弧度制中,一个完整的圆周对应的角度是360度,对应的弧度是2π(即360度 = 2π弧度)。# 因此,可以通过以下公式将角度转换为弧度: 弧度 = 角度 × π / 180# 当角度为90度时,根据上述公式,可以计算出对应的弧度为: 90度 × π / 180 = 0.5π = 1.57(约)# 如果水果的初始X坐标位于窗口左边区域, 取抛出时弧度在70度至90度之间if self.rect.x <= Manager.WIDTH / 2:self.throw_angel = random.randint(140, 157)# 如果水果的初始X坐标位于窗口右侧区域, 取抛出时弧度在90度至110度之间elif self.rect.x >= Manager.WIDTH / 2:self.throw_angel = random.randint(157, 175)# 水果旋转后的新图像new_fruit = pygame.transform.rotate(self.image, self.v_angel)self.window.blit(new_fruit, (self.rect.x + self.rect.width / 2 - new_fruit.get_width() / 2,self.rect.y + self.rect.height / 2 - new_fruit.get_height() / 2))# 如果水果落出屏幕,没有被切,经典模式 X 加一,并销毁水果对象if self.rect.y >= Manager.HEIGHT + self.rect.height:if self.flag != 5:Manager.classic_miss += 1self.kill()# 水果抛出后的运动时水平匀速运动以及竖直向上的变速运动到达最高点时下落, 所以可以判断水果做的是斜上抛运动# 可以利用重力加速度来求出每隔一段时间水果运动后的y坐标# 公式: v0 * t * sin(α) - g * t^2 / 2self.rect.y -= self.v0 * self.fruit_t * math.sin(self.throw_angel / 100) - (Manager.G *self.fruit_t ** 2 / 10) / 2# 计算水果在水平方向的匀速运动位移之后的X坐标# 公式: v0 * t * cos(α)self.rect.x += self.v0 * self.fruit_t * math.cos(self.throw_angel / 100)# 累加经过的时间self.fruit_t += 0.1# 累加旋转总角度self.v_angel += self.turn_angel""" 水果切片类 """
class HalfFruit(pygame.sprite.Sprite):def __init__(self, window, image_path, x, y, turn_angel, v_angel, v0):pygame.sprite.Sprite.__init__(self)self.window = windowself.image = pygame.image.load(image_path)self.rect = self.image.get_rect()self.rect.x = xself.rect.y = yself.turn_angel = turn_angelself.fruit_t = 0self.v_angel = v_angelself.v0 = v0def update(self):""" 水果运动状态更新 """# 水果旋转后的新图像new_fruit = pygame.transform.rotate(self.image, self.v_angel)# 将旋转后的新图像贴入游戏窗口, 注意, 旋转后的图像尺寸以及像素都不一样了(尺寸变大了), 所以坐标需要进行适当处理#                               在原先图片矩形的中心位置绘制self.window.blit(new_fruit, (self.rect.x + self.rect.width / 2 - new_fruit.get_width() / 2,self.rect.y + self.rect.height / 2 - new_fruit.get_height() / 2))if self.rect.y >= Manager.HEIGHT:self.kill()self.rect.y += Manager.G * self.fruit_t ** 2 / 2self.rect.x += self.v0 * self.fruit_tself.fruit_t += 0.01self.v_angel += self.turn_angel""" 水果刀光类 """
class Knife(object):def __init__(self, window):self.window = windowself.apple_flash = pygame.image.load("./images/apple_flash.png")self.banana_flash = pygame.image.load("./images/banana_flash.png")self.peach_flash = pygame.image.load("./images/peach_flash.png")self.watermelon_flash = pygame.image.load("./images/watermelon_flash.png")self.strawberry_flash = pygame.image.load("./images/strawberry_flash.png")def show_apple_flash(self, x, y):self.window.blit(self.apple_flash, (x, y))def show_banana_flash(self, x, y):self.window.blit(self.banana_flash, (x, y))def show_peach_flash(self, x, y):self.window.blit(self.peach_flash, (x, y))def show_watermelon_flash(self, x, y):self.window.blit(self.watermelon_flash, (x, y))def show_strawberry_flash(self, x, y):self.window.blit(self.strawberry_flash, (x, y))""" 模式选项类 """
class OptionMode(pygame.sprite.Sprite):def __init__(self, window, x, y, image_path, turn_angel, flag):pygame.sprite.Sprite.__init__(self)self.window = windowself.image = pygame.image.load(image_path)self.rect = self.image.get_rect()self.rect.x = xself.rect.y = yself.turn_angel = turn_angelself.v_angel = 0self.flag = flagdef update(self):new_image = pygame.transform.rotate(self.image, -self.v_angel)self.window.blit(new_image, (self.rect.x + self.rect.width / 2 - new_image.get_width() / 2,self.rect.y + self.rect.height / 2 - new_image.get_height() / 2))self.v_angel += self.turn_angel""" 游戏音乐类 """
class Bgm(object):def __init__(self):pygame.mixer.init()def play_menu(self):pygame.mixer.music.load("./sound/menu.mp3")pygame.mixer.music.play(-1, 0)def play_classic(self):pygame.mixer.music.load("./sound/start.mp3")pygame.mixer.music.play(1, 0)def play_throw(self):pygame.mixer.music.load("./sound/throw.mp3")pygame.mixer.music.play(1, 0)def play_splatter(self):pygame.mixer.music.load("./sound/splatter.mp3")pygame.mixer.music.play(1, 0)def play_over(self):pygame.mixer.music.load("./sound/over.mp3")pygame.mixer.music.play(1, 0)def play_boom(self):pygame.mixer.music.load("./sound/boom.mp3")pygame.mixer.music.play(1, 0)""" 游戏逻辑类 """
class Manager(object):# 窗口尺寸WIDTH = 640HEIGHT = 480# 游戏中的定时器常量THROWFRUITTIME = pygame.USEREVENTpygame.time.set_timer(THROWFRUITTIME, 3000)# 根据窗口大小,选取随机整数重力加速度, 水果下落更有层次感,使用时除以10G = random.randint(19, 21)# 经典模式miss掉的水果数classic_miss = 0# 打开文本文件with open('best.txt', 'r') as file:# 逐行读取文件内容for line in file:if 'zen_mode' in line:zen_best = int(line.split(':')[-1].strip())if 'classic_mode' in line:classic_best = int(line.split(':')[-1].strip())def __init__(self):# 生成游戏窗口self.window = pygame.display.set_mode((Manager.WIDTH, Manager.HEIGHT))self.window_icon = pygame.image.load("./images/score.png")pygame.display.set_icon(self.window_icon)pygame.display.set_caption("FruitNinja")# 创建游戏中用到的的精灵组self.background_list = pygame.sprite.Group()self.circle_option = pygame.sprite.Group()self.option_fruit_list = pygame.sprite.Group()self.fruit_half_list = pygame.sprite.Group()self.throw_fruit_list = pygame.sprite.Group()# 导入背景图像并添加入背景精灵组self.background = Background(self.window, 0, 0, "./images/background.jpg")self.home_mask = Background(self.window, 0, 0, "./images/home-mask.png")self.logo = Background(self.window, 20, 10, "./images/logo.png")self.ninja = Background(self.window, Manager.WIDTH - 320, 45, "./images/ninja.png")self.home_desc = Background(self.window, 20, 135, "./images/home-desc.png")self.zen_new = Background(self.window, 175, 215, "./images/new.png")self.background_list.add(self.background)self.background_list.add(self.home_mask)self.background_list.add(self.logo)self.background_list.add(self.ninja)self.background_list.add(self.home_desc)self.background_list.add(self.zen_new)# 创建旋转的圈并添加进精灵组self.dojo = OptionMode(self.window, Manager.WIDTH - 600, Manager.HEIGHT - 250,"./images/dojo.png", 1, None)self.new_game = OptionMode(self.window, Manager.WIDTH - 405, Manager.HEIGHT - 250,"./images/new-game.png", 1, None)self.game_quit = OptionMode(self.window, Manager.WIDTH - 160, Manager.HEIGHT - 150,"./images/quit.png", -1, None)self.circle_option.add(self.dojo)self.circle_option.add(self.new_game)self.circle_option.add(self.game_quit)# 创建主菜单界面旋转的水果并添加进精灵组self.home_peach = OptionMode(self.window, Manager.WIDTH - 600 + self.dojo.rect.width / 2 - 31,Manager.HEIGHT - 250 + self.dojo.rect.height / 2 - 59 / 2,"./images/peach.png", -1, "option_peach")self.home_watermelon = OptionMode(self.window, Manager.WIDTH - 405 + self.new_game.rect.width / 2 - 49,Manager.HEIGHT - 250 + self.new_game.rect.height / 2 - 85 / 2,"./images/watermelon.png", -1, "option_watermelon")self.home_boom = OptionMode(self.window, Manager.WIDTH - 160 + self.game_quit.rect.width / 2 - 66 / 2,Manager.HEIGHT - 150 + self.game_quit.rect.height / 2 - 68 / 2,"./images/boom.png", 1, "option_boom")self.option_fruit_list.add(self.home_peach)self.option_fruit_list.add(self.home_watermelon)self.option_fruit_list.add(self.home_boom)# 设置定时器self.clock = pygame.time.Clock()# 模式标记self.mode_flag = 0# 音效self.bgm = Bgm()# 刀光self.knife = Knife(self.window)# 游戏分数self.classic_score = 0self.zen_score = 0def create_fruit(self):""" 创建水果 """if self.mode_flag == 1:boom_prob = random.randint(4, 6)if boom_prob == 5:self.bgm.play_throw()boom = ThrowFruit(self.window, "./images/boom.png", None, 5, 5)self.throw_fruit_list.add(boom)fruit_image_path = ["./images/apple.png", "./images/banana.png", "./images/peach.png","./images/watermelon.png", "./images/strawberry.png"]fruit_number = random.randint(1, 4)for n in range(fruit_number):rand_fruit_index = random.randint(0, len(fruit_image_path) - 1)self.bgm.play_throw()fruit = ThrowFruit(self.window, fruit_image_path[rand_fruit_index], None, 5,rand_fruit_index)self.throw_fruit_list.add(fruit)def create_fruit_half(self, fruit_flag, fruit_x, fruit_y, turn_angel, v_angel):if fruit_flag == "option_peach":""" 禅宗模式的桃子被切开 """fruit_left = HalfFruit(self.window, "./images/peach-1.png", fruit_x - 50,fruit_y, turn_angel, v_angel, -5)fruit_right = HalfFruit(self.window, "./images/peach-2.png", fruit_x + 50,fruit_y, -turn_angel, v_angel, 5)self.fruit_half_list.add(fruit_left)self.fruit_half_list.add(fruit_right)if fruit_flag == "option_watermelon":""" 经典模式西瓜被切开 """fruit_left = HalfFruit(self.window, "./images/watermelon-1.png", fruit_x - 50,fruit_y, turn_angel, v_angel, -5)fruit_right = HalfFruit(self.window, "./images/watermelon-2.png", fruit_x + 50,fruit_y, -turn_angel, v_angel, 5)self.fruit_half_list.add(fruit_left)self.fruit_half_list.add(fruit_right)if fruit_flag == 0:""" 苹果被切开 """fruit_left = HalfFruit(self.window, "./images/apple-1.png", fruit_x - 50,fruit_y, turn_angel, v_angel, -5)fruit_right = HalfFruit(self.window, "./images/apple-2.png", fruit_x + 50,fruit_y, -turn_angel, v_angel, 5)self.fruit_half_list.add(fruit_left)self.fruit_half_list.add(fruit_right)if fruit_flag == 1:""" 香蕉被切开 """fruit_left = HalfFruit(self.window, "./images/banana-1.png", fruit_x - 50,fruit_y, turn_angel, v_angel, -5)fruit_right = HalfFruit(self.window, "./images/banana-2.png", fruit_x + 50,fruit_y, -turn_angel, v_angel, 5)self.fruit_half_list.add(fruit_left)self.fruit_half_list.add(fruit_right)if fruit_flag == 2:""" 梨被切开 """fruit_left = HalfFruit(self.window, "./images/peach-1.png", fruit_x - 50,fruit_y, turn_angel, v_angel, -5)fruit_right = HalfFruit(self.window, "./images/peach-2.png", fruit_x + 50,fruit_y, -turn_angel, v_angel, 5)self.fruit_half_list.add(fruit_left)self.fruit_half_list.add(fruit_right)if fruit_flag == 3:""" 西瓜被切开 """fruit_left = HalfFruit(self.window, "./images/watermelon-1.png", fruit_x - 50,fruit_y, turn_angel, v_angel, -5)fruit_right = HalfFruit(self.window, "./images/watermelon-2.png", fruit_x + 50,fruit_y, -turn_angel, v_angel, 5)self.fruit_half_list.add(fruit_left)self.fruit_half_list.add(fruit_right)if fruit_flag == 4:""" 草莓被切开 """fruit_left = HalfFruit(self.window, "./images/strawberry-1.png", fruit_x - 50,fruit_y, turn_angel, v_angel, -5)fruit_right = HalfFruit(self.window, "./images/strawberry-2.png", fruit_x + 50,fruit_y, -turn_angel, v_angel, 5)self.fruit_half_list.add(fruit_left)self.fruit_half_list.add(fruit_right)def impact_check(self):""" 碰撞检测 """for item in self.option_fruit_list:""" 主页的模式选择 """mouse_pos = pygame.mouse.get_pos()if mouse_pos[0] > item.rect.left and mouse_pos[0] < item.rect.right \and mouse_pos[1] > item.rect.top and mouse_pos[1] < item.rect.bottom:self.bgm.play_splatter()self.create_fruit_half(item.flag, item.rect.x, item.rect.y, item.turn_angel, item.v_angel)self.option_fruit_list.remove_internal(item)if item.flag == "option_peach":self.mode_flag = 1return 1elif item.flag == "option_watermelon":self.mode_flag = 2return 2elif item.flag == "option_boom":return 0for item in self.throw_fruit_list:""" 游戏开始后判断水果是否被切到 """mouse_pos = pygame.mouse.get_pos()if mouse_pos[0] > item.rect.left and mouse_pos[0] < item.rect.right \and mouse_pos[1] > item.rect.top and mouse_pos[1] < item.rect.bottom:if item.flag == 0:self.knife.show_apple_flash(item.rect.x, item.rect.y)if item.flag == 1:self.knife.show_banana_flash(item.rect.x, item.rect.y)if item.flag == 2:self.knife.show_peach_flash(item.rect.x, item.rect.y)if item.flag == 3:self.knife.show_watermelon_flash(item.rect.x, item.rect.y)if item.flag == 4:self.knife.show_strawberry_flash(item.rect.x, item.rect.y)if self.mode_flag == 1:self.zen_score += 2if self.mode_flag == 2:self.classic_score += 2if item.flag != 5:self.bgm.play_splatter()self.create_fruit_half(item.flag, item.rect.x, item.rect.y, item.turn_angel, item.v_angel)self.throw_fruit_list.remove_internal(item)if item.flag == 5:self.bgm.play_boom()time.sleep(0.4)return 3def check_key(self):""" 监听事件 """for event in pygame.event.get():if event.type == QUIT:pygame.quit()exit()elif event.type == Manager.THROWFRUITTIME and self.mode_flag == 1:self.create_fruit()elif event.type == Manager.THROWFRUITTIME and self.mode_flag == 2:self.create_fruit()def zen_mode(self):""" 禅宗模式 """self.bgm.play_classic()score_image = Background(self.window, 10, 5, "./images/score.png")text = pygame.font.Font("./images/simhei.ttf", 30)  # 设置分数显示的字体best = pygame.font.Font("./images/simhei.ttf", 20)  # 设置历史最好分数显示的字体# 禅宗模式游戏时间record_time = 3600while True:# 设置游戏帧率self.clock.tick(60)self.check_key()self.background_list.sprites()[0].update()score_image.update()text_score = text.render("%d" % self.zen_score, 1, (255, 213, 156))self.window.blit(text_score, (50, 8))best_score = best.render("BEST %d" % self.zen_best, 1, (255, 179, 78))self.window.blit(best_score, (10, 40))game_time = text.render("Time:%d" % (record_time / 60), 1, (178, 34, 34))self.window.blit(game_time, (510, 12))temp_flag = self.impact_check()self.throw_fruit_list.update()self.fruit_half_list.update()pygame.display.update()record_time -= 1# 禅宗模式更新最高历史记录if record_time == 0 or temp_flag == 3:if self.zen_score > self.zen_best:file_path = 'best.txt'with open(file_path, 'r') as file:content = file.read()content = content.replace(str(self.zen_best), str(self.zen_score))with open(file_path, 'w') as file:file.write(content)returndef classic_mode(self):""" 经典模式 """pygame.font.init()self.bgm.play_classic()score_image = Background(self.window, 10, 5, "./images/score.png")text = pygame.font.Font("./images/simhei.ttf", 30)  # 设置分数显示的字体best = pygame.font.Font("./images/simhei.ttf", 20)  # 设置历史最好分数显示的字体x_nums = pygame.sprite.Group()miss_times = pygame.sprite.Group()xxx = Background(self.window, Manager.WIDTH - 30, 5, "./images/xxx.png")xx = Background(self.window, Manager.WIDTH - 60, 5, "./images/xx.png")x = Background(self.window, Manager.WIDTH - 90, 5, "./images/x.png")x_nums.add(xxx)x_nums.add(xx)x_nums.add(x)while True:# 设置游戏帧率self.clock.tick(60)pygame.display.update()self.check_key()self.background_list.sprites()[0].update()score_image.update()text_score = text.render("%d" % self.classic_score, 1, (255, 213, 156))self.window.blit(text_score, (50, 8))best_score = best.render("BEST %d" % self.classic_best, 1, (255, 179, 78))self.window.blit(best_score, (10, 40))x_nums.update()miss_times.update()temp_flag = self.impact_check()if temp_flag == 3:# 经典模式炸弹结束游戏更新历史最高记录if self.classic_score > self.classic_best:file_path = 'best.txt'with open(file_path, 'r') as file:content = file.read()content = content.replace(str(self.classic_best), str(self.classic_score))with open(file_path, 'w') as file:file.write(content)self.bgm.play_boom()time.sleep(0.4)returnself.throw_fruit_list.update()self.fruit_half_list.update()if Manager.classic_miss == 1:xf = Background(self.window, Manager.WIDTH - 90, 5, "./images/xf.png")miss_times.add(xf)elif Manager.classic_miss == 2:xf = Background(self.window, Manager.WIDTH - 90, 5, "./images/xf.png")miss_times.add(xf)xxf = Background(self.window, Manager.WIDTH - 60, 5, "./images/xxf.png")miss_times.add(xxf)elif Manager.classic_miss >= 3:# 经典模式正常结束更新历史最高记录if self.classic_score > self.classic_best:file_path = 'best.txt'with open(file_path, 'r') as file:content = file.read()content = content.replace(str(self.classic_best), str(self.classic_score))with open(file_path, 'w') as file:file.write(content)self.bgm.play_over()time.sleep(0.4)Manager.classic_miss = 0returndef main(self):""" 主页 """self.bgm.play_menu()while True:# 设置游戏帧率self.clock.tick(60)self.background_list.update()self.circle_option.update()self.option_fruit_list.update()self.fruit_half_list.update()temp_flag = self.impact_check()pygame.display.update()if temp_flag == 1:self.zen_mode()self.__init__()self.bgm.play_over()self.bgm.play_menu()if temp_flag == 2:self.classic_mode()self.__init__()self.bgm.play_over()self.bgm.play_menu()elif temp_flag == 0:self.bgm.play_over()time.sleep(0.3)pygame.quit()exit()elif temp_flag == 3:self.__init__()self.bgm.play_menu()self.check_key()if __name__ == '__main__':manager = Manager()manager.main()

源码:

链接:https://pan.baidu.com/s/11YM7GzqzFz1QkcGbJHnDCQ 
提取码:daz5


http://www.ppmy.cn/news/1513823.html

相关文章

Springboot 使用 maven-resources-plugin 打包变量替换jar没有打包进去、Jar包没有被使用

问题场景&#xff1a; 最近在使用环境分离&#xff0c;必须用到maven-resources-plugin来替换配置文件变量。遇到了一些问题。 程序写好了需要打包为packge.jar。恰好本地使用了一些jar包&#xff08;如&#xff1a;them.jar&#xff09;作为依赖。jar包路径就在项目根目录的 …

【深度学习】基于Transformers的大模型推理框架

本文旨在介绍基于transformers的decoder-only语言模型的推理框架。与开源推理框架不同的是&#xff1a; 本框架没有利用额外的开源推理仓库&#xff0c;仅基于huggingface&#xff0c;transformers&#xff0c;pytorch等原生工具进行推理&#xff0c;适合新手学习大模型推理流…

聚鼎科技:怎么做装饰画更受大众好评

在当今这个充满创意与个性表达的时代&#xff0c;装饰画不再仅仅是墙面的点缀&#xff0c;它成为了展现屋主品味与生活态度的重要载体。那么&#xff0c;究竟如何才能创作出既符合大众审美又具有独特魅力的装饰画呢? 融合流行元素与个性化设计是关键所在。一方面&#xff0c;通…

振兴杯全国青年职业技能大赛职业技能标准——物联网安装调试员

一、大赛概述 1.1 振兴杯全国青年职业技能大赛简介 振兴杯全国青年职业技能大赛是一项国家级的职业技能竞赛&#xff0c;自2005年首届大赛成功举办以来&#xff0c;已逐渐成为国内规模最大、影响力最广的青年职业技能竞赛之一。这项竞赛旨在推动青年技能人才的培养和发展&…

camx chi 开 log

下面这里是chi log: <settingsSubGroup Name"ChiOverride Settings"> <setting> <Name>Set Log levels</Name> <Help> Bitmask of log levels, bit 0 - error, …

Java面试-基础

1. 面向对象 什么是面向对象 什么是面向对象&#xff1f; 对比面向过程&#xff0c;是两种不同的处理问题的角度 面向过程更注重事情的每一个步骤及顺序&#xff0c;面向对象更注重事情有哪些参与者 &#xff08;对象&#xff09;、及各自需要做什么 封装、继承、多态 2. …

MySQL 数据库管理

在 MySQL 中&#xff0c;数据库管理是非常基础但又至关重要的技能。无论是创建新的数据库、选择当前使用的数据库&#xff0c;还是查看数据库的相关信息&#xff0c;这些操作都是日常数据库管理中不可或缺的一部分。本文将详细介绍 MySQL 数据库管理的基本操作&#xff0c;包括…

【Solidity】代币

ERC20 ERC-20 全称 “Ethereum Request for Comment 20”&#xff0c;是一种标准接口&#xff0c;用于实现代币合约。ERC20 标准定义了一组函数和事件&#xff0c;使得代币可以在不同的应用和平台之间互操作。 ERC20 标准接口定义了一组必须实现的函数和事件&#xff1a; in…

C#收集海康系读码器内容并硬触发IO报警

最近有个需求&#xff0c;需要对几台打码机读码器进行集中防重。 实现目标&#xff1a;1.对条码进行分机台收集追溯 2.发现重复进行触发IO报警 首先使用海康MVS软件对读码器进行设置&#xff0c;通讯设置为TCP服务器&#xff0c;我们软件做客户端 进行数据收集。 然后再收集到…

使用VMware安装银河麒麟桌面操作系统

安装银河麒麟桌面操作系统&#xff08;Kylin Desktop OS&#xff09;在 VMware 虚拟机上是一项相对简单的任务。以下是具体步骤&#xff1a; 1. 准备工作 VMware Workstation 或 VMware Player&#xff1a;确保已在您的计算机上安装了 VMware 。银河麒麟桌面操作系统的ISO镜像…

《Redis核心技术与实战》学习笔记6——数据同步:主从库如何实现数据一致?

文章目录 主从库间如何进行第一次同步&#xff1f;主从级联模式分担全量复制时的主库压力主从库间网络断了怎么办&#xff1f;小结 大家好&#xff0c;我是大白。 如果 Redis 发生了宕机&#xff0c;我们可以使用了 AOF 和 RDB分别通过回放日志和重新读入 RDB 文件的方式恢复数…

API接口安全101:基础概念与最佳实践

文章目录 API定义协议架构风格描述语言 Webservicewsdl介绍复现 SOAPswagger介绍指纹查找利用存在目录复现 HTTPWebpack介绍复现 在当今数字化时代,API接口已成为现代软件架构中不可或缺的组成部分。它们连接着各种应用程序和服务,促进了数据交换和功能集成。然而,随着API的普及…

python创建项目环境及项目打包

目录 创建项目环境conda创建环境常用命令创建项目虚拟环境创建虚拟环境激活虚拟环境安装第三方库 pyinstaller 打包常用参数组合 嵌入式打包下载嵌入式版本的python配置环境无参调用可完善 nuitka打包 创建项目环境 conda创建环境常用命令 conda create -n py310 python3.10.…

Vue 计算属性:优雅地处理数据逻辑

在 Vue.js 中&#xff0c;计算属性&#xff08;Computed Properties&#xff09;是一种非常实用的功能&#xff0c;它允许我们根据组件的响应式依赖进行缓存和派生状态。计算属性可以让我们以声明式的方式编写复杂的逻辑&#xff0c;而不必担心性能问题。 什么是计算属性&…

畅阅读小程序的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;用户管理&#xff0c;分类管理&#xff0c;充值信息管理&#xff0c;扣费信息管理&#xff0c;书城管理&#xff0c;购买章节管理&#xff0c;章节信息管理&#xff0c;书架管理&#xff0c;系统管理 …

机器学习——XGBoost

目录 一、初识XGBoost 1. 介绍 2. 使用 XGBoost 的方法 &#xff08;1&#xff09;直接使用xgboost库自己的建模流程 &#xff08;2&#xff09;使用xgboost库中的sklearn的API 3. XGBoost的三大板块 4. 提升集成算法 5. 建模流程 二、模型常用参数 1. n_estimators …

C++:模板 II(非类型模板参数,特化,分离编译)

目录 非类型模板参数 模板的特化 函数模板特化 类模板特化 全特化 偏特化 引用特化 指针特化 模板分离编译 非类型模板参数 什么是非类型模板参数&#xff1f; 顾名思义&#xff0c;它的类型形参并不是一个类型&#xff0c;就是用一个常量来作为类模板或函数模板的…

等保测评避坑指南(新手必看)

等保测评&#xff0c;即信息安全等级保护测评&#xff0c;是中国网络安全法规中的一项重要内容。它要求网络运营者根据信息系统的安全保护等级&#xff0c;采取相应的管理措施和技术措施&#xff0c;以确保信息系统安全。对于初次接触等保测评的企业或个人来说&#xff0c;了解…

【HTML】用盒子模型划分网页模块

1、盒子模型 ☞ 所谓的盒子模型在HTML中就是一个盛装 元素内容的容器。 ☞ 每个盒子模型都由元素的内容、宽高、 内边距&#xff08;padding&#xff09;、边框&#xff08;border&#xff09;和外边距 &#xff08;margin&#xff09;组成。 2、< div>标签 3、border…

[数据集][目标检测]街灯路灯检测数据集VOC+YOLO格式1893张1类别

数据集格式&#xff1a;Pascal VOC格式YOLO格式(不包含分割路径的txt文件&#xff0c;仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数)&#xff1a;1893 标注数量(xml文件个数)&#xff1a;1893 标注数量(txt文件个数)&#xff1a;1893 标注…