钢琴块小游戏(附源码)

news2024/11/26 20:33:01

 代码结构

app.png是游戏运行主界面的图片(可以加载自己喜欢的主界面图片)

 Assets文件夹里面装的是一些需要用到的游戏图片

全部都可以替换为自己喜欢的图片

Fonts里面装的是

 Sounds文件夹里面装的是

 一 . 主程序代码

1.运行这个代码使得游戏开始

2.主界面的图片可以自己下载一些喜欢的图片 修改路径即可

3.报错就是缺少必要文件 有需要的可以联系我 (我把整个代码给你)


# 导入必要的包
import json
import random
import pygame
from threading import Thread

from objects import Tile, Square, Text, Button, Counter

pygame.init()
SCREEN = WIDTH, HEIGHT = 288, 512
TILE_WIDTH = WIDTH // 4
TILE_HEIGHT = 130

info = pygame.display.Info()
width = info.current_w
height = info.current_h

if width >= height:
	win = pygame.display.set_mode(SCREEN, pygame.NOFRAME)
else:
	win = pygame.display.set_mode(SCREEN, pygame.NOFRAME | pygame.SCALED | pygame.FULLSCREEN)

clock = pygame.time.Clock()
FPS = 30

# COLORS *********************************************************************

WHITE = (255, 255, 255)
GRAY = (75, 75, 75)
BLUE = (30, 144, 255)

# IMAGES *********************************************************************

bg_img = pygame.image.load('Assets/bg.png')
bg_img = pygame.transform.scale(bg_img, (WIDTH, HEIGHT))

piano_img = pygame.image.load('Assets/piano.png')
piano_img = pygame.transform.scale(piano_img, (212, 212))

title_img = pygame.image.load('Assets/title.png')
title_img = pygame.transform.scale(title_img, (200, 50))

start_img = pygame.image.load('Assets/start.png')
start_img = pygame.transform.scale(start_img, (120, 40))
start_rect = start_img.get_rect(center=(WIDTH//2, HEIGHT-80))

overlay = pygame.image.load('Assets/red overlay.png')
overlay = pygame.transform.scale(overlay, (WIDTH, HEIGHT))

# MUSIC **********************************************************************

buzzer_fx = pygame.mixer.Sound('Sounds/piano-buzzer.mp3')

pygame.mixer.music.load('Sounds/piano-bgmusic.mp3')
pygame.mixer.music.set_volume(0.8)
pygame.mixer.music.play(loops=-1)

# FONTS **********************************************************************

score_font = pygame.font.Font('Fonts/Futura condensed.ttf', 32)
title_font = pygame.font.Font('Fonts/Alternity-8w7J.ttf', 30)
gameover_font = pygame.font.Font('Fonts/Alternity-8w7J.ttf', 40)

title_img = title_font.render('Piano Tiles', True, WHITE)

# BUTTONS ********************************************************************

close_img = pygame.image.load('Assets/closeBtn.png')
replay_img = pygame.image.load('Assets/replay.png')
sound_off_img = pygame.image.load("Assets/soundOffBtn.png")
sound_on_img = pygame.image.load("Assets/soundOnBtn.png")

close_btn = Button(close_img, (24, 24), WIDTH // 4 - 18, HEIGHT//2 + 120)
replay_btn = Button(replay_img, (36,36), WIDTH // 2  - 18, HEIGHT//2 + 115)
sound_btn = Button(sound_on_img, (24, 24), WIDTH - WIDTH // 4 - 18, HEIGHT//2 + 120)

# GROUPS & OBJECTS ***********************************************************

tile_group = pygame.sprite.Group()
square_group = pygame.sprite.Group()
text_group = pygame.sprite.Group()

time_counter = Counter(win, gameover_font)

# FUNCTIONS ******************************************************************

def get_speed(score):
	return 200 + 5 * score

def play_notes(notePath):
	pygame.mixer.Sound(notePath).play()

# NOTES **********************************************************************

with open('notes.json') as file:
	notes_dict = json.load(file)

# VARIABLES ******************************************************************

score = 0
high_score = 0
speed = 0

clicked = False
pos = None

home_page = True
game_page = False
game_over = False
sound_on = True

count = 0
overlay_index = 0

running = True
while running:
	pos = None

	count += 1
	if count % 100 == 0:
			square = Square(win)
			square_group.add(square)
			counter = 0

	win.blit(bg_img, (0,0))
	square_group.update()

	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			running = False

		if event.type == pygame.KEYDOWN:
			if event.key == pygame.K_ESCAPE or \
				event.key == pygame.K_q:
				running = False

		if event.type == pygame.MOUSEBUTTONDOWN and not game_over:
			pos = event.pos

	if home_page:
		win.blit(piano_img, (WIDTH//8, HEIGHT//8))
		win.blit(start_img, start_rect)
		win.blit(title_img, (WIDTH // 2 - title_img.get_width() / 2 + 10, 300))

		if pos and start_rect.collidepoint(pos):
			home_page = False
			game_page = True

			x = random.randint(0, 3)
			t = Tile(x * TILE_WIDTH, -TILE_HEIGHT, win)
			tile_group.add(t)

			pos = None

			notes_list = notes_dict['2']
			note_count = 0
			pygame.mixer.set_num_channels(len(notes_list))

	if game_page:
		time_counter.update()
		if time_counter.count <= 0:
			for tile in tile_group:
				tile.update(speed)

				if pos:
					if tile.rect.collidepoint(pos):
						if tile.alive:
							tile.alive = False
							score += 1
							if score >= high_score:
								high_score = score
							

							note = notes_list[note_count].strip()
							th = Thread(target=play_notes, args=(f'Sounds/{note}.ogg', ))
							th.start()
							th.join()
							note_count = (note_count + 1) % len(notes_list)

							tpos = tile.rect.centerx - 10, tile.rect.y
							text = Text('+1', score_font, tpos, win)
							text_group.add(text)

						pos = None

				if tile.rect.bottom >= HEIGHT and tile.alive:
					if not game_over:
						tile.color = (255, 0, 0)
						buzzer_fx.play()
						game_over = True

			if pos:
				buzzer_fx.play()
				game_over = True

			if len(tile_group) > 0:
				t = tile_group.sprites()[-1]
				if t.rect.top + speed >= 0:
					x = random.randint(0, 3)
					y = -TILE_HEIGHT - (0 - t.rect.top)
					t = Tile(x * TILE_WIDTH, y, win)
					tile_group.add(t)

			text_group.update(speed)
			img1 = score_font.render(f'Score : {score}', True, WHITE)
			win.blit(img1, (70 - img1.get_width() / 2, 10))
			img2 = score_font.render(f'High : {high_score}', True, WHITE)
			win.blit(img2, (200 - img2.get_width() / 2, 10))
			for i in range(4):
				pygame.draw.line(win, WHITE, (TILE_WIDTH * i, 0), (TILE_WIDTH*i, HEIGHT), 1)

			speed = int(get_speed(score) * (FPS / 1000))

			if game_over:
				speed = 0

				if overlay_index > 20:
					win.blit(overlay, (0,0))

					img1 = gameover_font.render('Game over', True, WHITE)
					img2 = score_font.render(f'Score : {score}', True, WHITE)
					win.blit(img1, (WIDTH // 2 - img1.get_width() / 2, 180))
					win.blit(img2, (WIDTH // 2 - img2.get_width() / 2, 250))

					if close_btn.draw(win):
						running = False

					if replay_btn.draw(win):
						index = random.randint(1, len(notes_dict))
						notes_list = notes_dict[str(index)]
						note_count = 0
						pygame.mixer.set_num_channels(len(notes_list))

						text_group.empty()
						tile_group.empty()
						score = 0
						speed = 0
						overlay_index = 0
						game_over = False

						time_counter = Counter(win, gameover_font)

						x = random.randint(0, 3)
						t = Tile(x * TILE_WIDTH, -TILE_HEIGHT, win)
						tile_group.add(t)

					if sound_btn.draw(win):
						sound_on = not sound_on
				
						if sound_on:
							sound_btn.update_image(sound_on_img)
							pygame.mixer.music.play(loops=-1)
						else:
							sound_btn.update_image(sound_off_img)
							pygame.mixer.music.stop()
				else:
					overlay_index += 1
					if overlay_index % 3 == 0:
						win.blit(overlay, (0,0))

	pygame.draw.rect(win, BLUE, (0,0, WIDTH, HEIGHT), 2)
	clock.tick(FPS)
	pygame.display.update()

pygame.quit()

二.note_editor.py代码

# 导入josn文件
import json

twinkle_twinkle = ['c4','c4','g4','g4','a4','a4','g4',\
                'f4','f4','e4','e4','d4','d4','c4',\
                'g5','g5','f4','f4','e4','e4','d4',\
                'g5','g5','f4','f4','e4','e4','d4',\
                'c4','c4','g4','g4','a4','a4','g4',\
                'f4','f4','e4','e4','d4','d4','c4',\
                ]

happy_birthday = ["g4", "g4", "a4", "g4", "c5", "b4",\
                    "g4", "g4", "a4", "g4", "d5", "c5",\
                    "g4", "g4", "g5", "e5", "c5", "b4", "a4",\
                    "f5", "f5", "e5", "c5", "d5", "c5"]

jan_gan_man = ['c5', 'd5', 'e5', 'e5', 'e5', 'e5', 'e5',\
                'e5', 'e5', 'e5', 'e5', 'd5', 'e5', 'f5',\
                'e5', 'e5', 'e5', 'd5', 'd5', 'd5', 'b4',\
                'd5', 'c5', 'c5', 'g5', 'g5', 'g5', 'g5',\
                'g5', 'f-5', 'g5', 'g5', 'g5', 'f-5', 'a5',\
                'g5', 'f5', 'f5', 'f5', 'e5', 'e5', 'f5',\
                'd5', 'f5', 'e5', 'e5', 'e5', 'e5', 'e5',\
                'd5', 'g5', 'g5', 'g5', 'f5', 'f5', 'e5',\
                'e5', 'e5', 'd5', 'd5', 'd5', 'd5', 'b4',\
                'd5', 'c5', 'c5', 'd5', 'e5', 'e5', 'e5',\
                'e5', 'd5', 'e5', 'f5', 'e5', 'f5', 'g5',\
                'g5', 'g5', 'f5', 'e5', 'd5', 'f5', 'e5',\
                'e5', 'e5', 'd5', 'd5', 'd5', 'd5', 'b4',\
                'd5', 'c5', 'g5', 'g5', 'g5', 'g5', 'g5',\
                'g5', 'f-5', 'g5', 'g5', 'g5', 'f-5', 'a5',\
                'g5', 'f5', 'f5', 'f5', 'e5', 'e5', 'f5',\
                'df', 'e5', 'c5', 'b4', 'c5', 'b4', 'a5',\
                'b4', 'a5', 'g5', 'a5', 'c5', 'c5', 'd5',\
                'd5', 'e5', 'e5', 'd5', 'e5', 'f5']

o_mere_dil_ke_chain = ['a4', 'g4', 'a4', 'a4', 'g4', 'a4',\
                         'g4', 'e4', 'b4', 'g4', 'a4', 'a4',\
                         'g4', 'a4', 'g4', 'e4', 'g4', 'e4',\
                         'd4', 'd4', 'e4', 'e4', 'g4', 'g4',\
                         'a4', 'a4', 'b4', 'b4', 'g4', 'a4',\
                        'b4', 'b4', 'g4', 'a4', 'c5', 'b4',\
                        'a4', 'c5', 'b4', 'a4', 'c5', 'b4', 'a4']

naruto_theme = ['a4', 'b4', 'a4', 'g4', 'e4', 'g4', 'a4', 'd4',\
                'c4', 'd4', 'c4', 'a3', 'b3', 'a4', 'b4', 'a4',\
                'g4', 'e4', 'g4', 'a4', 'd4', 'c4', 'd4', 'c4',\
                'a3', 'a3', 'e4', 'd4', 'c4', 'a3', 'e4', 'd4',\
                'e4', 'a4', 'c5', 'b4', 'a4', 'g4', 'a4', 'e4',\
                'd4', 'e4', 'd4', 'b3', 'a3', 'a3', 'e4', 'd4',\
                'c4', 'a3', 'e4', 'd4', 'e4', 'a4', 'c5', 'b4',\
                'a4', 'g4', 'a4', 'e4', 'g4', 'a4', 'a4', 'b4',\
                'a4', 'g4', 'e4', 'g4', 'a4', 'd4', 'c4', 'd4',\
                'c4', 'a3', 'b3', 'g3', 'a4', 'b4', 'a4', 'g4',\
                'e4', 'g4', 'a4', 'd4', 'c4', 'd4', 'c4', 'a3',\
                'a3', 'e4', 'd4', 'c4', 'a3', 'e4', 'd4', 'e4',\
                'a4', 'c5', 'b4', 'a4', 'g4', 'a4', 'e4', 'd4',\
                'e4', 'd4', 'b3', 'a3', 'a3', 'e4', 'd4', 'c4',\
                'a3', 'e4', 'd4', 'e4', 'a4', 'c5', 'b4', 'a4',\
                'g4', 'a4', 'e4', 'g4', 'a4', 'a4', 'b4', 'a4',\
                'g4', 'e4', 'g4', 'a4', 'd4', 'c4', 'd4', 'c4',\
                'a3', 'b3', 'g3', 'a4', 'b4', 'a4', 'g4', 'e4',\
                'g4', 'a4', 'd4', 'c4', 'd4', 'c4', 'a3']

notes = {
    '1' : twinkle_twinkle,
    '2' : happy_birthday,
    '3' : jan_gan_man,
    '4' : o_mere_dil_ke_chain,
    '5' : naruto_theme
}

with open('notes.json', 'w') as file:
    json.dump(notes, file)

三.objects.py代码

import pygame
import random

SCREEN = WIDTH, HEIGHT = 288, 512
TILE_WIDTH = WIDTH // 4
TILE_HEIGHT = 130

WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BLUE = (30, 144, 255)
BLUE2 = (2, 239, 239)
PURPLE = (191, 64, 191)

class Tile(pygame.sprite.Sprite):
	def __init__(self, x, y, win):
		super(Tile, self).__init__()

		self.win = win
		self.x, self.y = x, y
		self.color = BLACK
		self.alive = True

		self.surface = pygame.Surface((TILE_WIDTH, TILE_HEIGHT), pygame.SRCALPHA)
		self.rect = self.surface.get_rect()
		self.rect.x = x
		self.rect.y = y

		self.center = TILE_WIDTH//2, TILE_HEIGHT//2 + 15
		self.line_start = self.center[0], self.center[1]-18
		self.line_end = self.center[0], 20

	def update(self, speed):
		self.rect.y += speed
		if self.rect.y >= HEIGHT:
			self.kill()

		if self.alive:
			pygame.draw.rect(self.surface, self.color, (0,0, TILE_WIDTH, TILE_HEIGHT))
			pygame.draw.rect(self.surface, PURPLE, (0,0, TILE_WIDTH, TILE_HEIGHT), 4)
			pygame.draw.rect(self.surface, BLUE2, (0,0, TILE_WIDTH, TILE_HEIGHT), 2)
			pygame.draw.line(self.surface, BLUE, self.line_start, self.line_end, 3)
			pygame.draw.circle(self.surface, BLUE, self.center, 15, 3)
		else:
			pygame.draw.rect(self.surface, (0,0,0, 90), (0,0, TILE_WIDTH, TILE_HEIGHT))
			
		self.win.blit(self.surface, self.rect)

class Text(pygame.sprite.Sprite):
	def __init__(self, text, font, pos, win):
		super(Text, self).__init__()
		self.win = win

		self.x,self.y = pos
		self.initial = self.y
		self.image = font.render(text, True, (255, 255, 255))

	def update(self, speed):
		self.y += speed
		if self.y - self.initial >= 100:
			self.kill()

		self.win.blit(self.image, (self.x, self.y))

class Counter(pygame.sprite.Sprite):
	def __init__(self, win, font):
		super(Counter, self).__init__()

		self.win = win
		self.font = font
		self.index = 1
		self.count = 3

	def update(self):
		if self.index % 30 == 0:
			self.count -= 1

		self.index += 1

		if self.count > 0:
			self.image = self.font.render(f'{self.count}', True, (255, 255, 255))
			self.win.blit(self.image, (WIDTH//2-16, HEIGHT//2-25))

class Square(pygame.sprite.Sprite):
	def __init__(self, win):
		super(Square, self).__init__()

		self.win = win
		self.color = (255, 255, 255)
		self.speed = 3
		self.angle = 0

		self.side = random.randint(15, 40)
		x = random.randint(self.side, WIDTH-self.side)
		y = 0

		self.surface = pygame.Surface((self.side, self.side), pygame.SRCALPHA)
		self.rect = self.surface.get_rect(center=(x, y))

	def update(self):
		center = self.rect.center
		self.angle = (self.angle + self.speed) % 360
		image = pygame.transform.rotate(self.surface , self.angle)
		self.rect = image.get_rect()
		self.rect.center = center

		self.rect.y += 1.5

		if self.rect.top >= HEIGHT:
			self.kill()

		pygame.draw.rect(self.surface, self.color, (0,0, self.side, self.side), 4)
		pygame.draw.rect(self.surface, (30, 144, 255, 128), (2,2, self.side-4, self.side-4), 2)
		self.win.blit(image, self.rect)

class Button(pygame.sprite.Sprite):
	def __init__(self, img, scale, x, y):
		super(Button, self).__init__()
		
		self.scale = scale
		self.image = pygame.transform.scale(img, self.scale)
		self.rect = self.image.get_rect()
		self.rect.x = x
		self.rect.y = y

		self.clicked = False

	def update_image(self, img):
		self.image = pygame.transform.scale(img, self.scale)

	def draw(self, win):
		action = False
		pos = pygame.mouse.get_pos()
		if self.rect.collidepoint(pos):
			if pygame.mouse.get_pressed()[0] and not self.clicked:
				action = True
				self.clicked = True

			if not pygame.mouse.get_pressed()[0]:
				self.clicked = False

		win.blit(self.image, self.rect)
		return action

四.notes.json代码

{"1": ["c4", "c4", "g4", "g4", "a4", "a4", "g4", "f4", "f4", "e4", "e4", "d4", "d4", "c4", "g5", "g5", "f4", "f4", "e4", "e4", "d4", "g5", "g5", "f4", "f4", "e4", "e4", "d4", "c4", "c4", "g4", "g4", "a4", "a4", "g4", "f4", "f4", "e4", "e4", "d4", "d4", "c4"], "2": ["g4", "g4", "a4", "g4", "c5", "b4", "g4", "g4", "a4", "g4", "d5", "c5", "g4", "g4", "g5", "e5", "c5", "b4", "a4", "f5", "f5", "e5", "c5", "d5", "c5"], "3": ["c5", "d5", "e5", "e5", "e5", "e5", "e5", "e5", "e5", "e5", "e5", "d5", "e5", "f5", "e5", "e5", "e5", "d5", "d5", "d5", "b4", "d5", "c5", "c5", "g5", "g5", "g5", "g5", "g5", "f-5", "g5", "g5", "g5", "f-5", "a5", "g5", "f5", "f5", "f5", "e5", "e5", "f5", "d5", "f5", "e5", "e5", "e5", "e5", "e5", "d5", "g5", "g5", "g5", "f5", "f5", "e5", "e5", "e5", "d5", "d5", "d5", "d5", "b4", "d5", "c5", "c5", "d5", "e5", "e5", "e5", "e5", "d5", "e5", "f5", "e5", "f5", "g5", "g5", "g5", "f5", "e5", "d5", "f5", "e5", "e5", "e5", "d5", "d5", "d5", "d5", "b4", "d5", "c5", "g5", "g5", "g5", "g5", "g5", "g5", "f-5", "g5", "g5", "g5", "f-5", "a5", "g5", "f5", "f5", "f5", "e5", "e5", "f5", "df", "e5", "c5", "b4", "c5", "b4", "a5", "b4", "a5", "g5", "a5", "c5", "c5", "d5", "d5", "e5", "e5", "d5", "e5", "f5"], "4": ["a4", "g4", "a4", "a4", "g4", "a4", "g4", "e4", "b4", "g4", "a4", "a4", "g4", "a4", "g4", "e4", "g4", "e4", "d4", "d4", "e4", "e4", "g4", "g4", "a4", "a4", "b4", "b4", "g4", "a4", "b4", "b4", "g4", "a4", "c5", "b4", "a4", "c5", "b4", "a4", "c5", "b4", "a4"], "5": ["a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "b3", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "a3", "e4", "d4", "c4", "a3", "e4", "d4", "e4", "a4", "c5", "b4", "a4", "g4", "a4", "e4", "d4", "e4", "d4", "b3", "a3", "a3", "e4", "d4", "c4", "a3", "e4", "d4", "e4", "a4", "c5", "b4", "a4", "g4", "a4", "e4", "g4", "a4", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "b3", "g3", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "a3", "e4", "d4", "c4", "a3", "e4", "d4", "e4", "a4", "c5", "b4", "a4", "g4", "a4", "e4", "d4", "e4", "d4", "b3", "a3", "a3", "e4", "d4", "c4", "a3", "e4", "d4", "e4", "a4", "c5", "b4", "a4", "g4", "a4", "e4", "g4", "a4", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "b3", "g3", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3"]}

游戏效果展示

喜欢的话点个赞呗~

 源代码来自:Github上面的一位大佬

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1845449.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

深入理解Vue3.js响应式系统设计之调度执行

如果您觉得这篇文章有帮助的话&#xff01;给个点赞和评论支持下吧&#xff0c;感谢~ 作者&#xff1a;前端小王hs 阿里云社区博客专家/清华大学出版社签约作者/csdn百万访问前端博主/B站千粉前端up主 此篇文章是博主于2022年学习《Vue.js设计与实现》时的笔记整理而来 书籍&a…

Linux 一键部署 Nginx1.26.1 + ModSecurity3

前言 ModSecurity 是 Apache 基金会的一个开源、高性能的 Web 应用程序防火墙(WAF),它提供了强大的安全规则引擎,用于检测和阻止各种攻击行为,如 SQL 注入、XSS 跨站点脚本攻击等。而 nginx 是一个高性能的 Web 服务器,常用于处理大量的并发请求,具有很高的负载均衡能力…

知网期刊《新课程导学》投稿要求及收稿方向

知网期刊《新课程导学》投稿要求及收稿方向 知网期刊《新课程导学》作为一份专注于教育领域的学术期刊&#xff0c;一直以来都致力于为广大学术研究者提供一个高质量、高水平的学术交流平台。为了保证期刊的学术质量&#xff0c;编辑部对投稿要求和收稿方向有着严格的规定。 首…

Postman接口测试详解与进阶

Postman是一个功能强大的接口测试工具&#xff0c;它主要用于模拟用户发起的各类HTTP请求&#xff0c;从而验证响应中的结果数据是否和预期值相匹配。以下是关于Postman的详细介绍&#xff1a; Postman是一个功能全面、使用便捷、支持多种HTTP请求类型、提供丰富的测试数据和配…

铝型材挤压车间的数字孪生应用

图扑利用数字孪生技术&#xff0c;在铝型材挤压车间实现了生产线的全方位实时监控和优化。通过高精度三维建模和数据可视化&#xff0c;提升了效率和管理透明度&#xff0c;促进了智能制造和资源配置的优化。

【2024亲测无坑】在Centos.7虚拟机上安装Oracle 19C

目录 一、安装环境准备 1、linux虚拟机安装 2、虚拟机快照 3、空间检查&软件上传 二、Oracle软件安装 1.preinstall安装及其他配置准备 2.oracle安装 三、数据库实例的安装 1.netca——网络配置助手 2.dbca——数据库配置助手 四、ORACLE 19C 在linux centos 7上…

c++qt合并两张灰度图像

需求&#xff1a;将两张尺寸相同的灰度图像进行合并&#xff0c;合并后的图像&#xff0c;每个像素点灰度值为两张原图对应像素点灰度值之和。若超过255&#xff0c;则最大为255。 方法一&#xff1a; 将图像读取为cv::Mat&#xff0c;再调用opencv的cv::add方法&#xff0c;进…

Electron快速入门(一):用VS Code快速创建html+js+css编写的项目

创建一个文件夹&#xff08;例如&#xff1a;start或者create-electron 都是小写英文字母有的插件才不会报错&#xff09;&#xff0c;并进入该文件夹&#xff0c;打开 vscode创建3个文件&#xff1a; 1. 名为 main.js 的文件是主进程 // main.js//用于控制应用程序寿命和创建…

网络安全的双刃守护:揭秘双算法SSL证书的智慧盾牌

双算法SSL证书&#xff0c;这一科技与智慧的结晶&#xff0c;如同夜空中最亮的双子星&#xff0c;照亮了数据传输的幽径。它不仅继承了传统SSL证书的精髓&#xff0c;确保信息在传递过程中的私密与完整&#xff0c;更创新性地融合了两种顶尖加密算法——RSA与SM2&#xff0c;犹…

gateway整合sentinel限流

官方文档&#xff1a;https://github.com/alibaba/Sentinel/wiki/%E7%BD%91%E5%85%B3%E9%99%90%E6%B5%81 从 1.6.0 版本开始&#xff0c;Sentinel 提供了 Spring Cloud Gateway 的适配模块&#xff0c;可以提供两种资源维度的限流&#xff1a; route 维度&#xff1a;即在 Spr…

STM32的通用定时器中断编程

如果遇到需要单片机产生严格时序的场景&#xff08;比如DAC输出特定模拟信号&#xff0c;GPIO口控制模拟开关&#xff09;&#xff0c;延时函数可能就无法胜任了。最近在工作时公司上级教会了我使用“门票”思维&#xff08;中断标志位)编写单片机裸机程序&#xff0c;今天写一…

预制舱变电站高压室巡检机器人系统

一、背景 预制舱变电站高压室由于空间狭小、设备紧凑&#xff0c;传统的巡检方式往往需要人工进入高压室进行巡检&#xff0c;不仅存在安全风险&#xff0c;而且巡检效率低下&#xff0c;难以满足日益增长的电力设备运维需求。 二、预制舱高压室巡检机器人系统 预制舱高压室巡…

QT MQTT (二)编译与集成

一、QT MQTT 提供 MQTT 客户端服务的 Qt 专用库基于标准化发布 / 订阅协议&#xff0c;用于在设备和组件之间可靠地共享数据。MQTT 是为保证状态正确性、满足高安全标准和交换最小数据而设计的协议&#xff0c;因此被广泛应用于各种分布式系统和物联网解决方案中。 Qt开发MQT…

【SAP Abap】一条SQL语句实现支持报表项配置的财务报表

【SAP Abap】一条SQL语句实现支持报表项配置的财务报表 1、业务背景2、配置项特殊处理3、实现方式&#xff08;Hana Studio SQL语句&#xff09;4、实现方式&#xff08;Abap OpenSQL语句&#xff09;5、总结 1、业务背景 在财务三大报表之外&#xff0c;业务需要使用类似的科…

[创业之路-121] :制造业企业的必备管理神器-ERP-企业唯一的盈利入口:销售管理

目录 一、ERP销售管理&#xff1a;卖产品 1.1 概述 1.2 核心功能 1. 客户管理&#xff1a; 2. 销售订单管理&#xff1a;最重要的功能**** 3. 销售发货管理&#xff1a; 4. 销售退货管理&#xff1a; 5. 销售统计分析&#xff1a; 二、用友ERP销售管理 2.1 概述 2.2…

UniApp 开发微信小程序教程(一):准备工作和环境搭建,项目结构和配置

文章目录 一、准备工作和环境搭建1. 安装 HBuilderX步骤&#xff1a; 2. 注册微信开发者账号步骤&#xff1a; 3. 创建 UniApp 项目步骤&#xff1a; 二、项目结构和配置1. UniApp 项目结构2. 配置微信小程序修改 manifest.json修改 pages.json 3. 添加首页文件index.vue 示例&…

Lynred在欧洲防务展上将展出新品——“HOT”红外传感器Seegnus。

Lynred在即将举办的巴黎欧洲防务展上将展出其令人瞩目的新品——“HOT”红外传感器Seegnus。这款专为战术视觉设计的大型阵列传感器&#xff0c;以其紧凑的封装和高分辨率的中波红外成像能力&#xff0c;无疑将为航空航天、国防和商业市场带来革命性的突破。 Seegnus传感器拥有…

【经典算法】LeetCode 8. 字符串转换整数 (atoi)(Java/C/Python3/Go实现含注释说明,Easy)

作者主页&#xff1a; &#x1f517;进朱者赤的博客 精选专栏&#xff1a;&#x1f517;经典算法 作者简介&#xff1a;阿里非典型程序员一枚 &#xff0c;记录在大厂的打怪升级之路。 一起学习Java、大数据、数据结构算法&#xff08;公众号同名&#xff09; ❤️觉得文章还…

蔚来汽车AI算法工程师,如何理解注意力?

大家好啊&#xff0c;我是董董灿。 今天分享一个上海蔚来汽车的AI算法岗位面试经验总结帖&#xff0c;面试岗位为算法工程师。 这次面试提到的问题&#xff0c;除了与实习相关内容和反问之外&#xff0c;面试官总共问了8个问题&#xff0c;主要集中在深度学习基础概念的理解上…

裁员裁到大动脉,是一种什么体验!

大家好啊&#xff0c;我是董董灿。 降本增效是每个当老板的人都喜欢挂在嘴边的口头禅&#xff0c;尤其是行业不景气&#xff0c;公司发展遇到瓶颈的时候。 大部分公司降本增效的手段其实非常相似&#xff0c;比较容易实施的手段也就那几种。 要么搞设备自动化和流程自动化&a…