【c语言】飞机大战(1)

提前准备好游戏要的素材,可以到爱给网去找,飞机大战我们需要的是一个我方战机图片,一个背景图,三个敌方战机的图,我方战机的图片,敌方战机的图片,并且将图片和.cpp放在同一文件夹下.
在这里插入图片描述
这里创建.cpp的文件是因为要用到图形库,所以创建.cpp的文件,然后图片格式都是png

1.我方飞机和背景图片的加载和贴图

#include<stdio.h>
#include <graphics.h>//图形库头文件
#define HEIGHT  503
#define WIDTH 700
IMAGE img_bk, img_plane;//定义背景图片,玩家的类




int main()
{
	initgraph(WIDTH, HEIGHT);//初始化游戏的背景
	loadimage(&img_bk, "./back.png");//加载游戏背景图
	loadimage(&img_plane, "./1.png");//加载游戏玩家图片
	putimage(0, 0, &img_bk);//贴游戏背景图
	putimage(200,200, &img_plane);//贴玩家战机的图片


	getchar();//防止窗口闪退









}

背景图片是503*700,背景图片大小自己设置,为了让游戏体验感增强,如果铺满整个屏幕的话,会不好移动.
在这里插入图片描述

2.去掉飞机背后的黑色背景,使用一个算法函数

#include<stdio.h>
#include <graphics.h>
#define HEIGHT  503
#define WIDTH 700
IMAGE img_bk, img_plane;
void drawAlpha(IMAGE* picture, int  picture_x, int picture_y) //x为载入图片的X坐标,y为Y坐标
{
	// 变量初始化
	DWORD* dst = GetImageBuffer();    // GetImageBuffer()函数,用于获取绘图设备的显存指针,EASYX自带
	DWORD* draw = GetImageBuffer();
	DWORD* src = GetImageBuffer(picture); //获取picture的显存指针
	int picture_width = picture->getwidth(); //获取picture的宽度,EASYX自带
	int picture_height = picture->getheight(); //获取picture的高度,EASYX自带
	int graphWidth = getwidth();       //获取绘图区的宽度,EASYX自带
	int graphHeight = getheight();     //获取绘图区的高度,EASYX自带
	int dstX = 0;    //在显存里像素的角标

	// 实现透明贴图 公式: Cp=αp*FP+(1-αp)*BP , 贝叶斯定理来进行点颜色的概率计算
	for (int iy = 0; iy < picture_height; iy++)
	{
		for (int ix = 0; ix < picture_width; ix++)
		{
			int srcX = ix + iy * picture_width; //在显存里像素的角标
			int sa = ((src[srcX] & 0xff000000) >> 24); //0xAArrggbb;AA是透明度
			int sr = ((src[srcX] & 0xff0000) >> 16); //获取RGB里的R
			int sg = ((src[srcX] & 0xff00) >> 8);   //G
			int sb = src[srcX] & 0xff;              //B
			if (ix >= 0 && ix <= graphWidth && iy >= 0 && iy <= graphHeight && dstX <= graphWidth * graphHeight)
			{
				if ((ix + picture_x) >= 0 && (ix + picture_x) <= graphWidth)	//防止出边界后循环显示
				{
					dstX = (ix + picture_x) + (iy + picture_y) * graphWidth; //在显存里像素的角标
					int dr = ((dst[dstX] & 0xff0000) >> 16);
					int dg = ((dst[dstX] & 0xff00) >> 8);
					int db = dst[dstX] & 0xff;
					draw[dstX] = ((sr * sa / 255 + dr * (255 - sa) / 255) << 16)  //公式: Cp=αp*FP+(1-αp)*BP  ; αp=sa/255 , FP=sr , BP=dr
						| ((sg * sa / 255 + dg * (255 - sa) / 255) << 8)         //αp=sa/255 , FP=sg , BP=dg
						| (sb * sa / 255 + db * (255 - sa) / 255);              //αp=sa/255 , FP=sb , BP=db
				}
			}
		}
	}
}



int main()
{
	initgraph(WIDTH, HEIGHT);
	loadimage(&img_bk, "./back.png");
	loadimage(&img_plane, "./1.png");

	putimage(0, 0, &img_bk);//贴背景前两个为图片左上角要贴在窗口的坐标
	drawAlpha(&img_plane, 200, 200);//贴飞机图片


	getchar();









}

这个函数我看不懂,是在网上搜的,我来解释一下三个参数,第一个是图片的地址,第二个参数,第三个参数的坐标是图片左上角从窗口的哪个位置贴,背景肯定是从窗口的左上角贴.
在这里插入图片描述
在这里插入图片描述
注意:使用这个函数在飞机移动屏幕过程中,会出现异常,不知道怎么解决,希望有大佬可以帮帮我,drawAlpha区别putimage可以把背景变透明

3.静态显示所有素材图片

#include<stdio.h>
#include <graphics.h>
#define HEIGHT  503
#define WIDTH 700
IMAGE img_bk, img_plane, img_a, img_b, img_c,img_abullet,img_bbullet,img_cbullet,img_planebullet;
struct aircraft 
{
	int x, y;







};
aircraft plane, a, b, c;
void datainit()
{
	plane = { 150,150 };
	a = { 0,0 };
	b = { 300,0 };
	c = { 450,0 };












}
void drawAlpha(IMAGE* picture, int  picture_x, int picture_y) //x为载入图片的X坐标,y为Y坐标
{
	// 变量初始化
	DWORD* dst = GetImageBuffer();    // GetImageBuffer()函数,用于获取绘图设备的显存指针,EASYX自带
	DWORD* draw = GetImageBuffer();
	DWORD* src = GetImageBuffer(picture); //获取picture的显存指针
	int picture_width = picture->getwidth(); //获取picture的宽度,EASYX自带
	int picture_height = picture->getheight(); //获取picture的高度,EASYX自带
	int graphWidth = getwidth();       //获取绘图区的宽度,EASYX自带
	int graphHeight = getheight();     //获取绘图区的高度,EASYX自带
	int dstX = 0;    //在显存里像素的角标

	// 实现透明贴图 公式: Cp=αp*FP+(1-αp)*BP , 贝叶斯定理来进行点颜色的概率计算
	for (int iy = 0; iy < picture_height; iy++)
	{
		for (int ix = 0; ix < picture_width; ix++)
		{
			int srcX = ix + iy * picture_width; //在显存里像素的角标
			int sa = ((src[srcX] & 0xff000000) >> 24); //0xAArrggbb;AA是透明度
			int sr = ((src[srcX] & 0xff0000) >> 16); //获取RGB里的R
			int sg = ((src[srcX] & 0xff00) >> 8);   //G
			int sb = src[srcX] & 0xff;              //B
			if (ix >= 0 && ix <= graphWidth && iy >= 0 && iy <= graphHeight && dstX <= graphWidth * graphHeight)
			{
				if ((ix + picture_x) >= 0 && (ix + picture_x) <= graphWidth)	//防止出边界后循环显示
				{
					dstX = (ix + picture_x) + (iy + picture_y) * graphWidth; //在显存里像素的角标
					int dr = ((dst[dstX] & 0xff0000) >> 16);
					int dg = ((dst[dstX] & 0xff00) >> 8);
					int db = dst[dstX] & 0xff;
					draw[dstX] = ((sr * sa / 255 + dr * (255 - sa) / 255) << 16)  //公式: Cp=αp*FP+(1-αp)*BP  ; αp=sa/255 , FP=sr , BP=dr
						| ((sg * sa / 255 + dg * (255 - sa) / 255) << 8)         //αp=sa/255 , FP=sg , BP=dg
						| (sb * sa / 255 + db * (255 - sa) / 255);              //αp=sa/255 , FP=sb , BP=db
				}
			}
		}
	}
}
void load()
{
	loadimage(&img_bk, "./back.png");
	loadimage(&img_plane, "./1.png");
	loadimage(&img_a, "./2.png");
	loadimage(&img_b, "./3.png");
	loadimage(&img_c, "./4.png");
	loadimage(&img_abullet, "./5.png");
	loadimage(&img_bbullet, "./6.png");
	loadimage(&img_cbullet, "./7.png");
	loadimage(&img_planebullet, "./8.png");


}
void draw()
{
	putimage(0, 0, &img_bk);
	drawAlpha(&img_plane,plane.x,plane.y);
	drawAlpha(&img_a, a.x, a.y);
	drawAlpha(&img_b, b.x, b.y);
	drawAlpha(&img_c, c.x, c.y);
	drawAlpha(&img_abullet,400,0 );//后两个参数是图片左上角在窗口要贴的位置
	drawAlpha(&img_bbullet,400 ,50 );
	drawAlpha(&img_cbullet, 400, 100);
	drawAlpha(&img_planebullet, 400, 150);




}


int main()
{
	initgraph(WIDTH, HEIGHT);
	datainit();
	load();
	draw();

	


	getchar();









}

定义3个敌方战机,a,b,c,3个敌机的子弹abullet,bbullet,cbullet,我方战机的子弹planebullet
IMAGE img_a, img_b, img_c,img_abullet,img_bbullet,img_cbullet,img_planebullet;
定义一个结构体记录每个图片左上角要贴在窗口的坐标.四个结构体表示我方战机,3个敌方战机在窗口上的坐标,图中的初始化只是为了让图片不重叠而已。
将加载图片的函数统一放在load函数里面,将贴图片的函数放在draw中.
在这里插入图片描述

4.我方飞机的移动

void player_move(int speed) //处理飞机移动
{

	if (GetAsyncKeyState(VK_UP) || GetAsyncKeyState('W'))
	{
		if (plane.y > 0)
			plane.y -= speed;
	}
	if (GetAsyncKeyState(VK_DOWN) || GetAsyncKeyState('S'))
	{
		if (plane.y + 126< HEIGHT)
			plane.y += speed;
	}
	if (GetAsyncKeyState(VK_LEFT) || GetAsyncKeyState('A'))
	{
		if (plane.x > 0)
			plane.x -= speed;
	}
	if (GetAsyncKeyState(VK_RIGHT) || GetAsyncKeyState('D'))
	{
		if (plane.x + 51 < WIDTH)
			plane.x += speed;
	}
}

这个移动函数在之前游戏里用了好多次,这里就不强调了.函数中的speed参数是我方战机的速度,每按一次会移动几个像素.这里的重点放在飞机边界的判断上,记得加双缓冲,要不然,屏幕会闪
在这里插入图片描述

在这里插入图片描述

边界的判断以及飞机的移动

	if (GetAsyncKeyState(VK_DOWN) || GetAsyncKeyState('S'))
	{
		if (plane.y + 126< HEIGHT)
			plane.y += speed;
	}

这里加126是为了不让程序出现异常,如果正常的话应该加51,因为我方战机图片大小是51*51;如果是51的话会出现如下视频的错误,不知道为什么,请看vcr

5.敌方战机的移动

首先我们要修改一下飞机结构体的变量

struct aircraft
{
	int x, y;
	int width;//敌机图片的宽度
	int height;//敌机图片的高度
	int speed;//敌机的速度
	int bornflag;//敌机在窗口里面置0,在外面置1

};

然后修改一下初始话敌机的属性.

void datainit()
{
	plane = { 150,150 };
	//a = { 0,0 };
	/*b = { 300,0 };*/
	/*c = { 450,0 };*/
	a.speed = 1;//a敌机的速度
	a.bornflag = 1;//a敌机是否存在
	b.bornflag = 1;
	c.bornflag = 1;
	a.width = 100;//a敌机的宽度
	a.height = 100;//a敌机的高度
	b.speed = 1;
	b.width = 80;
	b.height = 100;
	c.height = 70;
	c.width = 70;
	c.speed = 3;











}

敌机a的移动

敌机a的移动

如视频所示,对应的代码实现是

void ufoamove()
{
	static int dir1 = 1;


	if (a.bornflag == 1)
	{
		a.bornflag = 0;
		a.x = rand() % (WIDTH - a.width);
		a.y = -50;




	}
	if (a.y > 200)
	{
		dir1 = 0;
	}
	else if (a.y < -150)
	{
		dir1 = 1;
		a.bornflag = 1;
	}
	if (1 == dir1)
	{
		a.y += a.speed;

	}
	else
	{
		a.y -= a.speed;
	}













}

定义一个静态变量dir,dir为1的话,表示敌机前进,dir为0,敌机后退。因为是static,所以只有第一次初始化时候是1,别的时候不执行第一句.当敌机a没在窗口里面,说明a.bornflag == 1,就将a.bornflag 置为0,敌机a要出现了,随机数生成敌机a要出现的左右方向哪个地方,y=-50;是为了初始化的时候隐藏飞机.当敌机a前进200个像素时,dir置0,让敌机a后退.当敌机向上退出屏幕50个像素时,重新dir=1;敌机向前.此时会出现在另一个位置。在主函数中加入产生随机种子函数

srand(time(NULL));

包含头文件

#include<time.h>
#include<stdlib.h>

敌机出屏幕,drawAlpha这个函数会出错,所以我们把draw中的drawAlpha都改成putimage,这样黑框框又出现了,(电子叹气)

void draw()
{
	putimage(0, 0, &img_bk);
	putimage(plane.x, plane.y ,&img_plane );
		putimage(a.x, a.y ,&img_a);
		putimage(b.x, b.y ,&img_b );
		putimage(c.x, c.y, &img_c );
		putimage(400, 0 ,&img_abullet );
		putimage(400, 50 ,&img_bbullet);
		putimage(400, 100 ,&img_cbullet );
		putimage(400, 150, &img_planebullet );




}

敌机b的移动

请看vcr

敌机b的移动

对应代码

void ufobmove()
{
	static int step = b.speed;
	if (b.bornflag == 1)
	{
		b.bornflag = 0;
		b.x = rand() % (WIDTH - b.width);
		b.y = -b.height;




	}
	if (b.x <= 0 || b.x + b.width >= WIDTH)
	{
		step = -step;



	}
	b.x += step;
	b.y++;
	if (b.y >= HEIGHT)
	{
		b.bornflag = 1;


	}








}

由视频可知敌机b的移动规律是在左右移动的同时还向前移动,step如果为正,向右移动,step如果为负,表示向左移动,如果b战机没有出现在窗口内(b.bornflag == 1),将b.bornflag 置0,表示要出现,随机数生成b战机的坐标.y=-b.height;初始化先隐藏起来.如果b战机到了左右边界,step=-step;
就向相反的方向移动了,左右移动实质是在给b.x±step;然后y++,b战机在左右移动的过程中,一直往前走.当b战机出了下边界,b.bornflag = 1;表示b战机出了窗口.

敌机c的移动

请看vcr

敌机c的移动

对应的代码为

void ufocmove()
{


	static float disx = 0, disy = 0;
	static float tmpx = 0, tmpy = 0;
	static float vx = 0, vy = 0;
	float step = 1000 / c.speed;
	if (1 == c.bornflag)
	{
		c.bornflag = 0;
		tmpx = rand() % (WIDTH - c.width);
		tmpy = -c.height;
		disx = plane.x - tmpx;
		disy = plane.y - tmpy;
		vx = disx / step;
		vy = disy / step;




	}
	tmpx += vx;
	tmpy += vy;
	c.x = (int)(tmpx + 0.5);
	c.y = (int)(tmpy + 0.5);
	if (c.x < -c.width)
	{
		c.bornflag = 1;
	}
	else if (c.x > WIDTH)
	{
		c.bornflag = 1;

	}
	if (c.y > HEIGHT)
	{
		c.bornflag = 1;

	}






}

这个c战机是要撞向我方飞机,tmpx,tmpy存放的是c战机的临时的位置,刚生成时,当然是他出生点的坐标,disx是c战机刚出来x方向上与当时我方战机x方向上的距离,同理另一个.step是,假如c.speed的速度为5的话,step==200,就是说将x方向上的距离分为200份,vx就是每一份的距离是多少像素,这里强制类型转化,c.x,c.y是整数,因为vx,vy不清楚,所以+0.5,四舍五入一下就是整数了.如果在左,右,下方向超出了,就c.bornflag = 1;离开窗口了.

6.整体代码展示

#include<stdio.h>
#include <graphics.h>
//#include<conio.h>//_getch();
#define HEIGHT  503
#define WIDTH 700
IMAGE img_bk, img_plane, img_a, img_b, img_c, img_abullet, img_bbullet, img_cbullet, img_planebullet;
struct aircraft
{
	int x, y;
	int width;
	int height;
	int speed;
	int bornflag;

};
aircraft plane, a, b, c;
void datainit()
{
	plane = { 150,150 };
	//a = { 0,0 };
	/*b = { 300,0 };*/
	/*c = { 450,0 };*/
	a.speed = 1;
	a.bornflag = 1;
	b.bornflag = 1;
	c.bornflag = 1;
	a.width = 100;
	a.height = 100;
	b.speed = 1;
	b.width = 80;
	b.height = 100;
	c.height = 70;
	c.width = 70;
	c.speed = 3;











}
void drawAlpha(IMAGE* picture, int  picture_x, int picture_y) //x为载入图片的X坐标,y为Y坐标
{
	// 变量初始化
	DWORD* dst = GetImageBuffer();    // GetImageBuffer()函数,用于获取绘图设备的显存指针,EASYX自带
	DWORD* draw = GetImageBuffer();
	DWORD* src = GetImageBuffer(picture); //获取picture的显存指针
	int picture_width = picture->getwidth(); //获取picture的宽度,EASYX自带
	int picture_height = picture->getheight(); //获取picture的高度,EASYX自带
	int graphWidth = getwidth();       //获取绘图区的宽度,EASYX自带
	int graphHeight = getheight();     //获取绘图区的高度,EASYX自带
	int dstX = 0;    //在显存里像素的角标

	// 实现透明贴图 公式: Cp=αp*FP+(1-αp)*BP , 贝叶斯定理来进行点颜色的概率计算
	for (int iy = 0; iy < picture_height; iy++)
	{
		for (int ix = 0; ix < picture_width; ix++)
		{
			int srcX = ix + iy * picture_width; //在显存里像素的角标
			int sa = ((src[srcX] & 0xff000000) >> 24); //0xAArrggbb;AA是透明度
			int sr = ((src[srcX] & 0xff0000) >> 16); //获取RGB里的R
			int sg = ((src[srcX] & 0xff00) >> 8);   //G
			int sb = src[srcX] & 0xff;              //B
			if (ix >= 0 && ix <= graphWidth && iy >= 0 && iy <= graphHeight && dstX <= graphWidth * graphHeight)
			{
				if ((ix + picture_x) >= 0 && (ix + picture_x) <= graphWidth)	//防止出边界后循环显示
				{
					dstX = (ix + picture_x) + (iy + picture_y) * graphWidth; //在显存里像素的角标
					int dr = ((dst[dstX] & 0xff0000) >> 16);
					int dg = ((dst[dstX] & 0xff00) >> 8);
					int db = dst[dstX] & 0xff;
					draw[dstX] = ((sr * sa / 255 + dr * (255 - sa) / 255) << 16)  //公式: Cp=αp*FP+(1-αp)*BP  ; αp=sa/255 , FP=sr , BP=dr
						| ((sg * sa / 255 + dg * (255 - sa) / 255) << 8)         //αp=sa/255 , FP=sg , BP=dg
						| (sb * sa / 255 + db * (255 - sa) / 255);              //αp=sa/255 , FP=sb , BP=db
				}
			}
		}
	}
}
void load()
{
	loadimage(&img_bk, "./back.png");
	loadimage(&img_plane, "./1.png");
	loadimage(&img_a, "./2.png");
	loadimage(&img_b, "./3.png");
	loadimage(&img_c, "./4.png");
	loadimage(&img_abullet, "./5.png");
	loadimage(&img_bbullet, "./6.png");
	loadimage(&img_cbullet, "./7.png");
	loadimage(&img_planebullet, "./8.png");


}
void draw()
{
	putimage(0, 0, &img_bk);
	putimage(plane.x, plane.y ,&img_plane );
		putimage(a.x, a.y ,&img_a);
		putimage(b.x, b.y ,&img_b );
		putimage(c.x, c.y, &img_c );
		putimage(400, 0 ,&img_abullet );
		putimage(400, 50 ,&img_bbullet);
		putimage(400, 100 ,&img_cbullet );
		putimage(400, 150, &img_planebullet );




}
void player_move(int speed) //处理飞机移动
{

	if (GetAsyncKeyState(VK_UP) || GetAsyncKeyState('W'))
	{
		if (plane.y > 0)
			plane.y -= speed;
	}
	if (GetAsyncKeyState(VK_DOWN) || GetAsyncKeyState('S'))
	{
		if (plane.y + 51< HEIGHT)
			plane.y += speed;
	}
	if (GetAsyncKeyState(VK_LEFT) || GetAsyncKeyState('A'))
	{
		if (plane.x > 0)
			plane.x -= speed;
	}
	if (GetAsyncKeyState(VK_RIGHT) || GetAsyncKeyState('D'))
	{
		if (plane.x + 51 < WIDTH)
			plane.x += speed;
	}
}
void ufoamove()
{
	static int dir1 = 1;


	if (a.bornflag == 1)
	{
		a.bornflag = 0;
		a.x = rand() % (WIDTH - a.width);
		a.y = -50;




	}
	if (a.y > 200)
	{
		dir1 = 0;
	}
	else if (a.y < -150)
	{
		dir1 = 1;
		a.bornflag = 1;
	}
	if (1 == dir1)
	{
		a.y += a.speed;

	}
	else
	{
		a.y -= a.speed;
	}













}
void ufobmove()
{
	static int step = b.speed;
	if (b.bornflag == 1)
	{
		b.bornflag = 0;
		b.x = rand() % (WIDTH - b.width);
		b.y = -b.height;




	}
	if (b.x <= 0 || b.x + b.width >= WIDTH)
	{
		step = -step;



	}
	b.x += step;
	b.y++;
	if (b.y >= HEIGHT)
	{
		b.bornflag = 1;


	}








}
void ufocmove()
{


	static float disx = 0, disy = 0;
	static float tmpx = 0, tmpy = 0;
	static float vx = 0, vy = 0;
	float step = 1000 / c.speed;
	if (1 == c.bornflag)
	{
		c.bornflag = 0;
		tmpx = rand() % (WIDTH - c.width);
		tmpy = -c.height;
		disx = plane.x - tmpx;
		disy = plane.y - tmpy;
		vx = disx / step;
		vy = disy / step;




	}
	tmpx += vx;
	tmpy += vy;
	c.x = (int)(tmpx + 0.5);
	c.y = (int)(tmpy + 0.5);
	if (c.x < -c.width)
	{
		c.bornflag = 1;
	}
	else if (c.x > WIDTH)
	{
		c.bornflag = 1;

	}
	if (c.y > HEIGHT)
	{
		c.bornflag = 1;

	}






}

int main()
{
	initgraph(WIDTH, HEIGHT);
	BeginBatchDraw();
	datainit();
	while (1)
	{
		load();
		draw();
		ufoamove();
		ufobmove();
		ufocmove();
		player_move(5);
		FlushBatchDraw();
	}
	EndBatchDraw();


	getchar();









}

7.剩下实现放在下一篇啦

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【qt】解决qt里编辑qss后失效问题(qt编码问题)

1、先创建qss文本stylesheet.qss 以按钮为例 QPushButton {background-color:rgb(240,255,255);color: rgb(0, 0, 2);border-style: outset;border-color: beige;border-radius: 10px; }/* hover按钮悬浮&#xff0c;鼠标悬浮在按钮上的状态&#xff0c;按钮颜色 */QPushButto…

数据结构之树 --- 二叉树

目录 定义二叉树的结构体 二叉树的遍历 递归遍历 非递归遍历 链式二叉树的实现 二叉树的功能接口 先序遍历创建二叉树 后序遍历销毁二叉树 先序遍历查找树中值为x的节点 层序遍历 上篇我们对二叉树的顺序存储堆进行了讲述&#xff0c;本文我们来看链式二叉树。 定…

高斯泼溅的全面概述

一、说明 高斯泼溅是一种用于表示 3D 场景和渲染新颖视图的方法&#xff0c;在“实时辐射场渲染的 3D 高斯泼溅”中引入。它可以被认为是 NeRF 类模型的替代品&#xff0c;就像当年的 NeRF 一样&#xff0c;高斯分布导致了许多新的研究工作&#xff0c;这些工作选择将其用作各种…

线上隐私保护的未来:分布式身份DID的潜力

在日益数字化的世界中&#xff0c;人们的生活越来越多地依赖于互联网&#xff0c;数字身份也因而变得越来越重要。根据法律规定&#xff0c;互联网应用需要确认用户的真实身份才能提供各种服务&#xff0c;而用户则希望在进行身份认证的同时能够尽量保护他们的个人隐私&#xf…

OpenHarmony 应用通用签名

一.背景 由于hap包需要经过签名才能安装到设备上&#xff0c;在DevEco Studio可以进行自动签名&#xff0c;但是自动签名只能安装在当前的设备上&#xff0c;在其他设备上不能安装&#xff0c;所以我们需要进行通用的手动签名&#xff0c;手动签名HarmonyOS和OpenHarmony流程是…

Windows Sockets 2 笔记

文章目录 一、Winsock简介二、Windows中Winsock对网络协议支持的情况三、使用Winsock3.1 关于服务器和客户端3.2 创建基本Winsock应用程序3.3 初始化Winscok3.3.1 初始化步骤3.3.2 初始化的核心代码3.3.3 WSAStartup函数的协调3.3.4 WSACleanup函数3.3.5 初始化的完整代码 3.4 …

Python基础进阶3:函数和方法不是一回事

你好&#xff0c;我是kelly&#xff0c;今天分享的是Python的函数与方法的不同点。 对于Python的函数和方法是不一样的&#xff0c;这一点需要注意下。 一、结论 1、不存在隐式传参&#xff0c;所有参数都是显式传递的是函数。 2、存在隐式传参的是方法&#xff0c;一般指隐式…

懒加载的el-tree中没有了子节点之后还是有前面icon箭头的展示,如何取消没有子节点之后的箭头显示

没有特别多的数据 <template><el-tree:props"props":load"loadNode"lazyshow-checkbox></el-tree></template><script>export default {data() {return {props: {label: name,children: zones,isLeaf:"leaf",//关…

Matlab:BP神经网络算法,二叉决策树

1、BP神经网络算法 (1)步骤 1.准备训练数据和目标值 2.创建并配置BP神经网络模型 3.训练BP神经网络模型 4.用BP神经网络模型预测数据 例&#xff1a;某企业第一年度营业额为132468&#xff0c;第二年度为158948&#xff0c;第三年度为183737&#xff0c;预测第四年度的营…

VSCode Python开发环境配置

目录 1 插件安装2 Debug和测试配置常见问题 1 插件安装 1.1 基础编译插件&#xff0c;Python、Pylance 1.2 修改语言服务器类型&#xff0c;进入用户配置页面搜索Python: Language Server&#xff0c;选择Pylance&#xff08;一定要修改可以提供很多语法提示&#xff09; 1…

4.21 构建onnx结构模型-Resize

前言 构建onnx方式通常有两种&#xff1a; 1、通过代码转换成onnx结构&#xff0c;比如pytorch —> onnx 2、通过onnx 自定义结点&#xff0c;图&#xff0c;生成onnx结构 本文主要是简单学习和使用两种不同onnx结构&#xff0c; 下面以 Resize 结点进行分析 方式 方法一…

如何编译代码,把RustDesk主页面背景白色改成自己想要的图片

环境&#xff1a; RustDesk1.1.9自建服务器 问题描述&#xff1a; 如何编译代码&#xff0c;把RustDesk主页面背景白色改成自己想要的图片 解决方案&#xff1a; 详细方案&#xff0c;有需要私聊

启动springboot时报错 APPLICATION FAILED TO START 包冲突

启动springboot时报错 APPLICATION FAILED TO START 包冲突 problem 具体日志如下 *************************** APPLICATION FAILED TO START ***************************Description:An attempt was made to call a method that does not exist. The attempt was made fr…

【Java 进阶篇】Redis 缓存优化:提升应用性能的不二选择

在现代的软件开发中&#xff0c;性能一直是开发者们追求的目标之一。对于数据库访问频繁、数据读取较慢的场景&#xff0c;使用缓存是提升性能的有效手段之一。而 Redis 作为一款高性能的内存数据库&#xff0c;被广泛用作缓存工具。本文将围绕 Redis 缓存优化进行详解&#xf…

JMX使用详解

JMX简介JMX优缺点JMX的功能JMX的用法JMX和Activiti的区别JMX使用案例JMX架构JMX支持的协议JMX工作原理JMX主要方法JMX中的MBean的注册JMX拓展SNMP网络管理协议TMN网络管理协议CIM网络管理协议Activiti JMX简介 JMX&#xff08;Java Management Extensions&#xff0c;即Java管…

拍照就能建模!手机就能访问! 这个技术正成为宣传新手段!

随着人工智能技术的不断进步&#xff0c;现在可以通过拍摄照片结合AI技术来实现3D模型生成。这种技术的出现&#xff0c; 不仅能更加方便快捷地创建3D模型&#xff0c;而且还能真实复原现实中物件的质感、纹理等。同时&#xff0c;极大地降低了各行业对3D技术的应用门槛&#x…

Baumer工业相机堡盟工业相机如何通过NEOAPI SDK设置相机的固定帧率(C#)

Baumer工业相机堡盟工业相机如何通过NEOAPI SDK设置相机的固定帧率&#xff08;C#&#xff09; Baumer工业相机Baumer工业相机的固定帧率功能的技术背景CameraExplorer如何查看相机固定帧率功能在NEOAPI SDK里通过函数设置相机固定帧率 Baumer工业相机通过NEOAPI SDK设置相机固…

Scrapy使用案例——爬取豆瓣Top 250电影数据

文章目录 什么是Scrapy&#xff1f;创建Scrapy项目编写Scrapy Spider创建Item类配置数据存储运行Scrapy爬虫处理常见问题结论Python技术资源分享1、Python所有方向的学习路线2、学习软件3、入门学习视频4、实战案例5、清华编程大佬出品《漫画看学Python》6、Python副业兼职与全…

用通俗易懂的方式讲解大模型:使用 FastChat 部署 LLM 的体验太爽了

之前介绍了Langchain-Chatchat 项目的部署&#xff0c;该项目底层改用了 FastChat 来提供 LLM(大语言模型)的 API 服务。 出于好奇又研究了一下 FastChat&#xff0c;发现它的功能很强大&#xff0c;可以用来部署市面上大部分的 LLM 模型&#xff0c;可以将 LLM 部署为带有标准…

Sensor Demosaic IP 手册PG286笔记

《 UG1449 Multimedia User Guide》中包含了大量的多媒体IP简介。 本IP 用于对bayer RGB&#xff08;每个pixel只有单个R/G/B&#xff09;做去马赛克处理&#xff0c;恢复成每个pixel点都有完整的RGB值。通过axi接口配置IP内部erg。 1、算法手册中的描述 提到了几种插值算法&…
最新文章