资源简介
游戏编写 c编写潜艇大战代码。初学c开发游戏的同学使用。

代码片段和文件信息
# include
# include “13h.h“
# include
# include
# include “timer.h“
# include
# include
struct stBOMB
{
int x;
int y;
BOOL Used;
};
struct stEXPL
{
int x;
int y;
BYTE Num;
BOOL Used;
};
struct stSHIP
{
int x;
int y;
BOOL Used;
BYTE Dir;
BYTE Type;
};
struct stTORP
{
int x;
int y;
BOOL Used;
};
struct stBOMB bbBomb[21];
struct stSHIP spShip[21];
struct stTORP tpTorp[21];
struct stEXPL elExpl[21];
int BombUsed=0;
int ShipUsed=0;
int TorpUsed=0;
int ExplUsed=0;
int MAXBOMB=5;
int MAXSHIP=3;
int MAXTORP=5;
int MAXEXPL=5;
int ID_Timer[MAXTIMER+1];
int ID_Bomb[21];
int ID_Ship[21];
int ID_Torp[21];
int ID_Expl[21];
BOOL DISP=TRUE;
BOOL CLS=FALSE;
BOOL bPaint=FALSE;
BOOL ALIVE=TRUE;
BOOL SOUND=TRUE;
BOOL Flash=FALSE;
BOOL DONE=FALSE;
BYTE SHIP[2][32][64];
BYTE BOMB[32][32];
BYTE TORP[16][16];
BYTE PAL[256][3];
BYTE STR[80];
BYTE far * PIC_EXPL;
BYTE far * PIC_SHIP;
void far * Back1;
void far * Back2;
int MyX=0;
int MyY=0;
int Life=3;
int Score=25;
int LevelScore=25;
int Level=0;
int Step=0;
/* */
char *Info=“\
\\Welcome to play this game!\
\n\
\n\
\n\
In this gameyou will drive a warship to fight with\n\
the submarines.\n\n\
KEYS:\n\
‘Left‘ and ‘Right‘ keys to move your warship.\n\
‘Space bar‘ or ‘Ctrl‘ key to send bombs.\n\
‘S‘ key is a sound switch.\n\
‘D‘ key is a state switch.\n\n\
\n\
\n\n\
GOOD LUCK!\0“;
/* */
void StepIn()
{
int i;
for (i=0;i<256;i++)
/* */
setpal(iPAL[i][0]*Step/64PAL[i][1]*Step/64PAL[i][2]*Step/64);
Step++;
if (Step>64)
/* */
KillAllTimer();
}
/* */
void StepOut()
{
int i;
for (i=0;i<256;i++)
/* */
setpal(iPAL[i][0]*Step/64PAL[i][1]*Step/64PAL[i][2]*Step/64);
Step--;
/* */
if (Step<1)
KillAllTimer();
}
void OutInfo()
{
if (*Info++)
{
sound(1000);
printf(“%c“*(Info-1));
nosound();
}
else
KillAllTimer();
}
void Logo()
{
FILE *bmp;
int irgbxy;
setmode();
bmp=fopen(“logo.bmp““rb“);
fseek(bmp54SEEK_SET);
for (i=0;i<256;i++)
{
PAL[i][2]=fgetc(bmp)>>2;
PAL[i][1]=fgetc(bmp)>>2;
PAL[i][0]=fgetc(bmp)>>2;
fgetc(bmp);
setpal(i000);
}
for (y=0;y<200;y++)
for (x=0;x<320;x++)
pokeb(0xa000y*320+xfgetc(bmp));
fclose(bmp);
CreateTimer(1StepIn);
while (ScanKey()!=57&&TimerUsed)
TimerEvent();
Step=64;
StepIn();
wait();
CreateTimer(1StepOut);
while (ScanKey()!=57&&TimerUsed) TimerEvent();
Step=0;
StepOut();
closemode();
CreateTimer(2OutInfo);
locate(626);
while (ScanKey()!=57&&TimerUsed)
TimerEvent();
while (*Info++)
printf(“%c“*(Info-1));
wait();
}
void KillSelf()
{
if (SOUND
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2423 2004-05-11 19:35 08-潜艇大战游戏\13H.H
文件 5174 2001-12-15 19:09 08-潜艇大战游戏\boat.bmp
文件 1540 2001-12-15 19:03 08-潜艇大战游戏\bomb.bmp
文件 60726 2001-12-15 19:08 08-潜艇大战游戏\expl.bmp
文件 65080 2003-10-29 19:49 08-潜艇大战游戏\Logo.bmp
文件 65080 2011-04-13 08:57 08-潜艇大战游戏\Logo1.bmp
文件 180054 2003-10-29 19:23 08-潜艇大战游戏\ms_submarine.bmp
文件 24537 2003-10-29 19:00 08-潜艇大战游戏\ms_submarine.jpg
文件 11158 2001-12-15 19:09 08-潜艇大战游戏\SHIP.BMP
文件 13763 2004-05-11 19:17 08-潜艇大战游戏\ship.c
文件 43921 2004-05-11 19:36 08-潜艇大战游戏\ship.exe
..A.SH. 24576 2011-05-05 11:34 08-潜艇大战游戏\Thumbs.db
文件 1333 2004-05-11 19:23 08-潜艇大战游戏\TIMER.H
文件 772 2001-12-15 19:03 08-潜艇大战游戏\torp.bmp
目录 0 2013-03-02 20:24 08-潜艇大战游戏
----------- --------- ---------- ----- ----
500137 15
- 上一篇:yasm-1.3.0-win64.exe
- 下一篇:rbf神经网络图像识别
相关资源
- Power Electronic Converters Modeling and Contr
- CE修改器风叶人加强版
- Oracle+11gR2+RAC安装详解(HP-UX+11.31+ia6
- Oracle+GoldenGate运维完全手册
- STM32F103RC+ADC+DMA多通道采样LCD显示
- Modbus协议官方文档中、英文全
- pcbtemp电流计算软件
- I2C读写AT24C02 基于STM32F103 cube116540
- Scratch源码
- Microsoft Forms 2.0107770
- 实验三 消息中间件应用开发:Active
- WCE注入工具
- ModelGoon-4.4.1-site.zip
- AsyncTask文件控制暂停和继续,在状态
- Visio大全模具(含Cisco、IBM等常用拓扑
- 信号奇异点Lipschitz指数计算
- 基于STM32RCT6的步进电机驱动程序
- 酒店管理系统基于Qt Creator5)
- 用友NC开发API字典
- flash3.0小游戏
- Navicat Premium 15汉化包.zip55438
- 登录注册界面.zip48872
- 条码字体barcode128
- Rational Rose Common破解文件
- res10_300x300_ssd_iter_140000.caffemodel与dep
- scratch 第1课 翻跟斗的小猫(入门)
- stm32f407上的两个can发送和接收例程
- Scrach 欢乐狙击手.sb2
- 04741计算机网络原理知识点整理.docx(
- Wolfram Mathematica 矩阵初等变换函数(
评论
共有 条评论