#include "YCY.h"
HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
#define V 500
#define bulletv 3*V
#define myplanevx V/2.0f
#define myplanevy V/2.0f
#define enemyplanevx rand()%(int)V*3/10.0f-V*3/20.0f
#define enemyplanevy rand()%V/500 * 0.5 + 80
#define bossShow 7000 //boss出现所需的分数
#define GAP_SUPER 1300 //superpower的出现间隔
#define GAP_LIFE 2300 //newlife的出现间隔
#define planenum 9
int yy=0,xx=0;
GLfloat color[12][3]={{0.5f,0.5f,1.0f},{0.75f,0.5f,1.0f},{1.0f,0.5f,1.0f},{0.5f,1.0f,0.5f},
{1.0f,1.0f,0.5f},{0.75f,1.0f,0.5f},{1.0f,0.5f,0.5f},{1.0f,0.75f,0.5f},
{1.0f,0.5f,0.75f},{0.5f,1.0f,0.75f},{0.5f,1.0f,1.0f},{0.5f,0.75f,1.0f}};
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
int winwidth = 800, winheight=600;
int totalScore = 0;
int myplanelife=10; //开始时有10条命
GLuint myplanetexID,
bullettexID,
enemyplanetexID,
particletexID,
bulletID,
bossID,
background,
bossbulletID,
superpowerID,
bbID,
newlifeID;
int k=planenum;
GLuint base; // 绘制字体的显示列表的开始位置
bool game=true;
bool flag=false;
bool pause=false;
bool begin=false;
bool temp=false;
bool flag2=false;
bool flag3=false;
bool flag4=false;
bool flag5=false;
bool flag6=false;
bool flag7=false;
bool flag8=false;
bool flag9=false;
bool flag10=false;
bool flag11=false;
bool flag12=false;
bool flag13=false;
bool flag14=false;
bool flag15=false;
int cnt_super;
int cnt_life;
int skill = 0;
double duration;
struct Particles
{
bool active;
float life;
float fade;
float x,y;
float r,g,b;
float xi;
float yi;
}particle[100];
struct Myplane {
GLfloat x,y;
GLfloat vx,vy;
GLfloat w,h;
}myplane;
struct Bullet {
GLfloat r,g,b;
GLfloat x,y;
GLfloat v;
GLfloat size;
GLint active;
}bullet[2];
struct Enemyplane {
GLfloat r,g,b;
GLfloat br,bg,bb;
GLfloat x,y;
GLfloat vx,vy;
GLfloat w,h;
GLint score;
GLfloat bv;
GLfloat by;
GLfloat bx;
GLfloat bsize;
bool bactive;
}enemyplane[20];
struct Boss{
GLfloat h;
GLfloat w;
GLfloat x,y;
GLint life;
GLint score;
}boss;
struct BossBullet{
GLfloat vx;
GLfloat vy;
GLfloat y;
GLfloat x;
GLfloat size;
}bossbullet[6];
struct Superpower{
GLfloat v;
GLfloat x;
GLfloat y;
GLfloat size;
}superpower;
struct Newlife{
GLfloat x, y;
GLfloat v;
GLfloat size;
}newlife;
struct BB{
GLfloat x;
GLfloat y;
GLfloat size;
GLfloat v;
}bb[10];
void Initnewlife()
{
newlife.x = rand()%500-250.0f;
newlife.y = winheight/2.0f+rand()%100;
newlife.v = enemyplanevy*3.0f;
newlife.size= 30.0f;
}
void InitBB(){
int xx=0;
for(int i=0;i<9;i++){
bb[i].x= -winwidth/2.0f + 110.0f +xx;
xx+=70;
bb[i].y = winheight/2.0f;
bb[i].size = 20.0f;
bb[i].v = enemyplanevy*20.0f;
}
}
void Initboss()
{
boss.x=winwidth/2.0f - 500.0f;
boss.y=winheight-350.0f;
boss.h=200.0f;
boss.w=200.0f;
boss.life=30;
boss.score=500;
}
void Reshape(int i)
{
if(i == 0)
{
bossbullet[i].x = boss.x + 40.0f;
bossbullet[i].y = boss.y - boss.h/2.0f;
bossbullet[i].vy = V/3.0f;
bossbullet[i].vx = -V/6.0f;
}
else if(i == 1)
{
bossbullet[i].x = boss.x + boss.w/2.0f;
bossbullet[i].y = boss.y - boss.h/2.0f;
bossbullet[i].vy = V/3.0f;
bossbullet[i].vx = 0.0f;
}
else if(i == 2)
{
bossbullet[i].x = boss.x + boss.w - 40.0f;
bossbullet[i].y = boss.y - boss.h/2.0f;
bossbullet[i].vy = V/3.0f;
bossbullet[i].vx = V/6.0f;
}
else if(i == 3)
{
bossbullet[i].x = boss.x + 100.0f;
bossbullet[i].y = boss.y - boss.h/2.0f - 20.0f;
bossbullet[i].vy = V/3.0f;
bossbullet[i].vx = -V/6.0f;
}
else if(i == 4)
{
bossbullet[i].x = boss.x +boss.w - 100.0f;
bossbullet[i].y = boss.y - boss.h/2.0f - 20.0f;
bossbullet[i].vy = V/3.0f;
bossbullet[i].vx = V/6.0f;
}
else if(i == 5)
{
bossbullet[i].x = boss.x + boss.w/2.0f;
bossbullet[i].y = boss.y - boss.h/2.0f - 40.0f;
bossbullet[i].vy = V/3.0f;
bossbullet[i].vx = 0.0f;
}
bossbullet[i].size = 10.0f;
}
void Initbossbullet(int j)
{
if(j == 6)
{
for(int i=0;i<6;i++)
Reshape(i);
}
else Reshape(j);
}
void Initmyplane()
{
myplane.x=0.0f;
myplane.h=40.0f;
myplane.y=-winheight/2.0f+130.0f;
myplane.w=35.0f;
myplane.vx=myplanevx;
myplane.vy=myplanevy;
}
void Initbullet()
{
bullet[0].r=1.0f;
bullet[0].g=1.0f;
bullet[0].b=1.0f;
bullet[0].x=myplane.x + myplane.w/2.0f;
bullet[0].y=myplane.y-myplane.h/2.0f;
bullet[0].v=bulletv;
bullet[0].size=15.0f;
bullet[0].active=0;
}
void InitEnemyBullet(int j)
{
if(j>planenum)
{
enemyplane[j].br=1.0f;
enemyplane[j].bg=1.0f;
enemyplane[j].bb=1.0f;
enemyplane[j].bv=V/4.0f;
enemyplane[j].bsize=5.0f;
enemyplane[j].bx=enemyplane[j].x+enemyplane[j].w/2.0f;
enemyplane[j].by=enemyplane[j].y-enemyplane[j].h/2.0f;
}
else
{
enemyplane[j].br=1.0f;
enemyplane[j].bg=1.0f;
enemyplane[j].bb=1.0f;
enemyplane[j].bv=enemyplane[j].vy * 2.0f;
enemyplane[j].bsize=5.0f;
enemyplane[j].bx=enemyplane[j].x+enemyplane[j].w/2.0f;
enemyplane[j].by=enemyplane[j].y-enemyplane[j].h/2.0f;
}
}
void Initenemyplane(int j)
{
if(j == planenum+5)
{
for(int i=0;i<planenum + 5;i++)
{
enemyplane[i].r=1.0f;
enemyplane[i].g=1.0f;
enemyplane[i].b=1.0f;
if(i<planenum)
{
enemyplane[i].x=rand()%500-250.0f;
enemyplane[i].y=winheight/2.0f+rand()%100;
enemyplane[i].h=40.0f;
enemyplane[i].w=40.0f;
enemyplane[i].vx=enemyplanevx;
enemyplane[i].vy=enemyplanevy;
enemyplane[i].score=100;
}
else if(i ==10 )
{
enemyplane[i].x=boss.x+40.0f;
enemyplane[i].y=boss.y - boss.h + 70.0f;
enemyplane[i].vx=V/6.0f;
enemyplane[i].vy=V/5.0f;
enemyplane[i].score=200;
}
else if(i ==11)
{
enemyplane[i].x=boss.x+boss.w-60.0f;
enemyplane[i].y=boss.y - boss.h + 70.0f;
enemyplane[i].vx=-V/6.0f;
enemyplane[i].vy=V/5.0f;
enemyplane[i].score=200;
}
else if(i ==12)
{
enemyplane[j].x=boss.x + 40.0f;
enemyplane[j].y=boss.y - boss.h + 90.0f;
enemyplane[i].vx=-V/4.0f;
enemyplane[i].vy=0.0f;
enemyplane[i].score=200;
}
else if(i ==13)
{
enemyplane[i].x=boss.x+boss.w-60.0f;
enemyplane[i].y=boss.y - boss.h + 90.0f;
enemyplane[i].vx=V/4.0f;
enemyplane[i].vy=0.0f;
enemyplane[i].score=200;
}
InitEnemyBullet(i);
}
}
else
{
enemyplane[j].r=1.0f;
enemyplane[j].g=1.0f;
enemyplane[j].b=1.0f;
enemyplane[j].h=40.0f;
enemyplane[j].w=40.0f;
if(j>planenum)
{
if(j ==10 )
{
enemyplane[j].x=boss.x + 40.0f;
enemyplane[j].y=boss.y - boss.h + 70.0f;
enemyplane[j].vx=V/6.0f;
enemyplane[j].vy=V/5.0f;
enemyplane[j].score=300;
}
else if(j ==11)
{
enemyplane[j].x=boss.x + boss.w - 60.0f;
enemyplane[j].y=boss.y - boss.h + 70.0f;
enemyplane[j].vx=-V/6.0f;
enemyplane[j].vy=V/5.0f;
enemyplane[j].score=300;
}
else if(j ==12)
{
enemyplane[j].x=boss.x + 40.0f;
enemyplane[j].y=boss.y - boss.h + 90.0f;
enemyplane[j].vx=-V/4.0f;
enemyplane[j].vy=0.0f;
enemyplane[j].score=300;
}
else if(j ==13)
{
enemyplane[j].x=boss.x + boss.w - 60.0f;
enemyplane[j].y=boss.y - boss.h + 90.0f;
enemyplane[j].vx=V/4.0f;
enemyplane[j].vy=0.0f;
enemyplane[j].score=300;
}
}
else
{
enemyplane[j].score=100;
enemyplane[j].x=rand()%500-250.0f;
enemyplane[j].y=winheight/2.0f+rand()%100;
评论2
最新资源