我是靠谱客的博主 粗暴指甲油,最近开发中收集的这篇文章主要介绍原创游戏:血战太平洋1.1(可在Dev-C++上运行)前言: 献上代码:最后,,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

前言: 

那是一个暑假的下午,我在家里刷题。。。

突然隔壁家传来“BiuBiu——BOOM”的声音

原来是隔壁家小孩在玩一个名叫《1941》的游戏

这宏大的画面,这激烈的战斗,我顿时就馋哭了

可惜,我根本没有游戏机

那不如,和好朋友一起编一个吧!

效果图:

 这个游戏是和同学 xiedongbiao 一起编的,在这里要感谢他的大力支持!!

献上代码:

#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <conio.h>
#include "windows.h"
#pragma GCC optimize(3)
#pragma GCC optimize(2)
using namespace std;
const int row = 44;
const int col = 36;
struct Enemy
{
	int x,y;
	bool life;
} enemy[1000];
int enemy_top=0;
struct Blast
{
	int x,y;
	int making_tim;
	bool flag=0;
}
blast[1000];
int blast_top=0;
int tim_fire;
int tim_enemy_making;
bool v[row][col];
int p_fenshu=0;
int p_life=5;
int Map[row][col] =
{
//   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 0
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 1
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 2
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, //39
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, //40
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, //41
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, //42
	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, //43
};
int p_x=17,p_y=9;  //玩家的坐标  map[p_x][p_y];

void hide_cursor()
{
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO CursorInfo;
	GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
	CursorInfo.bVisible = false; //隐藏控制台光标
	SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
void blast_making (int b_x,int b_y)
{
	blast[++blast_top].making_tim=time(0);
	blast[blast_top].x=b_x;
	blast[blast_top].y=b_y;
	blast[blast_top].flag=1;
	Map[b_x][b_y]=10;
	Map[b_x+1][b_y]=11;
	Map[b_x-1][b_y]=11;
	Map[b_x][b_y+1]=11;
	Map[b_x][b_y-1]=11;
	Map[b_x+1][b_y+1]=12;
	Map[b_x+1][b_y-1]=12;
	Map[b_x-1][b_y+1]=12;
	Map[b_x-1][b_y-1]=12;
}
void blast_handle (int b_x,int b_y,int id)
{
	int now_time=time(0);
	Map[b_x][b_y]=10;
	Map[b_x+1][b_y]=11;
	Map[b_x-1][b_y]=11;
	Map[b_x][b_y+1]=11;
	Map[b_x][b_y-1]=11;
	Map[b_x+1][b_y+1]=12;
	Map[b_x+1][b_y-1]=12;
	Map[b_x-1][b_y+1]=12;
	Map[b_x-1][b_y-1]=12;
	if(now_time-blast[id].making_tim>=1)
	{
		Map[b_x][b_y]=0;
		Map[b_x+1][b_y]=0;
		Map[b_x-1][b_y]=0;
		Map[b_x][b_y+1]=0;
		Map[b_x][b_y-1]=0;
		Map[b_x+1][b_y+1]=0;
		Map[b_x+1][b_y-1]=0;
		Map[b_x-1][b_y+1]=0;
		Map[b_x-1][b_y-1]=0;
		blast[id].flag=0;
	}
}
void blast_check ()
{
	for(int i=1; i<=blast_top; i++)
	{
		if(blast[i].flag==0) continue;
		blast_handle(blast[i].x,blast[i].y,i);
	}
}
void color (string ss)
{
	if(ss=="RED")
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
	if(ss=="BLU")
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 1);
	if(ss=="GRE")
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
	if(ss=="YEL")
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
	if(ss=="PUR")
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 5);
	if(ss=="GRA")
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED);
	if(ss=="WHI")
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);

}

bool check(int x,int y)
{
	if(x>=0&&y>=0&&x<=37&&y<=35) return true;
	return false;
}

void move(int x_mov,int y_mov)    //玩家坐标位移
{
	p_x+=x_mov,p_y+=y_mov;
}

void fire(int p_x,int p_y)
{
	int now_fire=time(0);
	if(tim_fire==0||now_fire-tim_fire>=1)
	{
		Map[p_x-1][p_y]=8;
		Map[p_x-1][p_y+1]=8;
		Map[p_x-2][p_y]=9;
		Map[p_x-2][p_y+1]=9;
		tim_fire=now_fire;
	}

}

void player_step()    //位移操作
{
	Map[p_x][p_y]=0;
	Map[p_x][p_y+1]=0;
	Map[p_x+1][p_y+1]=0;
	Map[p_x+1][p_y]=0;
//	Map[p_x+1][p_y-1]=0;
	Map[p_x+1][p_y-2]=0;
//	Map[p_x+1][p_y+2]=0;
	Map[p_x+1][p_y+3]=0;
	Map[p_x+2][p_y+3]=0;
	Map[p_x+2][p_y+4]=0;
	Map[p_x+2][p_y+5]=0;
	Map[p_x+2][p_y+6]=0;
	Map[p_x+2][p_y+2]=0;
	Map[p_x+2][p_y+1]=0;
	Map[p_x+2][p_y]=0;
	Map[p_x+2][p_y-1]=0;
	Map[p_x+2][p_y-3]=0;
	Map[p_x+2][p_y-4]=0;
	Map[p_x+2][p_y-5]=0;
	Map[p_x+2][p_y-2]=0;
//	Map[p_x+3][p_y]=0;
//	Map[p_x+3][p_y+1]=0;
	Map[p_x+3][p_y+2]=0;
	Map[p_x+3][p_y-1]=0;
	Map[p_x+4][p_y]=0;
	Map[p_x+4][p_y+1]=0;
	Map[p_x+4][p_y-1]=0;
	Map[p_x+4][p_y+2]=0;
	Map[p_x+4][p_y+3]=0;
	Map[p_x+4][p_y+4]=0;
	Map[p_x+4][p_y-2]=0;
	Map[p_x+4][p_y-3]=0;
	if(GetKeyState(VK_UP) < 0&&p_x-1>=0)
	{
		move(-1, 0);
	}
	if(GetKeyState(VK_DOWN ) < 0&&p_x+1<=33)
	{
		move( 1, 0);
	}
	if(GetKeyState(VK_LEFT) < 0&&p_y-1>=5)
	{
		move( 0,-1);
	}
	if(GetKeyState(VK_RIGHT) < 0&&p_y+1<=29)
	{
		move( 0, 1);
	}
	if(GetKeyState(' ') < 0)
	{
		fire(p_x,p_y);
	}
	Map[p_x][p_y]=2;
	Map[p_x][p_y+1]=2;
	Map[p_x+1][p_y+1]=1;
	Map[p_x+1][p_y]=1;
//	Map[p_x+1][p_y-1]=7;
	Map[p_x+1][p_y-2]=1;
//	Map[p_x+1][p_y+2]=7;
	Map[p_x+1][p_y+3]=1;
	Map[p_x+2][p_y+3]=1;
	Map[p_x+2][p_y+4]=3;
	Map[p_x+2][p_y+5]=3;
	Map[p_x+2][p_y+6]=3;
	Map[p_x+2][p_y+2]=3;
	Map[p_x+2][p_y+1]=3;
	Map[p_x+2][p_y]=3;
	Map[p_x+2][p_y-1]=3;
	Map[p_x+2][p_y-3]=3;
	Map[p_x+2][p_y-4]=3;
	Map[p_x+2][p_y-5]=3;
	Map[p_x+2][p_y-2]=1;
//	Map[p_x+3][p_y]=7;
//	Map[p_x+3][p_y+1]=7;
	Map[p_x+3][p_y+2]=1;
	Map[p_x+3][p_y-1]=1;
	Map[p_x+4][p_y]=3;
	Map[p_x+4][p_y+1]=3;
	Map[p_x+4][p_y-1]=1;
	Map[p_x+4][p_y+2]=1;
	Map[p_x+4][p_y+3]=3;
	Map[p_x+4][p_y+4]=3;
	Map[p_x+4][p_y-2]=3;
	Map[p_x+4][p_y-3]=3;
}
//	puts("             ||		  ");
//	puts("           | || |       ");
//	puts("        ===|====|===    ");
//	puts("            |  |        ");
//	puts("          ==|==|==      ");
//	puts("");
//	puts("");
void enemy_clear(int e_x,int e_y)
{
	if(v[e_x][e_y])Map[e_x][e_y]=0;
	if(v[e_x][e_y+1])Map[e_x][e_y+1]=0;
	if(v[e_x-1][e_y])Map[e_x-1][e_y]=0;
	if(v[e_x-2][e_y])Map[e_x-2][e_y]=0;
	if(v[e_x-3][e_y])Map[e_x-3][e_y]=0;
	if(v[e_x-1][e_y+1])Map[e_x-1][e_y+1]=0;
	if(v[e_x-2][e_y+1])Map[e_x-2][e_y+1]=0;
	if(v[e_x-3][e_y+1])Map[e_x-3][e_y+1]=0;
	if(v[e_x-1][e_y-1])Map[e_x-1][e_y-1]=0;
	if(v[e_x-2][e_y-3])Map[e_x-1][e_y-2]=0;
	if(v[e_x-1][e_y-3])Map[e_x-1][e_y-3]=0;
	if(v[e_x-1][e_y-4])Map[e_x-1][e_y-4]=0;
	if(v[e_x-1][e_y+2])Map[e_x-1][e_y+2]=0;
	if(v[e_x-1][e_y+3])Map[e_x-1][e_y+3]=0;
	if(v[e_x-1][e_y+4])Map[e_x-1][e_y+4]=0;
	if(v[e_x-1][e_y+5])Map[e_x-1][e_y+5]=0;
	if(v[e_x-3][e_y-1])Map[e_x-3][e_y-1]=0;
	if(v[e_x-3][e_y+2])Map[e_x-3][e_y+2]=0;
//	cout<<1<<" ";
}
void enemy_check(int e_x,int e_y,int id)
{
	if(Map[e_x][e_y]==8||Map[e_x][e_y]==9)
	{
		p_fenshu++;
		enemy[id].life=0;
		enemy_clear(enemy[id].x,enemy[id].y) ;
		blast_making(e_x,e_y);
		return ;
	}
	if((check(e_x,e_y)&&Map[e_x][e_y]>=1&&Map[e_x][e_y]<=3))
	{
		p_life-=1;
		p_fenshu++;
		enemy[id].life=0;
		enemy_clear(enemy[id].x,enemy[id].y) ;
		blast_making(e_x,e_y);
		return ;
	}
//	Map[e_x][e_y]=cor;
}



void enemy_move(int e_x,int e_y,int id)
{
	enemy_clear(e_x,e_y);
	e_x+=1;
	enemy[id].x=e_x;
	if(v[e_x][e_y])
	{
		enemy_check(e_x,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x][e_y]=4;
	}
	if(v[e_x][e_y+1])
	{
		enemy_check(e_x,e_y+1,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x][e_y+1]=4;
	}
	if(v[e_x-1][e_y])
	{
		enemy_check(e_x-1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y]=6;
	}
	if(v[e_x-2][e_y])
	{
		enemy_check(e_x-2,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-2][e_y]=6;
	}
	if(v[e_x-3][e_y])
	{
		enemy_check(e_x-3,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-3][e_y]=6;
	}
	if(v[e_x-1][e_y+1])
	{
		enemy_check(e_x-1,e_y+1,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y+1]=6;
	}
	if(v[e_x-2][e_y+1])
	{
		enemy_check(e_x-2,e_y+1,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-2][e_y+1]=6;
	}
	if(v[e_x-3][e_y+1])
	{
		enemy_check(e_x-3,e_y+1,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-3][e_y+1]=6;
	}
	if(v[e_x-1][e_y-1])
	{
		enemy_check(e_x-1,e_y-1,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y-1]=7;
	}
	if(v[e_x-1][e_y-2])
	{
		enemy_check(e_x-1,e_y-2,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y-2]=7;
	}
	if(v[e_x-1][e_y-3])
	{
		enemy_check(e_x-1,e_y-3,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y-3]=7;
	}
	if(v[e_x-1][e_y-4])
	{
		enemy_check(e_x-1,e_y-4,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y-4]=7;
	}
	if(v[e_x-1][e_y+2])
	{
		enemy_check(e_x-1,e_y+2,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y+2]=7;
	}
	if(v[e_x-1][e_y+3])
	{
		enemy_check(e_x-1,e_y+3,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y+3]=7;
	}
	if(v[e_x-1][e_y+4])
	{
		enemy_check(e_x-1,e_y+4,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y+4]=7;
	}
	if(v[e_x-1][e_y+5])
	{
		enemy_check(e_x-1,e_y+5,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-1][e_y+5]=7;
	}
	if(v[e_x-3][e_y-1])
	{
		enemy_check(e_x-3,e_y-1,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-3][e_y-1]=7;
	}
	if(v[e_x-3][e_y+2])
	{
		enemy_check(e_x-3,e_y+2,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
		Map[e_x-3][e_y+2]=7;
	}

	if(v[e_x+1][e_y])
	{

		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x+1][e_y+1])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x][e_y+2])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x][e_y+3])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x][e_y+4])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x][e_y+5])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x][e_y-1])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x][e_y-2])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x][e_y-3])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}
	if(v[e_x][e_y-4])
	{
		enemy_check(e_x+1,e_y,id);
		if(enemy[id].life==false)
		{
			enemy_clear(e_x,e_y);
			return ;
		}
	}


}
void enemy_step()
{
	for(int i=1; i<=enemy_top; i++)
	{
		if(!enemy[i].life) continue;
		enemy_move(enemy[i].x,enemy[i].y,i);
	}
}

void make_enemy()
{
	int now_tim_enemy=time(0);
	srand(time(0));
	int enemy_making_lie=rand()%27+4;
	if(now_tim_enemy-tim_enemy_making>=2)
	{
		enemy[++enemy_top].life=1;
		enemy[enemy_top].x=1;
		enemy[enemy_top].y=enemy_making_lie;
		tim_enemy_making=now_tim_enemy;
	}
}
//    =||=
//     ||
// ====||====
//	   --
void draw(int x,int y)
{
	if(Map[x][y]==0) putchar (' ');
//  1~3:player
	if(Map[x][y]==1||Map[x][y]==2) color("GRE"),putchar('|');
	if(Map[x][y]==3)               color("GRE"),putchar('=');
//  4~7:enemy
	if(Map[x][y]==4||Map[x][y]==5) color("GRA"),putchar('-');
	if(Map[x][y]==6)               color("GRA"),putchar('|');
	if(Map[x][y]==7)               color("GRA"),putchar('=');
//  8~9:bullet
	if(Map[x][y]==8)   //子弹特殊操作
	{
		color("YEL"),putchar('^');
		Map[x][y]=0;
		if(x-1)
			Map[x-1][y]=8;
	}
	if(Map[x][y]==9)   //子弹特殊操作
	{
		color("YEL"),putchar(' ');
		Map[x][y]=0;
		if(x-1)
			Map[x-1][y]=9;
	}
//  10~12:blast
	if(Map[x][y]==10)               color("YEL"),putchar('O');
	if(Map[x][y]==11)               color("RED"),putchar('o');
	if(Map[x][y]==12)               color("WHI"),putchar('+');
}
void home();
void game();
void teach();
void team();
void chushihua();
void home ()
{
	system("mode con cols=62 lines=41");

	color("YEL");
	int n;
	cout<<"      _____          _______         ____        _____"<<endl;
	cout<<"     /____/|        /______/\       /___/|      /____/|"<<endl;
	cout<<"    /_   | |       /  ___  \/|     /   | |     /_   | |"<<endl;
	cout<<"      |  | |       | /\__\ | |    / /| | |_      |  | |"<<endl;
	cout<<"      |  | |       | \/__/ | |   / /_| |/_/|     |  | |"<<endl;
	cout<<"      |  | |       \____   | |   |___   __|/     |  | |"<<endl;
	cout<<"     _|  | |__      ____|  | |       | | |      _|  | |__"<<endl;
	cout<<"    /_|  |/__/|    /____|  |/        | | |     /_|  |/__/|"<<endl;
	cout<<"    |________|/    \_______/         |_|/      |________|/"<<endl;
	cout<<endl<<endl;
	color("WHI");
	cout<<"                       1.开始游戏 "<<endl;
	cout<<"                       2.游戏教程 "<<endl;
	cout<<"                       3.制作团队 "<<endl;
	cout<<"                       4.退出游戏 "<<endl;
	cout<<"                       请选择: ";

	cin>>n;
	if(n==1)
	{
		game();
	}
	if(n==2)
	{
		teach();
	}
	if(n==3)
	{
		team();
	}
	if(n==4)
	{
		system("cls");
		cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
		exit(0);
	}
}
void chushihua ()
{
	p_life=5;
	p_fenshu=0;
	memset(Map,0,sizeof Map);
	p_x=17,p_y=9;
}
void team()
{
	system("mode con cols=62 lines=41");
	color("WHI");
	cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
	cout<<"                   作者:蒟蒻尹、xiedongbiao     n     "<<endl;
	cout<<"                   策划:蒟蒻尹          n"<<endl;
	cout<<"                   测试:xiedongbiao          n"<<endl;
	cout<<"                   美术:蒟蒻尹          n"<<endl;
	cout<<"                   校正:xiedongbiao          n"<<endl;
	cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
	system("pause");
	system("cls");
	home();
}
void teach()
{
	system("mode con cols=62 lines=41");
	color("WHI");
	cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
	cout<<"                  ↑           "<<endl;
	cout<<"             按 ←↓→控制飞机移动, 按 "空格" 键开火          "<<endl;
	cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
	system("pause");
	system("cls");
	home();
}
void die()
{
	color("WHI");
	system("mode con cols=62 lines=41");
	int n;
	cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
	cout<<"                       1.返回主页 "<<endl;
	cout<<"                       2.退出游戏 "<<endl;
	cout<<"                       请选择: ";
	cin>>n;
	if(n==1)
	{
		home();
	}
	if(n==2)
	{
		system("cls");
		cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
		exit(0);
	}
}
void game()
{

	hide_cursor();
	for(int i=0; i<=37; i++)
	{
		for(int j=0; j<=35; j++)
		{
			v[i][j]=1;
		}
	}
	system("mode con cols=37 lines=41");
	while (true)
	{
		if(p_life==0)
		{
			die();
		}
		make_enemy();
		enemy_step();
		player_step();
		blast_check();
		color("WHI");
		printf("     SCORE             ");
		printf("LIFEn");
		color("YEL");
		cout<<setw(10)<<p_fenshu<<"             ";
		color("RED");
		for(int i=1; i<=p_life; i++) cout<<(char)3;
		printf("n");
		color("WHI");
		for(int i=0; i<=35; i++) printf("-");;
		printf("n");
		for(int i=0; i<=37; i++)
		{
			for(int j=0; j<=35; j++)
			{
				draw(i,j);
			}
			if(i!=38-1)puts("");
		}

		Sleep(10);
		system("cls");

	}
}
int main()
{

	home();
}

最后,

大家如果觉得有改进的空间的话,请向我提出,我会努力做出更好的游戏

最后

以上就是粗暴指甲油为你收集整理的原创游戏:血战太平洋1.1(可在Dev-C++上运行)前言: 献上代码:最后,的全部内容,希望文章能够帮你解决原创游戏:血战太平洋1.1(可在Dev-C++上运行)前言: 献上代码:最后,所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(32)

评论列表共有 0 条评论

立即
投稿
返回
顶部