资源简介
这个游戏使用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.em
文件 472 2013-05-18 15:28 gamefeiji\gamefeiji\Debug\gamefeiji.exe.em
文件 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\li
文件 2 2013-05-18 15:28 gamefeiji\gamefeiji\Debug\li
文件 2 2013-05-18 15:28 gamefeiji\gamefeiji\Debug\li
文件 2 2013-05-18 15:28 gamefeiji\gamefeiji\Debug\li
文件 2 2013-05-18 15:28 gamefeiji\gamefeiji\Debug\li
文件 2 2013-05-18 15:28 gamefeiji\gamefeiji\Debug\li
文件 2 2013-05-18 15:28 gamefeiji\gamefeiji\Debug\li
文件 2 2013-05-18 15:28 gamefeiji\gamefeiji\Debug\li
............此处省略70个文件信息
- 上一篇:IPv4到IPv6过渡技术的研究及其仿真
- 下一篇:机器学习实战中文pdf
相关资源
- 很久以前的MUD游戏源码和mudos
- HGE基础教程
- pppd2.4.7源代码以及拨号脚本
- 基于Sun技术创建世界级游戏的安全架
- 酒店预订管理系统源代码
- 酷冷至尊开阳星游戏鼠标驱动 v1.08 官
- 迪龙游戏手柄驱动 v6.0.0.619 绿色免费
- 机会路由源代码+仿真工具(SCORP)
- 批量替换证件照片的底色(含源代码
- cocos2d-x飞机大战项目
- 40款h5游戏+21款热门测试吸粉
- 分享一个远程控制软件源代码
- BLE-CC254x-1.3.2 蓝牙官方源代码
- BATOCERA游戏系统整合包.zip
- 程序源代码行数统计工具
- flutter_gallery源代码
- Butterfly.net通过按需计算推动下一代游
- 插件式GIS应用框架的设计与实现&mda
- x264源代码
- 游戏物理引擎开发&源代码.zip
- 易语言文字打怪游戏源码
- 易语言海战小游戏源码
- 街机游戏HACK ROM的制作加教程
- Cocos2d-x开发游戏的坐标系知识介绍
- 易语言征途登陆器源代码源码
- 易语言猜拳游戏客户端源码易语言猜
- VC++ RS232 RS485串口通信源代码_
- 烟花效果源代码
- 易语言P2P源代码1源码易语言P2P网络电
- ABB机器人教学仿真源代码_搬运应用
评论
共有 条评论