C语言 完整游戏项目坦克大战详细代码

话不多说 我们今天就来创造出属于我们自己的《坦克大战》,GOGOGO!!! 直接开始吧 这次的源码比较详细,我分了好几个cpp文件,思路更加的清晰,请耐心用心的观看

首先就是我们载入图片的函数tupian.cpp

# include "tanke.h"

障碍物
void LaoWang(int * tilex, int * tiley)
{
	IMAGE img;
	loadimage(&img, _T("res\\tile.bmp"));

	putimage(*tilex, *tiley, 32 , 32 , &img, 32 * 5, 0 );

}
void tileHong(int * tilex, int * tiley)
{
	IMAGE img;
	loadimage(&img, _T("res\\tile.bmp"));

	putimage(*tilex, *tiley, 32, 32, &img, 32 * 0,  0 );

	return;

}

void tileLv(int * tilex, int * tiley)
{
	IMAGE img;
	loadimage(&img, _T("res\\tile.bmp"));

	putimage(*tilex, *tiley, 32, 32, &img, 32 * 2, 0 );
	return;
}

void tileBai(int * tilex, int * tiley)
{
	IMAGE img;
	loadimage(&img, _T("res\\tile.bmp"));

	putimage(*tilex, *tiley, 32, 32, &img, 32 * 1, 0 );
	return;
}

void tileBlue(int *tilex, int *tiley)
{
	IMAGE img;
	loadimage(&img, _T("res\\tile.bmp"));

	putimage(*tilex, *tiley, 32, 32, &img, 32 * 3, 0 );
}
//物品
void FaZhang(int *wupinx, int *wupiny)
{
	IMAGE img;
	loadimage(&img, _T("res\\fazhang.jpg"));

	putimage(*wupinx, *wupiny, 24, 24, &img, 0, 0 );
}

void ShouQiang(int *wupinx, int *wupiny)
{
	IMAGE img;
	loadimage(&img, _T("res\\shouqiang.jpg"));

	putimage(*wupinx, *wupiny, 24, 24, &img, 0, 0 );
}

void ShangDian(int *wupinx, int *wupiny)
{
	IMAGE img;
	loadimage(&img,_T("res\\shangdian.jpg"));

	putimage(*wupinx, *wupiny, 32, 32, &img, 0, 0 );
}

void YaoShui(int *wupinx, int *wupiny)
{
	IMAGE img;
	loadimage(&img, _T("res\\yaoshui.jpg"));

	putimage(*wupinx, *wupiny, 28, 28, &img, 0, 0 );
}

void DunPai(int *wupinx, int *wupiny)
{
	IMAGE img;
	loadimage(&img, _T("res\\dunpai.jpg"));

	putimage(*wupinx, *wupiny, 28, 28, &img, 0, 0 );
}

void XieZi(int *wupinx, int *wupiny)
{
	IMAGE img;
	loadimage(&img, _T("res\\xiezi.jpg"));

	putimage(*wupinx, *wupiny, 28, 28, &img, 0, 0 );
}

void Boss(int *wupinx, int *wupiny)
{
	IMAGE img;
	loadimage(&img, _T("res\\boss.jpg"));

	putimage(*wupinx, *wupiny, 32, 32, &img, 0, 0 );
}

void BigBoss(int *wupinx, int *wupiny)
{
	IMAGE img;
	loadimage(&img, _T("res\\bigboss.jpg"));

	putimage(*wupinx, *wupiny, 32, 32, &img, 0, 0 );
}

接下来是初始化的函数waiyuan.cpp

# include "tanke.h"

/外部
void JShengMing(int *j)
{
	setcolor(GREEN);
	settextstyle(0, 0, ("宋体"));
	char c2[20] = "自己生命值:";
	outtextxy(0, 20, c2);

	char c3[10] ;
	sprintf(c3, _T("%.1f"), 100* (60 - *j) / 60.0);
	outtextxy(90, 20, c3);
}

void DShengMing(int * d,int *k)
{
	setcolor(GREEN);
	settextstyle(0, 0, ("宋体"));
	char c2[20] = "敌人生命值:";
	outtextxy(0, 0, c2);

	char c3[10] ;
	sprintf(c3, _T("%.1f"), 100* (60 - *d) / 60.0);
	outtextxy(90, 0, c3);

	char c4[40] = "恭喜~! 现在起金币到2200有惊喜!";//胜利

	if ( *k >= 8000 )
			{
				setcolor(YELLOW);
				settextstyle(30, 0, ("宋体"));

				outtextxy(150, 0, c4);
			}
}

void Gold(int * gold)
{
	setcolor(GREEN);
	settextstyle(0, 0, ("宋体"));
	char c2[20] = "金币:";
	outtextxy(0, 40, c2);

	char c3[10] ;
	sprintf(c3, _T("%d"), *gold);
	outtextxy(40, 40, c3);
}

void start(void)
{
	initgraph(200, 130);

	TCHAR s1[10]="坦克大战";
	TCHAR s2[30]="按A 开始游戏  按B 退出游戏";
	TCHAR s3[30]="按W S A D控制方向";
	TCHAR s4[20]="按J 发射子弹";
	TCHAR s5[20]="按C 看攻略";

	outtextxy(70, 0, s1);
	outtextxy(0,  110, s2);
	outtextxy(60, 90, s5);
	outtextxy(55, 30, s4);
	outtextxy(35, 60, s3);

	while (true)
	{
		Sleep(500);
		if (GetAsyncKeyState('A'))
		{
			BeginBatchDraw();
			closegraph();
			initgraph(640, 480);
			Sleep(200);
			Quit();
			return ;
		}
		if (GetAsyncKeyState('C'))
		{
			Sleep(200);
			GongLue();
		}
	}
}
void GongLue(void)
{
	initgraph(450, 300);
	TCHAR s1[20]="游戏攻略:";
	TCHAR s2[50]="再打坦克之前先吃法杖打掉白色砖块,";
	TCHAR s3[50]="这样敌坦克打白色就不能回血了,boss更应如此。";
	TCHAR s15[70]="吃盾牌的作用就是可以碾压对手";
	TCHAR s4[50]="打大坦克的时候,别和它对子弹这样会吃亏";
	TCHAR s5[70]="可以直接选择上去碾压它 注意:当血足够少的时候走开,";
	TCHAR s6[50]="用子弹打它这样才能得到钱,";
	TCHAR s7[70]="小boss可以反复刷,虽然挣不到钱,但复活次数更需要。";
	TCHAR s14[70]="吃手枪虽然速度快了但伤害会减少,但打绿boss时伤害反而增加";
	TCHAR s8[70]="血要多吃,肯定划算,钱少了好挣,复活少了,就难挣了。";
	TCHAR s9[50]="打终极boss时,记得要用大子弹打它伤害才能打出来。";
	TCHAR s10[90]="最后温馨提示:有块红砖比较可疑~";
	TCHAR s11[40]="最后:别想着跑后面去打终极Boss了";
	TCHAR s12[30]="因为你超过它会直接被秒。";
	TCHAR s13[30]="按A 开始游戏";

	outtextxy(0, 0,  s1);
	outtextxy(0, 20, s2);
	outtextxy(0, 40, s3);
	outtextxy(0, 60, s15);
	outtextxy(0, 80, s4);
	outtextxy(0, 100, s5);
	outtextxy(0, 120, s6);
	outtextxy(0, 140, s14);
	outtextxy(0, 160, s7);
	outtextxy(0, 180, s8);
	outtextxy(0, 200, s9);
	outtextxy(0, 220, s10);
	outtextxy(0, 240, s11);
	outtextxy(0, 260, s12);
	outtextxy(0, 280, s13);

	while (true)
	{
		Sleep(500);
		if (GetAsyncKeyState('A'))
		{
			keybd_event(65,0,0,0);
			keybd_event(65,0,KEYEVENTF_KEYUP,0);
			return ;
		}
	}

}

void MiJi(void)
{
	closegraph();

	printf("游戏秘籍:\n");
	printf("恭喜你通关了,\n");
	printf("告诉你些游戏作弊方法~!。\n");
	printf("当你一直按住子弹不松的话 ,还有直接控制 子弹功能哦~~\n\n");
	printf("哈哈 另外小技巧。打boss前 先把小坦克都压了\n");
	printf("只留一个,因为boss出来 基地就危险了\n");
	printf("还有 有的人 觉得花了600块的大子弹没伤害没用\n");
	printf("我只能说他的用法不对 不是一下一下的点,\n\n");
	printf("而是一直按着然后松开 那伤害高到 爆~!终极boss都打一半血!\n\n");
	printf("还有 就是 就算Gameover了 不算输,我还留了一手\n\n");
	printf("你把所有敌坦克都杀了 再按 Y\n\n");
	printf("这时候你的基地就复活了,\n\n");
	printf("~~嘘~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
	printf("另外:小坦克靠近基地时按Y它就乖乖回去了\n\n");
	printf("按B 游戏结束\n\n");	

	while (true)
	{
		Sleep(500);
		if (GetAsyncKeyState('B'))
		{
			exit(0);
		}
	}

}
void music(void)
{
	mciSendString("open sound\\坦克大战.mp3 alias mymusic", NULL, 0, NULL);
	mciSendString("play mymusic", NULL, 0, NULL);
	return;
}
void start_(void)
{
	music();
	srand( (unsigned)time( NULL ) );//随机种子
	setcolor(GREEN);
	setfillcolor(RED);
}
void win(pHongZhuan phongzhuan,bool *live2, bool *live3, bool *live4, bool *live5,bool *live6,bool *live7,
		 bool *exist_laowang, bool *exist1,
		 bool *wexist1,bool *wexist2,bool *wexist3,bool *wexist8)
{
	char c[10] = "YOU WIN";
	settextcolor(YELLOW);
	settextstyle(80, 0, ("宋体"));
	outtextxy(190, 100, c);
	char c1[20] = "按Y键 进入下一关";
	settextstyle(30, 0, ("宋体"));
	outtextxy(230, 200, c1);
	if (GetAsyncKeyState('Y'))
	{
		*live2 = true;
		*live3 = true;
		*live4 = true;
		*live5 = true;
		*live6 = true;
		*live7 = true;

		*exist_laowang =true;
		*exist1 = true;

		phongzhuan[0].exist = true;
		phongzhuan[1].exist = true;
		*wexist1 = true;
		*wexist2 = true;
		*wexist3 = true;
		*wexist8 = true;
	}
	return ;
}

void lost(bool * live1, int *relive, int *gold)
{
	char c[10] = "YOU LOST";
	settextcolor(YELLOW);
	settextstyle(80, 0, ("宋体"));
	outtextxy(170, 100, c);
	char c1[20] = "按I键 复活,金币-60";
	settextstyle(30, 0, ("宋体"));
	outtextxy(200, 200, c1);

	char c2[20] = "剩余复活次数:";
	outtextxy(220, 230, c2);

	char c3[10] ;
	sprintf(c3, _T("%d"), 2 - *relive);
	outtextxy(426, 230, c3);

	if (GetAsyncKeyState('I'))
	{
		keybd_event(73,0,KEYEVENTF_KEYUP,0);

		(*relive)++;
		*gold -= 60;

		if (*relive < 3)
			*live1 = true;
	}
	if (*relive >= 3)
		GameOver();
	return ;
}

void GameOver(void)
{
	IMAGE img;
	loadimage(&img,_T("res\\gameover.bmp"));

	HDC	dstDC = GetImageHDC();
	HDC	srcDC = GetImageHDC(&img);

	TransparentBlt(dstDC,200,50, 248, 160, srcDC, 0, 0, 248,  160, RGB(0,0,0));
}

bool Quit(void)
{
	if(GetAsyncKeyState('B'))
	{
		if(MessageBox(NULL, "你确定要退出吗?",
			"提示", MB_YESNO) == IDYES)
			return true;

	}
	return false;
}

再然后是效果函数xiaoguo.cpp

# include "tanke.h"

bool LuoShui( int * x_, int * y_, int * tileBlue_x, int *tileBlue_y, int *d,int *gold)
{
	IMAGE imgBoom;
	loadimage(&imgBoom,_T("res\\explode1.bmp"));
	if (*x_ + 14 <= *tileBlue_x + 32 && *x_ + 14 >= *tileBlue_x && *y_ + 14 <= *tileBlue_y + 32 && *y_ + 14 >= *tileBlue_y)
	{
		putimage(*x_, *y_, 28, 28, &imgBoom,0 ,0 );
		(*d)++;
		*gold -= 2; 

		if (*d >= 40)
		{
			*d = 0;
			return false;
		}
	}
	return true;
}

bool BossMiaoRen(int *y_,int *y9)
{

	if (*y_ <= *y9 + 67)
	{
		mciSendString("open sound//boom.mp3 alias mymusic_1", NULL, 0, NULL);
		mciSendString("play mymusic_1", NULL, 0, NULL);
		return false;
	}
	return true;
}

bool HuoWu(int *x_, int *y_, int *wupinx, int *wupiny, int *d, int *HWsd)
{
	IMAGE imgXing;
	loadimage(&imgXing, _T("res\\bore.bmp"));
	if (*x_ + 14 <= *wupinx + 32 && *x_ + 14 >= *wupinx && *y_ + 14 <= *wupiny + 32 && *y_ + 14 >= *wupiny)
	{
		putimage(*x_ - 4, *y_ - 4, 32, 32, &imgXing, 32 * 3 ,0 );
		(*d)++;

		if (*d >= *HWsd)
		{
			if (*HWsd != 0)
				printf("\a");
			*d = 0;
			return false;
		}
	}
	return true;
}

之后是关于子弹的函数zidan.cpp

# include "tanke.h"

坦克 子弹
void JBox(int (*x)[2][3],int * x_, int * y_, int * z,int * r, int * sd, int *zhidan,int *color1)
{
	int h = 0;//图片的方向
	int k , k1, k2;//k循环,k1,k2装有的方向
	IMAGE img;
	loadimage(&img, _T("res\\player1.bmp"));
	if (x[*z + 1][0][1] == 0 &&	x[*z  + 1][0][2] == -1)//w
		h = 0;

	if (x[*z + 1][0][1] == 0 &&	x[*z + 1][0][2] ==  1)//s
		h = 2;

	if (x[*z + 1][0][1] == -1 && x[*z + 1][0][2] ==  0)//a
		h = 3;

	if (x[*z + 1][0][1] == 1 &&	x[*z + 1][0][2] ==  0)//d
		h = 1;

	if (GetAsyncKeyState('J'))//发射子弹
	{
		*z = *z + 1;

		x[*z + 1][0][1] = x[*z ][0][1] ;//x坐标中的方向
		x[*z + 1][0][2] = x[*z ][0][2] ;//

		if (x[*z][0][1] == 0 &&	x[*z][0][2] == -1)//w
		{
			x[*z][0][0] = *x_ + 34;
			x[*z][1][0] = *y_ + 14;
		}
		if (x[*z][0][1] == 0 &&	x[*z][0][2] ==  1)//s
		{
			x[*z][0][0] = *x_ + 34;
			x[*z][1][0] = *y_ + 48;
		}
		if (x[*z][0][1] == -1 && x[*z][0][2] ==  0)//a
		{
			x[*z][0][0] = *x_ + 17;
			x[*z][1][0] = *y_ + 33;
		}
		if (x[*z][0][1] == 1 &&	x[*z][0][2] ==  0)//d
		{
			x[*z][0][0] = *x_ + 48;
			x[*z][1][0] = *y_ + 33;
		}
		keybd_event(74,0,KEYEVENTF_KEYUP,0);
	}
	putimage( *x_,  *y_, 28 , 28 , &img, 28 * (*color1) , 28 * h );

	for (k = 0; k<40; k++)
	{
		k1 = x[k][0][1];
		k2 = x[k][0][2];
		if(*r % *sd == 0)//己方子弹的的速度
		{
			if ( k1 == 1 && k2 == 0 && x[k][0][0] != 0)
				x[k][0][0] = x[k][0][0] + 4;

			if ( k1 == 0 && k2 == 1 && x[k][0][0] != 0)
				x[k][1][0] = x[k][1][0] + 4;

			if ( k1 == -1 && k2 == 0 && x[k][0][0] != 0)
				x[k][0][0] = x[k][0][0] - 4;

			if ( k1 == 0 && k2 == -1 && x[k][0][0] != 0)
				x[k][1][0] = x[k][1][0] - 4;
		}

		if ( (x[k][0][0] -20) >= 640 || (x[k][0][0] - 20)<= 0)
			x[k][0][0] = 0 ;//子弹到边界 就初始化数组坐标x为0
		if ( (x[k][1][0] -20) >= 480 || (x[k][1][0] - 20)<= 0)
			x[k][0][0] = 0 ;

		solidcircle(x[k][0][0] - 20,  x[k][1][0] - 20, *zhidan);
	}

	if (*z >= 38)//数组 要满时就循环
	{
		x[1][0][1] = x[*z ][0][1] ;
		x[1][0][2] = x[*z ][0][2] ;
		x[1][1][1] = x[*z ][1][1] ;
		x[1][1][2] = x[*z ][1][2] ;
		*z = 0;
	}

	return ;
}

void DBox(int (*x)[2][3],int * x_, int * y_, int * z, int *r, int * color)
{
	int h = 0;
	int k , k1, k2;
	IMAGE img;
	loadimage(&img,_T("res\\enemy.bmp"));
	if (x[*z + 1][0][1] == 0 &&	x[*z  + 1][0][2] == -1)//w
		h = 0;

	if (x[*z + 1][0][1] == 0 &&	x[*z + 1][0][2] ==  1)//s
		h = 2;

	if (x[*z + 1][0][1] == -1 && x[*z + 1][0][2] ==  0)//a
		h = 3;

	if (x[*z + 1][0][1] == 1 &&	x[*z + 1][0][2] ==  0)//d
		h = 1;
	if ((*r) % 80 == 0)//敌坦克发子弹频率
	{
		*z = *z + 1;

		x[*z + 1][0][1] = x[*z ][0][1] ;//给方向
		x[*z + 1][0][2] = x[*z ][0][2] ;

		if (x[*z][0][1] == 0 &&	x[*z][0][2] == -1)//w
		{
			x[*z][0][0] = *x_ + 34;
			x[*z][1][0] = *y_ + 14;
		}
		if (x[*z][0][1] == 0 &&	x[*z][0][2] ==  1)//s
		{
			x[*z][0][0] = *x_ + 34;
			x[*z][1][0] = *y_ + 48;

		}
		if (x[*z][0][1] == -1 && x[*z][0][2] ==  0)//a
		{
			x[*z][0][0] = *x_ + 17;
			x[*z][1][0] = *y_ + 33;
		}
		if (x[*z][0][1] == 1 &&	x[*z][0][2] ==  0)//d
		{
			x[*z][0][0] = *x_ + 48;
			x[*z][1][0] = *y_ + 33;
		}
	}

	putimage( *x_,  *y_, 28 , 28 , &img, *color , 28 * h );
	for (k = 0; k<40; k++)
	{
		k1 = x[k][0][1];
		k2 = x[k][0][2];
		if(*r % 1 == 0)//敌坦克子弹速度
		{
			if ( k1 == 1 && k2 == 0 && x[k][0][0] != 0)
				x[k][0][0] = x[k][0][0] + 2;

			if ( k1 == 0 && k2 == 1 && x[k][0][0] != 0)
				x[k][1][0] = x[k][1][0] + 2;

			if ( k1 == -1 && k2 == 0 && x[k][0][0] != 0)
				x[k][0][0] = x[k][0][0] - 2;

			if ( k1 == 0 && k2 == -1 && x[k][0][0] != 0)
				x[k][1][0] = x[k][1][0] - 2;
		}

		if ( (x[k][0][0] -20) >= 640 || (x[k][0][0] - 20)<= 0)
			x[k][0][0] = 0 ;
		if ( (x[k][1][0] -20) >= 480 || (x[k][1][0] - 20)<= 0)
			x[k][0][0] = 0 ;

		fillcircle(x[k][0][0] - 20,  x[k][1][0] - 20, 5);
	}

	if (*z >= 38)
	{
		x[1][0][1] = x[*z ][0][1] ;
		x[1][0][2] = x[*z ][0][2] ;
		x[1][1][1] = x[*z ][1][1] ;
		x[1][1][2] = x[*z ][1][2] ;
		*z = 0;
	}

	return ;
}

void DBoxBig(int (*x)[2][3],int * x_, int * y_, int * z, int *r, int * color)
{
	int h = 0;
	int k , k1, k2;
	IMAGE img;
	loadimage(&img,_T("res\\enemy.bmp"));
	if (x[*z + 1][0][1] == 0 &&	x[*z  + 1][0][2] == -1)//w
		h = 0;

	if (x[*z + 1][0][1] == 0 &&	x[*z + 1][0][2] ==  1)//s
		h = 2;

	if (x[*z + 1][0][1] == -1 && x[*z + 1][0][2] ==  0)//a
		h = 3;

	if (x[*z + 1][0][1] == 1 &&	x[*z + 1][0][2] ==  0)//d
		h = 1;
	if ((*r) % 30 == 0)//敌坦克发子弹频率
	{
		*z = *z + 1;

		x[*z + 1][0][1] = x[*z ][0][1] ;
		x[*z + 1][0][2] = x[*z ][0][2] ;
		if (x[*z][0][1] == 0 &&	x[*z][0][2] == -1)//w
		{
			x[*z][0][0] = *x_ + 34;
			x[*z][1][0] = *y_ + 14;
		}
		if (x[*z][0][1] == 0 &&	x[*z][0][2] ==  1)//s
		{
			x[*z][0][0] = *x_ + 34;
			x[*z][1][0] = *y_ + 48;

		}
		if (x[*z][0][1] == -1 && x[*z][0][2] ==  0)//a
		{
			x[*z][0][0] = *x_ + 17;
			x[*z][1][0] = *y_ + 33;
		}
		if (x[*z][0][1] == 1 &&	x[*z][0][2] ==  0)//d
		{
			x[*z][0][0] = *x_ + 48;
			x[*z][1][0] = *y_ + 33;
		}
		keybd_event(74,0,KEYEVENTF_KEYUP,0);
	}

	putimage( *x_,  *y_, 28 , 28 , &img, *color , 112 + (28 * h) );
	for (k = 0; k<40; k++)
	{
		k1 = x[k][0][1];
		k2 = x[k][0][2];
		if(*r % 2 == 0)//敌坦克子弹速度
		{
			if ( k1 == 1 && k2 == 0 && x[k][0][0] != 0)
				x[k][0][0] = x[k][0][0] + 15;

			if ( k1 == 0 && k2 == 1 && x[k][0][0] != 0)
				x[k][1][0] = x[k][1][0] + 15;

			if ( k1 == -1 && k2 == 0 && x[k][0][0] != 0)
				x[k][0][0] = x[k][0][0] - 15;

			if ( k1 == 0 && k2 == -1 && x[k][0][0] != 0)
				x[k][1][0] = x[k][1][0] - 15;
		}

		if ( (x[k][0][0] -20) >= 640 || (x[k][0][0] - 20)<= 0)
			x[k][0][0] = 0 ;
		if ( (x[k][1][0] -20) >= 480 || (x[k][1][0] - 20)<= 0)
			x[k][0][0] = 0 ;

		fillcircle(x[k][0][0] - 20,  x[k][1][0] - 20, 5);
	}

	if (*z >= 38)
	{
		x[1][0][1] = x[*z ][0][1] ;
		x[1][0][2] = x[*z ][0][2] ;
		x[1][1][1] = x[*z ][1][1] ;
		x[1][1][2] = x[*z ][1][2] ;
		*z = 0;
	}

	return ;
}

void DBoxFeiJi(int (*x_9)[2][3],int (*x_10)[2][3],int (*x_11)[2][3],int * x_, int * y_, int * z, int *r)
{
	int k;
	IMAGE img;
	loadimage(&img, _T("res\\feiji.jpg"));

	HDC	dstDC = GetImageHDC();
	HDC	srcDC = GetImageHDC(&img);

	TransparentBlt(dstDC,*x_,*y_, 65, 65, srcDC, 0, 0, 65, 65, RGB(0,0,0));//飞机

	if ((*r) % 13 == 0)//敌坦克发子弹频率
	{
		*z = *z + 1;
		x_9[*z][0][0] = *x_ + 52;
		x_9[*z][1][0] = *y_ + 85;

		x_10[*z][0][0] = *x_ + 52;
		x_10[*z][1][0] = *y_ + 85;

		x_11[*z][0][0] = *x_ + 52;
		x_11[*z][1][0] = *y_ + 85;
	}
	for (k = 0; k<40; k++)
	{
		if(*r % 5 == 0 && x_10[k][0][0] != 0)//敌坦克子弹速度
		{
			x_9[k][1][0] = x_9[k][1][0] + 15;

			x_10[k][0][0] = x_10[k][0][0] + 15;
			x_10[k][1][0] = x_10[k][1][0] + 15;

			x_11[k][0][0] = x_11[k][0][0] - 15;
			x_11[k][1][0] = x_11[k][1][0] + 15;
		}

		if ( (x_9[k][1][0] -20) >= 480 )
			x_9[k][0][0] = 0 ;
		if ( (x_10[k][1][0] -20) >= 480)
			x_10[k][0][0] = 0 ;
		if ( (x_11[k][1][0] -20) >= 480)
			x_11[k][0][0] = 0 ;

		fillcircle(x_9[k][0][0] - 20,  x_9[k][1][0] - 20, 7);
		fillcircle(x_10[k][0][0] - 20,  x_10[k][1][0] - 20, 7);
		fillcircle(x_11[k][0][0] - 20,  x_11[k][1][0] - 20, 7);
	}	

	if (*z >= 38)
		*z = 0;
	return ;
}

接下来是我们子弹暴炸时的函数boom.cpp


# include "tanke.h"
/效果
bool DBoom(int (*x)[2][3], int * x_, int *y_, int *d,int *gold)
{
	int i;//循环用
	IMAGE imgBoom;
	loadimage(&imgBoom, _T("res\\explode1.bmp"));
	for (i=1; i<39; i++)//被击中爆炸
		if (x[i][0][0] <= *x_+48 && x[i][0][0] >= *x_ + 20 && x[i][1][0] <= *y_ + 48 && x[i][1][0] >= *y_ + 20)
		{

			if	 (*d % 10 ==  0)
				x[i][0][0] = 0;

			putimage(*x_, *y_, 28, 28, &imgBoom,0 ,0 );
			(*d)++;
			if (*d >= 60)
			{
				mciSendString("open sound//boom.mp3 alias mymusic_1", NULL, 0, NULL);
				mciSendString("play mymusic_1", NULL, 0, NULL);

				*d = 0;
				*gold += 10;
				return false;
			}
			mciSendString("close mymusic_1", NULL, 0, NULL);
		}	

		return true;

}

bool QZBoom(int (*x)[2][3], int * x_, int *y_)//强制子弹消失,物体爆炸。
{
	int i;//循环用
	for (i=1; i<39; i++)//被击中爆炸
		if (x[i][0][0] <= *x_+52 && x[i][0][0] >= *x_ + 20 && x[i][1][0] <= *y_ + 52 && x[i][1][0] >= *y_ + 20)
		{
			x[i][0][0] = 0;

			return false;
		}			

		return true;
}

bool DBoomBig(int (*x)[2][3], int * x_, int *y_, int *d)
{
	int i;//循环用
	IMAGE imgBoom;
	loadimage(&imgBoom,_T("res\\explode2.bmp"));
	for (i=1; i<39; i++)//被击中爆炸
		if (x[i][0][0] <= *x_+52 && x[i][0][0] >= *x_ + 20 && x[i][1][0] <= *y_ + 52 && x[i][1][0] >= *y_ + 20)
		{
			putimage(*x_ - 18, *y_ -18, 64, 64, &imgBoom,0 ,0 );
			(*d)++;

			if	 (*d % 10 ==  0)
				x[i][0][0] = 0;

		if (*d >= 60)
			{
				mciSendString("open sound//boom.mp3 alias mymusic_1", NULL, 0, NULL);
				mciSendString("play mymusic_1", NULL, 0, NULL);

				*d = 0;
				return false;
			}
			mciSendString("close mymusic_1", NULL, 0, NULL);
		}	

		return true;

}
bool DBossBoomBig(int (*x)[2][3], int * x_, int *y_, int *k, int*zhidan)
{
	int i;//循环用
	IMAGE imgBoom;
	loadimage(&imgBoom,_T("res\\explode2.bmp"));
	for (i=1; i<39; i++)//被击中爆炸
		if (x[i][0][0] <= *x_+70 && x[i][0][0] >= *x_ + 20 && x[i][1][0] <= *y_ + 70 && x[i][1][0] >= *y_ + 20)
		{
			putimage(*x_ - 18, *y_ -18, 64, 64, &imgBoom,0 ,0 );

			if (*zhidan == 5)
				(*k)++;

			if (*zhidan == 15)
				(*k) += 10;

			if (*k >= 8000)
			{
				x[i][0][0] = 0;

				keybd_event(89,0,0,0);
				keybd_event(89,0,KEYEVENTF_KEYUP,0);

				return false;
			}

		}
		setcolor(GREEN);
		settextstyle(0, 0, ("宋体"));
		char c2[20] = "BOSS生命值:";
		outtextxy(220, 0, c2);

		char c3[10] ;
		sprintf(c3, _T("%.1f"),1000*(8000 - *k)/8000.0 );
		outtextxy(320, 0, c3);

		return true;

}
bool DBossBoomSmall(int (*x)[2][3], int * x_, int *y_, int *l, int*sd)
{
	int i;//循环用
	IMAGE imgBoom;
	loadimage(&imgBoom, _T("res\\explode2.bmp"));
	for (i=1; i<39; i++)//被击中爆炸
		if (x[i][0][0] <= *x_+48 && x[i][0][0] >= *x_ + 20 && x[i][1][0] <= *y_ + 48 && x[i][1][0] >= *y_ + 20)
		{
			putimage(*x_ - 18, *y_ -18, 64, 64, &imgBoom,0 ,0 );

			if (*sd == 2)
				(*l)++;

			if (*sd == 1)
				(*l) += 10;

			if (*l >= 1000)
			{
				x[i][0][0] = 0;
				*l = 0;
				return false;
			}

		}
		setcolor(GREEN);
		settextstyle(0, 0, ("宋体"));
		char c2[20] = "BOSS生命值:";
		outtextxy(220, 0, c2);

		char c3[10] ;
		sprintf(c3, _T("%.1f"),1000*(1000 - *l)/1000.0 );
		outtextxy(320, 0, c3);
		return true;
}

最后就是我们运行的主函数了main.cpp


# include "tanke.h"

int main(void)
{
	start();//开始说明

	int r = 0;//减速的
	int relive = 0;//复活次数
	int sd = 2;//子弹速度
	int HWsd = 40;
	int gold = 0;//金币
	int zhidan = 5;//己方坦克子弹大小
	int o = 0; //boss方向储存
	int ydsd = 2;//移动速度

	int j = 0;//爆炸图片多次,或者生命值
	int d = 0;//爆炸图片多次
	int k = 0;//boss生命值
	int l = 0;//小boss生命值
	int m = 0;//物品生命值

	TanKe tanke[7] = {	{0,0, 0, 0,   true, {0}},
						{0,0, 0, 0,   true, {0}},
						{0,0, 0, 56,  true, {0}},
						{0,0, 0, 112, true, {0}},
						{0,0, 0, 168, true, {0}},
						{0,0, 0, 112, true, {0}},
						{0,0, 0, 168, true, {0}}};

	pTanKe ptanke = NULL;

	BaiZhuan baizhuan[3] = { {0,0,true},{0,0,true},{0,0,true}};

	pBaiZhuan pbaizhuan = NULL;

	LvZhuan lvzhuan[12];
	pLvZhuan plvzhuan = NULL;

	HongZhuan hongzhuan[2] ={ {0,0,true},{0,0,true}};
	pHongZhuan phongzhuan = NULL;

	tanke[0].d[1][0][1] = 0;//初始化己方第一颗子弹方向上
	tanke[0].d[1][0][2] = -1;

	tanke[1].d[1][0][1] = 0;//初始化己方第一颗子弹方向上
	tanke[1].d[1][0][2] = -1;

	tanke[2].d[1][0][1] = 0;//初始化己方第一颗子弹方向上
	tanke[2].d[1][0][2] = -1;

	tanke[3].d[1][0][1] = 0;//初始化己方第一颗子弹方向上
	tanke[3].d[1][0][2] = -1;

	tanke[4].d[1][0][1] = 0;//初始化己方第一颗子弹方向上
	tanke[4].d[1][0][2] = -1;

	tanke[5].d[1][0][1] = 0;//初始化己方第一颗子弹方向上
	tanke[5].d[1][0][2] = -1;

	tanke[6].d[1][0][1] = 0;//初始化己方第一颗子弹方向上
	tanke[6].d[1][0][2] = -1;

	int z8 = 0;//绿坦克
	int z9 = 0;//飞机

	int color8 = 0;//绿boss

	int x_8[40][2][3] = {0};//绿坦克子弹
	int x_9[40][2][3] = {0};
	int x_10[40][2][3] = {0};//飞机子弹
	int x_11[40][2][3] = {0};//飞机子弹

	x_8[1][0][1] = 0;//初始化己方第一颗子弹方向上
	x_8[1][0][2] = -1;

	start_();

	bool live8 = false;//绿坦克
	bool live9 = false;//飞机

	bool exist_laowang  = true;
	bool exist1 = true;	//boss红砖

	bool wexist1 = true;//法杖
	bool wexist2 = true;//枪
	bool wexist3 = true;//商店
	bool wexist4 = true;//药水
	bool wexist5 = true;//盾牌
	bool wexist8 = true;//鞋子
	bool wexist6 = true;//物品—boss
	bool wexist7 = true;//物品—bigboss

	int tilelaowang_x = 304;//老王
	int tilelaowang_y = 448;
	int tileHong_x1 = 304;//老王前障碍物
	int tileHong_y1 = 416;

	while(true)
	{
		tanke[0].x = 28 + rand() % 584, tanke[0].y = 400 + rand() % 52;//己方方块,
		tanke[1].x = 28 + rand() % 584, tanke[1].y = 28 + rand() % 124;//敌方方块,↓同理
		tanke[2].x = 28 + rand() % 584, tanke[2].y = 28 + rand() % 124;
		tanke[3].x = 28 + rand() % 584, tanke[3].y = 28 + rand() % 124;
		tanke[4].x = 28 + rand() % 584, tanke[4].y = 28 + rand() % 124;
		tanke[5].x = 28 + rand() % 584, tanke[5].y = 28 + rand() % 124;
		tanke[6].x = 28 + rand() % 584, tanke[6].y = 28 + rand() % 124;
		//int x8 = 28 + rand() % 584, y8 = 28 + rand() % 124;//放在下面的
		int x9 = 320, y9 = -80;//大boss

		hongzhuan[0].x = 100 + rand() % 376;//红色砖块
		hongzhuan[0].y = 200 + rand() % 216;
		hongzhuan[1].x = 32 + rand() % 576;//红色砖块
		hongzhuan[1].y = 32 + rand() % 416;
		baizhuan[0].x = 32 + rand() % 576; //白色砖块
		baizhuan[0].y = 32 + rand() % 416;
		baizhuan[1].x = 32 + rand() % 576; //白色砖块
		baizhuan[1].y = 32 + rand() % 416;
		baizhuan[2].x = 32 + rand() % 576; //白色砖块
		baizhuan[2].y = 32 + rand() % 416;
		int tileBai_x4 = -20; //老王前白色砖块真的打不烂!
		int tileBai_y4 = -20;

		lvzhuan[0].x = 32 + rand() % 576; //绿色砖块
		lvzhuan[0].y = 32 + rand() % 416;
		lvzhuan[1].x = 32 + rand() % 576;
		lvzhuan[1].y = 32 + rand() % 416;
		lvzhuan[2].x = 32 + rand() % 576;
		lvzhuan[2].y = 32 + rand() % 416;
		lvzhuan[3].x = 32 + rand() % 576;
		lvzhuan[3].y = 32 + rand() % 416;
		lvzhuan[4].x = 32 + rand() % 576;
		lvzhuan[4].y = 32 + rand() % 416;
		lvzhuan[5].x = 32 + rand() % 576;
		lvzhuan[5].y = 32 + rand() % 416;
		lvzhuan[6].x = 32 + rand() % 576; //绿色砖块
		lvzhuan[6].y = 32 + rand() % 416;
		lvzhuan[7].x = 32 + rand() % 576;
		lvzhuan[7].y = 32 + rand() % 416;
		lvzhuan[8].x = 32 + rand() % 576;
		lvzhuan[8].y = 32 + rand() % 416;
		lvzhuan[9].x = 32 + rand() % 576;
		lvzhuan[9].y = 32 + rand() % 416;
		lvzhuan[10].x = 32 + rand() % 576;
		lvzhuan[10].y = 32 + rand() % 416;
		lvzhuan[11].x = 32 + rand() % 576;
		lvzhuan[11].y = 32 + rand() % 416;
		int tileBlue_x1 = 32 + rand() % 576; //蓝色砖块
		int tileBlue_y1 = 32 + rand() % 416;
		int tileBlue_x2 = 32 + rand() % 576; //蓝色砖块
		int tileBlue_y2 = 32 + rand() % 416;

		int fazhang_x1 = 32 + rand() % 576; //物品—法杖;
		int fazhang_y1 = 32 + rand() % 416;

		int shouqiang_x1 = 32 + rand() % 576; //物品—枪;
		int shouqiang_y1 = 32 + rand() % 416;

		int shangdian_x1 = 32 + rand() % 576; //物品—商店;
		int shangdian_y1 = 200 + rand() % 216;

		int yaoshui_x1 = 32 + rand() % 576; //物品—药水;
		int yaoshui_y1 = 32 + rand() % 416;

		int dunpai_x1 = 32 + rand() % 576; //物品—盾牌;
		int dunpai_y1 = 32 + rand() % 116;

		int xiezi_x1 = 32 + rand() % 576; //物品—鞋子;
		int xiezi_y1 = 32 + rand() % 116;

		int boss_x1 = 100 + rand() % 376; //物品—Boss;
		int boss_y1 = 100 + rand() % 216;
		int x8 = boss_x1 , y8 = boss_y1;

		int bigboss_x1 = hongzhuan[0].x ; //物品—bigBoss;
		int bigboss_y1 = hongzhuan[0].y ;

		while (true)
		{
			ZhengTiFangXiang(tanke,baizhuan,hongzhuan,x_8,
				&live8,&live9,
				&r,&x8,&y8,&x9,&y9,
				&z8,
				&o,&ydsd);//方向

			cleardevice();//清屏

			ZhengTiLaoWang(tanke,x_8,x_9,x_10,x_11,
				&exist_laowang,&exist1,&gold,&d,
				&tilelaowang_x,&tilelaowang_y,&tileHong_x1,&tileHong_y1,&tileBai_x4,&tileBai_y4,&live9);//老王

			ZhengTiBaiSeZhangAiWu(tanke,x_8,x_9,x_10,x_11,
				&wexist1,
				&d,baizhuan);//白砖

			ZhengTiLanSeZhangAiWu(&tileBlue_x1,&tileBlue_y1,&tileBlue_x2,&tileBlue_y2);//蓝砖

			ZhengTiTanKeBaoZha(tanke,x_8,x_9,x_10,x_11,
				&live8,&live9,
				&r,&x8,&y8,&x9,&y9,
				&sd,&color8,
				&j,&d,&k,&l,&gold,&zhidan,
				&z8,&z9);//坦克 、 爆炸

			ZhengTiLuoShui(tanke,&tileBlue_x1,&tileBlue_y1,&tileBlue_x2,&tileBlue_y2,
				&j,&gold,&y9);//落水.boss秒人

			ZhengTiLvSeZhangAiWu(lvzhuan);//绿砖

			ZhengTiWuPin(tanke,&x8,&y8,
				&live8,&live9,
				&fazhang_x1,&fazhang_y1,
				&shouqiang_x1,&shouqiang_y1,
				&shangdian_x1,&shangdian_y1,
				&yaoshui_x1,&yaoshui_y1,
				&dunpai_x1,&dunpai_y1,
				&xiezi_x1,&xiezi_y1,
				&boss_x1,&boss_y1,
				&bigboss_x1,&bigboss_y1,
				&wexist1, &wexist2,&wexist3,&wexist4,&wexist5,&wexist6,&wexist7,&wexist8,
				&sd,&HWsd,&ydsd, &d,&j,&gold,&zhidan,&relive);//物品

			ZhengTiHongSeZhangAiWu(tanke,x_8,x_9,
				&d,hongzhuan);//红砖 后藏boss

			ZhengTiShengMing(tanke,hongzhuan,
				&exist_laowang,&exist1,&wexist1,&wexist2,&wexist3,&wexist8,
				&relive,&j,&d,&gold,&k);//生命

			FlushBatchDraw();

			if (GetAsyncKeyState('Y'))
			{break;}

			if (Quit())
			{exit(0);}

			if (gold == 2200)
			{
				MiJi();
			}

		}
	}
	EndBatchDraw();
	return 0;
}

这样一个《坦克大战》就完成了。快去自己动手尝试一下叭!!!

代码很长,希望看完了的同学可以获得自己想要的知识,也感谢大家的耐心观看,在这里想得到大家一波关注,后续UP主还会发布更多的项目源码以及学习资料,有什么问题可以回帖留言,我尽量回答。希望和大家一起学习进步!!!

到此这篇关于C语言 完整游戏项目坦克大战详细代码的文章就介绍到这了,更多相关C语言 坦克大战内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • C语言实现一个简单的扫雷游戏

    前言 扫雷跟上一篇文章的三子棋一样,是C语言基础知识的综合运用的实例,对于巩固我们的基础知识非常重要,同时扫雷作为C语言的一个小项目,锻炼我们的编程思维,也是一个不可多得的实践. 提示:以下是本篇文章正文内容 一.扫雷的基本思路 1.用C语言实现简单的扫雷,我们需要创建两个数组,一个数组存放雷的信息,另外一个数组存放排雷后结果的信息. 2.在创建数组时候,需要注意的是数组需要大一圈,什么意思?举个例子,比如说我们实现的是9 ×9的扫雷,那么我们的数组就得创建10×10.为什么呢? 原因如下: 因

  • C语言实现简易连连看游戏

    本文为大家分享了C语言实现连连看游戏位的具体代码,供大家参考,具体内容如下 题目 给定一个2N×2N的方阵网格游戏盘面,每个格子中放置一些符号.这些符号一定是成对出现的,同一个符号可能不止一对.程序读入玩家给出的一对位置(x​1,y1​​ ).(x​2,y​2),判断这两个位置上的符号是否匹配.如果匹配成功,则将两个符号消为"*"并输出消去后的盘面:否则输出"Uh-oh".若匹配错误达到3次,则输出"Game Over"并结束游戏.或者当全部符号

  • C语言实现的一个三子棋游戏详解流程

    目录 前言 一.三子棋完成程序运行结果 二.三子棋代码实现 1.创建源文件与头文件 2.整体页面的制作 3.制作并打印棋盘 1.在test.c文件中,定义函数game(); 2.在game.h 头文件中 3.在game.c源文件中 4.人机互动下棋 1.在test.c源文件中 2.在game.h头文件中 3.在game.c源文件中 4.此时打印效果 5.判断输赢 1.在test.c源文件中 2.在game.h头文件中 3.在game.c源文件中 4.最终实现结果 最后 前言 三子棋是我们先前所学

  • 基于C语言实现井字棋游戏

    井字棋游戏要求在3乘3棋盘上,每行都相同或者每列都相同再或者对角线相同,则胜出.因此我们可以使用一个二维数组来表示棋盘,判断胜负只需要判断数组元素是否相同即可.具体我们可以分为以下几步来做: 1.创建维数组并进行初始化,如果仅仅是一个二维数组来表示棋盘,看起来不是很清楚,因此我们可以对棋盘边框用符号打印出来进行优化一下: //初始化棋盘 void init(char board[max_row][max_col]) { for (int row = 0; row < max_row; row++

  • C语言构建连连看游戏(矩阵方式)

    C语言构建连连看游戏的具体代码,供大家参考,具体内容如下 设计要求 用数字+英文字母,采用文本输出的方式.每次输出一个8*10的矩形,然后等待玩家输入两个数字或字母的坐标,如果满足消除规则就输出新的矩形. 注意:考虑类似迷宫的处理方式,在8 * 10矩形之外加一层空心围墙,可以用来连接.大家体验一下连连看游戏就可以发现这个规则.判断是否能连,用的是10 *12的数组,最外层添加的是空格,可用来辅助连接. 分析 大纲(简化): /**********************************

  • 基于C语言实现2048游戏

    本文实例为大家分享了C语言实现2048游戏的具体代码,供大家参考,具体内容如下 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <conio.h> #include <windows.h> #define ROW 4 #define COL ROW #define KEY1 224 #define KEY_LEFT 75 #define KEY_UP 72 #de

  • C++实现坦克大战小游戏EGE图形界面

    C++ EGE 实现坦克大战小游戏,供大家参考,具体内容如下 因为有过一次用EGE写小游戏的经验,所以这一次写坦克大战快了很多.并且使用对象编程也简化了很多编程时繁琐的步骤. 写出坦克大战使我在学习编程的道路上又迈出了一大步. 如果您需要图片素材的,我可以单独发给您. 技术环节: 编译环境:Windows VS2019 需求: 控制坦克移动发射炮弹,炮弹可以消灭敌军坦克,且可以消灭砖块.坦克遇到方块会被挡住.敌军消灭我军三次或基地被毁则游戏失败,共摧毁十次敌方坦克游戏胜利. 思路: 先写出坦克的

  • C语言 完整游戏项目坦克大战详细代码

    话不多说 我们今天就来创造出属于我们自己的<坦克大战>,GOGOGO!!! 直接开始吧 这次的源码比较详细,我分了好几个cpp文件,思路更加的清晰,请耐心用心的观看 首先就是我们载入图片的函数tupian.cpp # include "tanke.h" 障碍物 void LaoWang(int * tilex, int * tiley) { IMAGE img; loadimage(&img, _T("res\\tile.bmp")); puti

  • C语言 完整游戏项目推箱子详细代码

    话不多说 我们今天就来创造出属于我们自己的<推箱子>,GOGOGO!!! 直接开始吧 首先是我们用二维数组特定的数字描绘出这个地图 int cas = 0; int map[3][8][8] = { 1,1,1,1,1,1,1,1, 1,3,4,0,0,4,3,1, 1,0,1,3,0,1,0,1, 1,0,1,4,0,1,0,1, 1,0,0,5,0,0,0,1, 1,0,1,0,0,1,0,1, 1,3,4,0,0,4,3,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1

  • java简单坦克大战制作代码

    利用Java语言中的集合.Swing.线程等知识点编写一个坦克大战游戏. (1) 画出敌我坦克的原理: 在坦克类里面有一个布尔类型变量good.用于判断坦克的阵营,在创建坦克对象时在Tank类的构造方法中传入good的值.在画坦克的时候判断good的值,区分敌我坦克的颜色: (2) 坦克运动的原理: 在坦克类里写入了监听键盘摁键的响应事件,对监听到的上下左右键进行记录,并合成坦克移动的八个方向的变量.之后对应每个方向的不同对坦克坐标x,y的值做响应的更改实现我方坦克的移动.而敌方坦克则自动移动,

  • C语言实现扫雷小游戏详细代码

    前言 扫雷是一款很经典的电脑小游戏,扫雷就是要把所有非地雷的格子找出即为胜利,输入到地雷格子就算失败.游戏主区域由很多个方格组成,输入一个方格坐标,方格即被打开并显示出方格中的数字,方格中数字则表示其周围的8个方格隐藏了几颗雷,如果点开的格子为0,即代表其周围有0颗雷. 本篇文章将用VS2013带领大家用C语言编写此款小游戏. 一.所需函数 1.埋雷函数(SetMines) 2.ShowLine 3.ShowBoard (2.3函数均为显示横线和竖线) 4.统计雷的个数函数(CountMines

  • 使用 TypeScript 重新编写的 JavaScript 坦克大战游戏代码

    源码下载 源码我已经上传到 CSDN 了,无需资源分,下载地址:http://download.csdn.net/detail/zgynhqf/8565873. 源码使用 VS 2013 +TypeScript 1.4 进行开发.打开后,显示如下图: JsTankGame 1.0:老的使用 JS 编写的坦克游戏. JsTankGame 2.0:新的使用 TS 直接翻译过来的游戏. JsTankGame:在 2.0 的基础上,对类型进行了重构后的新游戏. 重构步骤 由于老的 JS 游戏是采用 MS

  • C语言实现扫雷游戏详细代码

    本文实例为大家分享了C语言实现扫雷游戏的详细代码,供大家参考,具体内容如下 一.思想实现 本文的扫雷游戏主要实现以下的功能: 1.显示雷和其信息 2.输入一个坐标可观测其周围九格内的地雷数 3.点击到地雷则游戏结束 用到的IDE为VS2013 二.源代码 创建一个头文件saolei.h 存放关于所有自定义函数的声明 #define COL 9 char** creatMat(int row, int col); void intMat(char** Mat, int row, int col,

  • JAVA实现经典游戏坦克大战的示例代码

    目录 前言 主要设计 功能截图 代码实现 总结 前言 小时候大家都玩过坦克大战吧,熟悉的旋律和丰富的关卡陪伴了我们一整个寒暑假,还记得传说中的经典坦克大战 吗?那些怀旧的记忆,伴随着我们一起走过来的经典坦克大战,刚开始那战战兢兢,屡屡被敌人坦克击毁的情景历历在目.现在好了,再也不用担心敌人坦克了,可 以横冲直撞,横扫敌人坦克了.快哉!!! <坦克大战>游戏以坦克战斗为主题,用java语言实现,采用了swing技术进行了界面化处理,设计思路用了面向对象思想. 主要需求 可以生成不同的地图,消灭地

  • 易语言坦克大战游戏制作

    易语言是一款可视全中文的编程语言,既然是一款编程语言,那么肯定可以编写游戏,每一种编程语言在学习编程游戏中一般都会编写一种游戏,叫坦克大战,那么最基础的用键代码移动那个坦克,那么该如何编写呢?下面我为大家讲解! 1.打开易语言,新建windows窗口程序. 2.将按钮1放在启动窗口内. 3.随便弄一张图设置成按钮的背景图片 4.在按钮1的属性下面事件中选择被某键按下 5.在按钮1的属性下面事件中选择被某键按下 开始编写,写入代码如下 .版本 2 .程序集 窗口程序集_启动窗口 .子程序 _按钮1

  • C语言扫雷详细代码分步实现流程

    目录 一,创建菜单 二,创建游戏内容 1.场景创建和初始化 2.场景打印 3.埋雷 4.排雷 完整代码 1.game.h 2.game.c 3.test.c 还是说一下:发的这些小游戏都是第一个版本,之后改进的话都会在标题中声明. 上一个游戏三子棋:             >> C语言三子棋一步步实现详程<< 来看这次扫雷游戏的思路:                  1.创建游戏界面菜单                   2.创建游戏内容:             初始化场景

  • Pygame坦克大战游戏开发实战详解代码

    导语 哈喽!哈喽——我是木木子 今天来升级下之前写的坦克大战游戏嘛,哈哈哈 其实也不算是修改,就是稍微的调试一下!​​ 因为之前写的界面都是英文的 ,有的小伙伴儿英文一点儿都不会的可能看着别扭,今天来一款中 文版的给大家嘛! 俗话说的好:“雨露均沾”.哈哈哈.jpg 小简介: <坦克大战>,1985年由日本开发商南梦宫(Namco)开发,是第一款可以双打的红白机游戏. 当时使用的还是小霸王. 很多小朋友以学习的名义买了以后偷偷打的打游戏还被家长发现了有 没得! <坦克大战>红白机原

随机推荐