资源简介
这个游戏使用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
相关资源
- bp神经网络源代码,可直接运行
- flash3.0小游戏
- Scrach 欢乐狙击手.sb2
- 仿知乎界面小程序源代码
- 贪吃蛇源代码.fla
- dotnet 写字板 实验 源代码 不好请要不
- 图像二维小波变换的实现源代码
- 八三编码器设计 VHDL代码 简单,包附
- linux应用层的华容道游戏源代码
- 网上拍卖系统完整源代码
- CSMA/CD等动画演示加源代码
- silicon lab公司的收音IC SI47XX全套开发工
- 合同管理系统的源代码(附数据库)
- 用VC 编写的仿QQ聊天室程序源代码
- 小鸡快跑游戏.
- STM32F103 串口程序(完整版)
- VPC3_DPV1源代码,Profibus
- PB做的托盘程序(最小化后在左下角显
- 透明加密源码及说明
- 排队机叫号 源代码
- 五子棋C 源代码
- CAD LISP24个源代码
- 二叉树基本操作源代码
- 推箱子及人工智能寻路C 源代码
- opengl轮廓字体源代码
- [易语言]游戏多开例程
- 冈萨雷斯 数字图像处理 源代码(m文
- 直流伺服电机电路原理图(内附单片
- 贪吃蛇游戏设计(汇编语言)
- 哈哈冒险岛登入器源代码
评论
共有 条评论