• 大小: 2.39MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-09-26
  • 语言: 其他
  • 标签: HGE  游戏  源代码  

资源简介

这个游戏使用HGE游戏引擎写的,代码不难,可以供初学HGE者参考。

资源截图

代码片段和文件信息

// gamefeiji.cpp : 定义控制台应用程序的入口点。
//

#include “stdafx.h“
#include “SetXY.h“
#include “include\hge.h“
#include “include\hgesprite.h“
#include “include\hgeFont.h“
#include “include\hgeanim.h“
#include 
#include 
#include 
#include “include\hgeparticle.h“
#define EnemyNum  10
void Free_work(); //释放内存
void DrawParticle(); //每次运行时画图函数
void Init_Data(); //初始化数据
void Add_One_Enemy();
EnemyPlane EP[EnemyNum];
int EnemyN; //当前敌机数

HGE *hge = 0;
hgeSprite *foeman[5] ={00000};
hgeSprite *me =0; //飞机自己精灵
hgeAnimation *fire;
hgeSprite *zidan;
hgeSprite *background;

HTEXTURE foemans[5]; //敌机纹理
HTEXTURE fly; //自己飞机纹理
HTEXTURE fires; //后尾的火
HTEXTURE zidans; //子弹
HTEXTURE map;

static int boomnum;
static float backgroundmapY =0;
OneXY mainplain ;
OneXY zidanxy[100];
float dtt; //间隔时间积累

void DestoryDouble(int zidan int feiji)
{
for(int i =zidan; i {
zidanxy[i].h = zidanxy[i+1].h;
zidanxy[i].x = zidanxy[i+1].x;
zidanxy[i].y = zidanxy[i+1].y;
zidanxy[i].w = zidanxy[i+1].w;
}

for(int i =feiji ; i {
EP[i].EnemyType =EP[i+1].EnemyType;
EP[i].xspeed    =EP[i+1].xspeed;
EP[i].yspeed    =EP[i+1].yspeed;
EP[i].location.h    =EP[i+1].location.h;
EP[i].location.x    =EP[i+1].location.x;
EP[i].location.y    =EP[i+1].location.y;
EP[i].location.w    =EP[i+1].location.w;

}
boomnum--;
EnemyN--;
printf(“%d  %d \n“boomnumEnemyN);
}


void Add_One_boom(int x int y)
{
boomnum=boomnum+1;
zidanxy[boomnum].x=x;
zidanxy[boomnum].y=y;
zidanxy[boomnum].w=16;
zidanxy[boomnum].h=32;
}

void run_booms()
{
for(int i=0; i {
if(zidanxy[i].y< -20)
{
//缩进
for(int j =i; j {
zidanxy[j].x = zidanxy[j+1].x;
zidanxy[j].y = zidanxy[j+1].y;

}
if(boomnum>0) boomnum--;
}
}
for(int i=0; i {
zidanxy[i].y = zidanxy[i].y-10;


}
}

//碰撞检测
bool Hit(int x1int y1int w1  int h1int x2int y2  int w2  int h2)
{
printf(“%d %d %d %d %d %d %d %d\n“x1y1w1  h1x2 y2   w2   h2);
if(x1+w1x2+w2 || y1+h1y2+h2) return false;
//无碰撞

else return true; //碰上了
}

void Destory_Enemy()
{
for(int i=0; i< EnemyN; i++)
if( EP[i].location.y >600) //缩进
{
for(int j =i ; j {
EP[j].EnemyType  = EP[j+1].EnemyType;
EP[j].location.x = EP[j+1].location.x;
EP[j].location.y = EP[j+1].location.y;
EP[j].xspeed     = EP[j+1].xspeed;
EP[j].yspeed     = EP[j+1].yspeed;
}

EnemyN--;
return;
}
}


bool RenderFunc()
{  
hge->Gfx_BeginScene();  
    hge->Gfx_Clear(0);  

    // End rendering and update the screen  
for(int i=0; i {
zidan->Render(zidanxy[i].xzidanxy[i].y);
zidan->SetZ(0.0f);
}
background->Render(0backgroundmapY);//背景
background->Render(0 backgroundmapY-1024);
background->

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-05-15 21:51  gamefeiji\
     目录           0  2013-05-15 21:50  gamefeiji\Debug\
     文件       93240  2007-10-12 19:12  gamefeiji\Debug\bass.dll
     文件       47616  2013-05-18 15:28  gamefeiji\Debug\gamefeiji.exe
     文件      355252  2013-05-18 15:28  gamefeiji\Debug\gamefeiji.ilk
     文件      723968  2013-05-18 15:28  gamefeiji\Debug\gamefeiji.pdb
     文件      166400  2008-02-12 16:48  gamefeiji\Debug\hge.dll
     目录           0  2013-05-15 21:49  gamefeiji\gamefeiji\
     文件         894  2013-05-15 21:31  gamefeiji\gamefeiji.sln
     文件       10752  2013-05-18 15:28  gamefeiji\gamefeiji.suo
     文件       93240  2007-10-12 19:12  gamefeiji\gamefeiji\bass.dll
     目录           0  2013-05-15 21:50  gamefeiji\gamefeiji\Debug\
     文件        2730  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\cl.command.1.tlog
     文件       23092  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\CL.read.1.tlog
     文件        1236  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\CL.write.1.tlog
     文件         406  2013-05-15 21:41  gamefeiji\gamefeiji\Debug\gamefeiji.exe.embed.manifest
     文件         472  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\gamefeiji.exe.embed.manifest.res
     文件         381  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\gamefeiji.exe.intermediate.manifest
     文件          40  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\gamefeiji.lastbuildstate
     文件        4215  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\gamefeiji.log
     文件       81749  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\gamefeiji.obj
     文件     1179648  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\gamefeiji.pch
     文件         208  2013-05-15 21:38  gamefeiji\gamefeiji\Debug\gamefeiji_manifest.rc
     文件           2  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\link-cvtres.read.1.tlog
     文件           2  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\link-cvtres.write.1.tlog
     文件           2  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\link.4376-cvtres.read.1.tlog
     文件           2  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\link.4376-cvtres.write.1.tlog
     文件           2  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\link.4376.read.1.tlog
     文件           2  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\link.4376.write.1.tlog
     文件           2  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\link.5212-cvtres.read.1.tlog
     文件           2  2013-05-18 15:28  gamefeiji\gamefeiji\Debug\link.5212-cvtres.write.1.tlog
............此处省略70个文件信息

评论

共有 条评论