C++闲代码——大游戏(格斗类)

Hello,大家好,我是木头做的鱼,木鱼啊。

现在啊,科技越来越进步,许许多多的应用、科技出现(不过我说这干嘛)。

上一次不是做了一个闲游戏吗,呃...手痒,我就再做了一个,希望大家喜欢。

目录

正文

头文件.cpp

函数定义及类型定义.cpp

函数.cpp

主函数.cpp


正文

今天给大家带来的是格斗类游戏(C++),包含技能、二人游戏...

那么就来吧!!!!!!!!!!!!

头文件.cpp

#include<iomanip>
#include<iostream>
#include<conio.h>
#include<windows.h>
#include<cstdio>
#include<vector>
#include<cstring>
#include<string>
#define bottom 40
#define jumph 6
#define skills 6
#define skilled 2
#define Setcolor(NAME) if(NAME)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE);else SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE)
#define Backcolor(NAME) if(NAME)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE)
#define Choosecolor(NAME) if(NAME==2)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED| FOREGROUND_GREEN|FOREGROUND_BLUE | FOREGROUND_INTENSITY|BACKGROUND_BLUE );else if(!NAME)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_RED| BACKGROUND_INTENSITY| BACKGROUND_GREEN|BACKGROUND_RED|BACKGROUND_BLUE );else if(NAME==1)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY| BACKGROUND_GREEN|BACKGROUND_RED)

当然函数当然少不了啦

函数定义及类型定义.cpp

using namespace std;
void HideCursor();
void go(int x, int y);
void movewindow();
void GetContain();
void start1();
void start2();
void _skillprint(int, int);
void skillprint(int, int);
void mapprint();
void Getmove();
void winprint(bool);
void BoomGet();
class bullet;
class player;
bool dj1, dj2, s11, s12, s21, s22;
int da1, da2, skill1[2] = { 4, 3 }, skill2[2] = {2, 4}, boom1, boom2, cost[10] = {0, 3, 3, 5, 15}, place[11][2][2], explace[11][2]; //[???üêy×?][ê?óú][x,y×?±ê]
float cool[2][2];
char hit[2];
string name1, name2, contain[11], excontain[11];
vector<bullet>bu;
class player {
	public:
		int x, y, j, jh, life, loving, flying, gaying;
		char a, b[2];
		bool dir, fly, myself, fdir;
		void clear() {
			go(x, y);
			printf(" ");
			go(x, y + 1);
			printf(" ");
		}
		void print() {
			Setcolor(myself);
			if (gaying)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE);
			go(x, y);
			if (loving) {
				Setcolor(!myself);
				cout << (char)3;
				Setcolor(myself);
			} else if (gaying)cout << "?á";
			else cout << a;
			go(x, y + 1);
			cout << b[dir];
			Backcolor(myself);
		}
		void lifedown(int l) {
			if (!myself) {
				go(life - l + 1, 2);
				for (int i = 1; i <= l; ++i)
					cout << " ";
			} else {
				go(188 - life, 2);
				for (int i = 1; i <= l; ++i)
					cout << " ";
			}
			life -= l;
		}
		void jump() {
			++j;
			if (j <= jh) {
				clear();
				--y;
				print();
			} else fly = 1;
		}
		void flown() {
			++flying;
			clear();
			if (flying <= jumph - 1)--y;
			else if (flying <= 2 * jumph - 2)++y;
			else flying = 0;
			if (!fdir)x -= 2;
			else x += 2;
			if (x < 1)x = 1;
			else if (x > 188)x = 188;
			print();
		}
		void skill(int, bool);
		void attack();
		void move(int);
} p1, p2;
class bullet {
	public:
		int x, y, boom, length, soap;
		bool own, dir, love;
		inline void clear() {
			go(x, y);
			cout << " ";
		}
		void print() {
			Setcolor(own);
			go(x, y);
			if (boom)cout << (char)15;
			else if (love)cout << (char)3;
			else if (soap) cout << "¨|";
			else cout << hit[own];
			Backcolor(own);
		}
		void start(int p, int q, bool d, bool o) {
			y = q;
			dir = d;
			own = o;
			if (!d)x = p - 1;
			else x = p + 1;
			boom = 0;
			love = 0;
			length = 0;
			soap = 0;
		}
		void boomstart(int p, int q, bool d, bool o, int l) {
			y = q + 1;
			dir = d;
			own = o;
			if (!d)x = p - 1;
			else x = p + 1;
			boom = 1;
			length = l;
			love = 0;
		}
		bool fly() {
			if (boom >= 800) {
				if (boom == 805) {
					for (int i = -4; i <= 4; i += 2)
						for (int j = -2; j <= 2; ++j) {
							if (x + i < 1 || x + i > 188 || y + j > bottom + 1)continue;
							go(x + i, y + j);
							cout << " ";
						}
					p1.print();
					p2.print();
					return 1;
				}
				++boom;
				return 0;
			}
			if (soap != -1)clear();
			if (!dir)--x;
			else ++x;
			if (boom) {
				if (!dir)x -= length;
				else x += length;
			}
			if (boom) {
				++boom;
				char _sign = 4;
				if (x < 1 || x > 188) {
					Setcolor(own);
					for (int i = -4; i <= 4; i += 2)
						for (int j = -2; j <= 2; ++j) {
							if (x + i < 1 || x + i > 188 || y + j > bottom + 1)continue;
							go(x + i, y + j);
							cout << _sign ;
						}
					Backcolor(own);
					if (!own) {
						if (x >= p2.x - 4 && x <= p2.x + 4 && y + 2 >= p2.y && y - 2 <= p2.y + 1) {
							p2.lifedown(10);
							if (x > p2.x)p2.fdir = 0;
							else p2.fdir = 1;
							p2.flown();
						}
					} else {
						if (x >= p1.x
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值