⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mygame.h

📁 基于C++的RPG小游戏
💻 H
字号:
#pragma once

#include "resource.h"
#include <string>

string makestring(string,int);

int Game_Init(void);
int Game_Main(void);
int Game_Down(void);

class Cplane;
class Cpplayer;
class Cpenemy;
class xg;
class bullet;
class bouns;
class boss;




#define MOVE_STATE_UP 1
#define MOVE_STATE_RIGHT 2
#define MOVE_STATE_DOWN 4
#define MOVE_STATE_BACK 8
#define P_STATE_MOVE 1
#define P_STATE_ATTACK 2
#define MAX_ANIM_FRAME 50
#define BULLET_NORMAL 0
#define BULLET_UNABLE 9

#define ENEMY_STATUS_DEAD 9

#define XG_STATUS_NORMAL 0
#define XG_STATUS_DEAD 9

#define BOUNS_STATUS_NORMAL 0
#define BOUNS_STATUS_DEAD 9


typedef struct Cpoints_type
	{
		int x;
		int y;
	}Cpoints;

class boss{
public:
	int x;
	int y;
	int xx;
	int yy;
	RECT rboss;
	int width;
	int height;
	vector<xg> xgzd;
	int dx;
	int dy;
	int status;
	int moveindex;
	int bulletindex;
	boss();
private:
};

boss::boss()
{
	moveindex=0;
	bulletindex=0;
	dx=0;
	dy=0;
	x=640;
	y=140;
	status=0;
	xx=x+60;
	yy=y+40;
	rboss.left=xx;
	rboss.top=yy;
	rboss.right=rboss.left+190;
	rboss.bottom=rboss.top+220;
	xgzd.clear();
}

class bullet
{
public:
	bullet();
	bullet(int ,int,int,int,int,int,int,int,int);
	bullet(int ,int,int,int); 
	bullet(int ,int,int,int,int,int,int,int,int,int,int); 
	Cpoints Pos;
	int width;
	int height;
	int type;
	int movtype;
	int status;
	int speed;
	int dx;
	int dy;
	RECT drect;
	int animidx;
	int maxframe;
	int power;
private:
};
bullet::bullet(int x,int y,int ddx,int ddy)
{
	width=16;
	height=16;
	speed=15;
	Pos.x=x;
	Pos.y=y;
	dx=ddx;
	dy=ddy;
	type=3;
	maxframe=6;
	status=0;
	animidx=0;
	power=5;
}
bullet::bullet(int wid,int hei,int sp,int x,int y,int tp,int movtp,int maxfrm,int pow)
{
	width=wid;
	height=hei;
	speed=sp;
	Pos.x=x;
	Pos.y=y;
	type=tp;
	movtype=movtp;
	maxframe=maxfrm;
	status=0;
	animidx=0;
	power=pow;
}
bullet::bullet(int wid,int hei,int sp,int x,int y,int tp,int movtp,int maxfrm,int pow,int px,int py)
{
	width=wid;
	height=hei;
	speed=sp;
	Pos.x=x;
	Pos.y=y;
	type=tp;
	movtype=movtp;
	maxframe=maxfrm;
	status=0;
	animidx=0;
	dx=px;
	dy=py;
	power=pow;
}
bullet::bullet()
{
	status=0;
	animidx=0;
}

class xg
{
public:
	xg();
	xg(int,int,int,int,int,int,int);
	int row;
	int width;
	int height;
	Cpoints xgPos;
	int index;
	int status;
	int type;
	int maxframe;
	RECT drect;
private:
};
xg::xg()
{
	index=0;
	status=0;
}
xg::xg(int wid,int hei,int posx,int posy,int mxfm,int rw,int tp)
{
	width=wid;
	height=hei;
	xgPos.x=posx;
	xgPos.y=posy;
	maxframe=mxfm;
	row=rw;
	type=tp;
	status=0;
	index=0;
}


class Cplane
{
public:
	Cpoints PPos;
	int index;
	int width;
	int height;
private:
};
class Cpplayer:public Cplane
{
public:
	Cpplayer();
	~Cpplayer();
//	ChangeRect(int);
	int playerstate;
	int movestate;
	int pmovidx;
	int pmovdir;
	int bulltp;
	int bullpw;
	int health;
	RECT drect;
	vector<bullet> zd;
	int boom;
//	LP_BITMAPX ppp;
private:
};

class Cpenemy:public Cplane
{
public:
	Cpenemy();
	~Cpenemy();
	Cpenemy(int,int,int,int,int,int,int,int,int,int,int,int);
	//	ChangeRect(int);
	int bullettim;
	int bulidx;
	int movetype;
	int enemytype;
	int bulltp;
	int speed;
	int enemystate;
	int maxfrm;
	int row;
	int animidx;
	int health;
	RECT drect;
	vector<bullet> zd;
	//	LP_BITMAPX ppp;
private:
};

Cpplayer::Cpplayer (void)
{
	width=50;
	height=38;
	PPos.x =100;
	PPos.y=221;
	pmovidx=8;
	health=500;
	movestate =0;
	playerstate =0;
	bulltp=2;
	bullpw=1;
	boom=9;
	zd.clear ();
//	ppp=NULL;

//	ppp=(LP_BITMAPX)malloc(sizeof(LP_BITMAPX));
//	ppp=GetGraphics()->CreateBitmapFromBMP("player3.bmp");
//	ppp->SetColorKey (RGB2Hi(255,255,255));
	
}



Cpplayer::~Cpplayer()
{
//	GetGraphics()->RemoveBitmap(ppp);
	
}

Cpenemy::~Cpenemy()
{

}

Cpenemy::Cpenemy()
{
}

Cpenemy::Cpenemy(int wid,int hei,int bulltime,int posx,int posy,int mvtp,int emtp,int butp,int sped,int maxf,int ro,int hel)
{
	width=wid;
	height=hei;
	bullettim=bulltime;
	bulidx=0;
	PPos.x=posx;
	maxfrm=maxf;
	PPos.y=posy;
	movetype=mvtp;
	row=ro;
	animidx=0;
	enemytype=emtp;
	bulltp=butp;
	speed=sped;
	enemystate=0;
	health=hel;
}


int ChangeRect (int i,int x,int y,RECT& drect)
{
	int cx,cy;
	cx=i % 9;
	cy=i / 9;
	drect.left =cx*x;
	drect.right =drect.left +x;
	drect.top =cy*y;
	drect.bottom =drect.top +y;
	return 1;	
}

class bouns{
public:
	bouns();
	bouns(int ,int,int,int,int,int,int); 
	Cpoints Pos;
	int width;
	int height;
	int type;
	
	int status;
	int row;
	int dx;
	int dy;
	RECT drect;
	int animidx;
	int maxframe;
private:
};

bouns::bouns()
{
};

bouns::bouns(int x,int y,int wid,int hei,int tp,int mf,int rw)
{
	Pos.x=x;
	Pos.y=y;
	width=wid;
	height=hei;
	type=tp;
	maxframe=mf;
	row=rw;
	animidx=0;
	status=BOUNS_STATUS_NORMAL;
}


vector<Cpenemy> planeenemy;
vector<xg> vxg;
vector<bouns> vbouns;
vector<bullet> pub;

int retran(int a)
{
	int py=0;
	py=rand();
	py+=90;
	py=(int)(py%a);
	return py;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -