#include <Stdio.h>
#include "LessonX.h"
#include "List.h"
// 游戏全局变量定义
int g_iGameState = 0; // 游戏状态,0:结束或者等待开始;1:初始化;2:游戏进行中
float g_fGameTime = 0.f; // 游戏进行的总时长
float g_fDifficulControl = 0.f; // 难度系数控制。根据游戏时间,逐渐增加游戏的难度系数(原理:使用此系数,降低各敌机的出现间隔时间,越到后面敌机出的越快)
int g_iMaxScore = 0; // 历史最高积分
int g_iCreatedSpriteCount = 0; // 当前已经创建的Sprite数量,递增,以创建唯一的名字
//
float g_fWorldLeft = -50.f; // 世界上下左右边界
float g_fWorldRight = 50.f;
float g_fWorldTop = -37.f;
float g_fWorldBottom = 37.f;
//
// 我们控制的精灵ControlSprite的数据
float g_fVelocityLeft = 0.f; // 控制飞机的上下左右速度
float g_fVelocityRight = 0.f;
float g_fVelocityTop = 0.f;
float g_fVelocityBottom = 0.f;
bool g_bControlCanFire = false; // 按下发射键的时候,将此值设置为true,可以发射。松开的时候,设置为false
//
// 各种敌机出现的时间间隔
float g_fBossCreateTime = 30.f;
float g_fRotateCreateTime = 25.f;
float g_fHorCreateTime = 5.f;
float g_fVerCreateTime = 6.f;
float g_fHealthCreateTime = 25.f;
//
SGameSprite g_ControlSprite; // 我们控制的飞机 -- ControlSprite
SGameSprite g_ControlSprite1;
//
////////////////////////////////////////////////////////////////////////////////
//
// 定义各种类型的Sprite的模板数值,创建的时候,直接拷贝此模板数值即可
SGameSprite g_BigBossTemplate;
SGameSprite g_RotateTemplate;
SGameSprite g_HorTemplate;
SGameSprite g_VerTemplate;
SGameSprite g_HealthTemplate;
SGameSprite g_Bullet1Template;
SGameSprite g_Bullet2Template;
// 函数声明
void GameInit();
void GameEnd();
void GameRun( float fDeltaTime );
void CreateBigBossTick( float fDeltaTime );
void CreateRotateTick( float fDeltaTime );
void CreateHorTick( float fDeltaTime );
void CreateHealthTick( float fDeltaTime );
void CreateVerTick( float fDeltaTime );
SGameSprite *CreateBullet1( const int iBulletType, const float fPosX, const float fPosY );
SGameSprite *CreateBullet2( const int iBulletType, const float fPosX, const float fPosY, const float fTarPosX, const float fTarPosY );
void BigBossLoopTick( SGameSprite *pSprite, float fDeltaTime );
void RotateLoopTick( SGameSprite *pSprite, float fDeltaTime );
void HorLoopTick( SGameSprite *pSprite, float fDeltaTime );
void VerLoopTick( SGameSprite *pSprite, float fDeltaTime );
void ControlColOther( SGameSprite *pControl, SGameSprite *pOther );
void HealthColOther( SGameSprite *pHealth, SGameSprite *pOther );
void Bullet1ColOther( SGameSprite *pBullet, SGameSprite *pOther );
void Bullet2ColOther( SGameSprite *pBullet2, SGameSprite *pOther );
void EnemyColOther( SGameSprite *pEnemy, SGameSprite *pOther );
// 初始化各种模板数据
void InitTemplateData()
{
// 我们控制的Control Sprite
strcpy( g_ControlSprite.szName, "ControlSprite" );
g_ControlSprite.iHp = CONTROL_MAX_HP;
g_ControlSprite.iScore = 0;
g_ControlSprite.iDamage = 500; // 敌机碰到我,也会被击伤...
g_ControlSprite.eSpriteType = SPRITE_CONTROL;
g_ControlSprite.iBulletType = 0; // Unused
g_ControlSprite.fFireAfterCreate = 0.f; // Unused
g_ControlSprite.fBulletTime = 0.3f; // 0.3秒发射一次子弹
g_ControlSprite.fBulletTime2 = 0.f; // Unused
g_ControlSprite.fFloatTime = 0.f; // 飞行中上下浮动控制
g_ControlSprite.bFloatUp = true;
// 我们控制的Control Sprite
strcpy( g_ControlSprite1.szName, "ControlSprite1" );
g_ControlSprite.iHp = CONTROL_MAX_HP;
g_ControlSprite.iScore = 0;
g_ControlSprite.iDamage = 500; // 敌机碰到我,也会被击伤...
g_ControlSprite.eSpriteType = SPRITE_CONTROL;
g_ControlSprite.iBulletType = 0; // Unused
g_ControlSprite.fFireAfterCreate = 0.f; // Unused
g_ControlSprite.fBulletTime = 0.3f; // 0.3秒发射一次子弹
g_ControlSprite.fBulletTime2 = 0.f; // Unused
g_ControlSprite.fFloatTime = 0.f; // 飞行中上下浮动控制
g_ControlSprite.bFloatUp = true;
g_HealthTemplate.szName[0] = '\0';
g_HealthTemplate.iHp = 1; // 生命值1
g_HealthTemplate.iScore = 10; // 积分10
g_HealthTemplate.iDamage = 500; // 此伤害值,实际为碰撞的时候给ControlSprite增加的HP
g_HealthTemplate.eSpriteType = SPRITE_HEALTH;
g_HealthTemplate.iBulletType = 0; // Unused
g_HealthTemplate.fFireAfterCreate = 0.f; // Unused
g_HealthTemplate.fBulletTime = 0.0f; // Unused
g_HealthTemplate.fBulletTime2 = 0.f; // Unused
g_HealthTemplate.fFloatTime = 0.f; // 飞行中上下浮动控制
g_HealthTemplate.bFloatUp = true;
//
g_VerTemplate.szName[0] = '\0';
g_VerTemplate.iHp = 100; // 生命值100
g_VerTemplate.iScore = 50; // 积分50
g_VerTemplate.iDamage = 500; // 碰到自身,伤害500
g_VerTemplate.eSpriteType = SPRITE_VER;
g_VerTemplate.iBulletType = 0; // Unused
g_VerTemplate.fFireAfterCreate = 1.f; // 出生1s后开始发射子弹
g_VerTemplate.fBulletTime = 1.f; // 1秒发射一次子弹
g_VerTemplate.fBulletTime2 = 0.f;
g_VerTemplate.fFloatTime = 0.f; // 飞行中上下浮动控制
g_VerTemplate.bFloatUp = true;
//
// 其它Sprite...
g_BigBossTemplate.szName[0] = '\0';
g_BigBossTemplate.iHp = 2000; // 生命值2000
g_BigBossTemplate.iScore = 500; // 积分500
g_BigBossTemplate.iDamage = 100000; // 这个数字必须比ControlSprite的生命值HP大,保证ControlSprite一碰到自己就死
g_BigBossTemplate.eSpriteType = SPRITE_BIG_BOSS;
g_BigBossTemplate.iBulletType = 0; // Unused
g_BigBossTemplate.fFireAfterCreate = 2.f; // 出生2s后开始发射子弹
g_BigBossTemplate.fBulletTime = 1.f; // 1秒发射一次子弹
g_BigBossTemplate.fBulletTime2 = 3.f; // 2秒发射一次特殊子弹
g_BigBossTemplate.fFloatTime = 0.f; // 飞行中上下浮动控制
g_BigBossTemplate.bFloatUp = true;
//
g_RotateTemplate.szName[0] = '\0';
g_RotateTemplate.iHp = 100; // 生命值100
g_RotateTemplate.iScore = 100; // 积分100
g_RotateTemplate.iDamage = 500; // 碰到自身,伤害500
g_RotateTemplate.eSpriteType = SPRITE_ROTATE;
g_RotateTemplate.iBulletType = 0; // Unused
g_RotateTemplate.fFireAfterCreate = 1.f; // 出生1s后开始发射子弹
g_RotateTemplate.fBulletTime = 3.f; // 只有一种子弹,2秒发射一次
g_RotateTemplate.fBulletTime2 = 0.f; // 无2种子弹
g_RotateTemplate.fFloatTime = 0.f; // 飞行中上下浮动控制
g_RotateTemplate.bFloatUp = true;
//
g_HorTemplate.szName[0] = '\0';
g_HorTemplate.iHp = 100; // 生命值100
g_HorTemplate.iScore = 50; // 积分50
g_HorTemplate.iDamage = 500; // 碰到自身,伤害500
g_HorTemplate.eSpriteType = SPRITE_HOR;
g_HorTemplate.iBulletType = 0; // Unused
g_HorTemplate.fFireAfterCreate = 1.f; // 出生1s后开始发射子弹
g_HorTemplate.fBulletTime = 1.f; // 1秒发射一次子弹
g_HorTemplate.fBulletTime2 = 0.f;
g_HorTemplate.fFloatTime = 0.f; // 飞行中上下浮动控制
g_HorTemplate.bFloatUp = true;
//
//
g_Bullet1Template.szName[0] = '\0';
g_Bullet1Template.iHp = 1; // 生命值1
g_Bullet1Template.iScore = 10; // 积分10
g_Bullet1Template.iDamage = 0; // 伤害值由发射的Sprite决定
g_Bullet1Template.eSpriteType = SPRITE_BULLET1;
g_Bullet1Template.iBulletType = 0; // 类型由发射的Sprite决定
g_Bullet1Template.fFireAfterCreate = 0.f; // Unused
g_Bullet1Template.fBulletTime = 0.0f; // Unused
g_Bullet1Template.fBulletTime2 = 0.f; // Unused
g_Bullet1Template.fFloatTime = 0.f; // 飞行中上下浮动控制
g_Bullet1Template.bFloatUp = true;
//
g_Bullet2Template.szName[0] = '\0';
g_Bullet2Template.iHp = 1; // 生命值1
g_Bullet2Template.iScore = 10; // 积分10
g_Bullet2Template.iDamage = 0; // 伤害值由发射的Sprite决定
g_Bullet2Template.eSpriteType = SPRITE_BULLET2;
g_Bullet2Template.iBulletType = 0; // 类型由发射的Sprite决定
g_Bul
没有合适的资源?快使用搜索试试~ 我知道了~
程序设计实训funcode(海底世界+太空战机)
共403个文件
dso:92个
cs:78个
png:62个
需积分: 50 55 下载量 30 浏览量
2018-12-01
20:23:14
上传
评论 8
收藏 58.66MB ZIP 举报
温馨提示
funcode程序 海底世界和太空战机源代码(C language)太空战机升级了界面和游戏难度,游戏画风相对清新,开始界面是像素风,外送old threads 音乐一条(适合作背景音)
资源推荐
资源详情
资源评论
收起资源包目录
程序设计实训funcode(海底世界+太空战机) (403个子文件)
CommonAPI.a 65KB
CommonAPI.a 65KB
kkcapture 2018-06-19 16-54-54.avi 30.86MB
level.t2d.bak 17KB
level.t2d.bak 7KB
fsd.cbp 2KB
program1.cbp 2KB
LessonX.cpp 38KB
Main.cpp 5KB
ListX.cpp 4KB
Main.cpp 3KB
LessonX.cpp 2KB
datablocks.cs 22KB
levelManagement.cs 14KB
levelManagement.cs 14KB
datablocks.cs 12KB
options.cs 11KB
options.cs 11KB
profiles.cs 10KB
profiles.cs 10KB
keybindings.cs 10KB
keybindings.cs 10KB
align.cs 9KB
align.cs 9KB
xml.cs 8KB
xml.cs 8KB
messageBox.cs 6KB
messageBox.cs 6KB
common.cs 5KB
common.cs 5KB
chatClient.cs 5KB
chatClient.cs 5KB
projectManagement.cs 4KB
projectManagement.cs 4KB
main.cs 4KB
main.cs 4KB
serverConnection.cs 4KB
serverConnection.cs 4KB
message.cs 4KB
message.cs 4KB
clientConnection.cs 4KB
clientConnection.cs 4KB
projectResources.cs 4KB
projectResources.cs 4KB
chatServer.cs 4KB
chatServer.cs 4KB
defaultPrefs.cs 4KB
defaultPrefs.cs 4KB
screenshot.cs 3KB
screenshot.cs 3KB
metrics.cs 3KB
metrics.cs 3KB
properties.cs 3KB
properties.cs 3KB
cursor.cs 3KB
cursor.cs 3KB
audio.cs 2KB
audio.cs 2KB
server.cs 2KB
server.cs 2KB
main.cs 2KB
main.cs 2KB
help.cs 2KB
help.cs 2KB
client.cs 2KB
client.cs 2KB
message.cs 2KB
message.cs 2KB
canvas.cs 2KB
canvas.cs 2KB
main.cs 2KB
main.cs 2KB
guiProfiles.cs 1KB
guiProfiles.cs 1KB
game.cs 1KB
game.cs 1KB
kickban.cs 839B
kickban.cs 839B
scriptDoc.cs 640B
scriptDoc.cs 640B
cursors.cs 598B
cursors.cs 598B
datablocks.cs 365B
datablocks.cs 365B
brushes.cs 122B
brushes.cs 122B
persistent.cs 38B
persistent.cs 38B
banlist.cs 0B
banlist.cs 0B
Score.dat 4B
rocksnear.dds 512KB
rocksfar.dds 512KB
bgmountains1.dds 256KB
pufferfishpuffsheet.dds 256KB
butterflyfishsheet.dds 256KB
angelfish1sheet.dds 256KB
angelfish2sheet.dds 256KB
background.dds 256KB
triggerfish1sheet.dds 256KB
共 403 条
- 1
- 2
- 3
- 4
- 5
资源评论
踏雪无痕的大虾
- 粉丝: 2
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- database-project-massunaAi笔记
- 2%EF%BC%9A%E9%99%95%E8%A5%BF%E
- yyspdz62_944.apk
- SAP公司间采购EDI配置-如何触发自动MIRO.docx
- python197基于图像识别的仪表实时监控系统.rar
- python196基于循环神经网络的情感分类系统.rar
- I2C驱动SHT30温湿度传感器和LCD12864使用例程(RSCG12864B)
- python193中学地理-中国的江河湖泊教学网(django).rar
- python191基于时间序列分析的大气污染预测软件(django).rar
- python190基于人脸识别智能化小区门禁管理系统.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功