• MINI-FOOLFLY 游戏代码
  •  2009/5/20 14:57:15 | 分类:C语言 | 阅读:709
  • 导读:/oolflygamevbyskywind空战摸拟源程序,林伟年月日这是一个空战程序的模式例子,并没有做任何优化与扩充仅仅向人说明编写游戏程序的若干功能实现或常用处理方法程序是版的,现在写游…

  • / Fool fly game v1.0 by skywind
    空战摸拟源程序,林伟 1999年7月30日

    这是一个空战程序的模式例子,并没有做任何优化与扩充
    仅仅向人说明编写游戏程序的若干功能实现或常用处理方法
    程序是DOS版的,现在写游戏的平台早已变化了许多,但是
    我尽量容入了一些不变理论,希望才入门的游戏设计者能受
    到一些启发,通过它也可以看出当日DOS下设计的困难重重。

    整个程序不足300行,请用BC31或者TC20的Large模式编译
    /

    #include <stdio.h>
    #include <dos.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <mem.h>
    #include <time.h>
    #include <math.h>
    #include <alloc.h>

    #define  MAX_STAR   80                    / 最多星星数目         /
    #define  MAX_OBJ    30                    / 最多物体(子弹和敌人) /
    #define  MAXY      169                  / y坐标的最大值        /
    typedef unsigned long ulong;
    char far VideoBuf=(char far)0xa0000000L, MemBuf;     / MemBuf 图形二级缓存 /
    char  keys;                                        / keys[0..100] 键盘上各键的状态   /
    const KEY_UP=72,KEY_DOWN=80,KEY_LEFT=75,KEY_RIGHT=77,KEY_ESC=1,KEY_CTRL=29;
                                                    / 键盘扫描码 /
    void interrupt far (OldInt9)(void);                            / 老的键盘中断程序地址 /
    void interrupt NewInt9(void);                                   / 新的键盘中断服务程序 /
    char GameStart(void);
    strUCt TStars { int x,y,v; } Stars[MAX_STAR];   / 星星的描述 /
    struct TObj { int mode,type,index,next,x,y; } Objs[MAX_OBJ]; / 子弹和敌人的描述 /
    long GameScore=0;                               / 游戏分数 /

    unsigned char fly_pic={      / 飞机的图形,我是用程序将PCX图形转换过来的 /
    16,0,16,0,0,0,0,29,25,0,0,0,0,25,29,196,0,0,0,0,0,0,0,25,25,0,0,0,0,25,0,196,0,
    0,0,0,112,112,0,25,196,40,40,29,112,112,40,112,0,112,112,112,40,40,112,112,40,40,
    25,25,112,40,40,112,112,112,112,112,112,40,112,25,40,40,112,112,112,40,40,25,
    40,112,112,0,0,112,112,25,40,40,40,112,40,40,40,25,40,112,0,0,0,0,112,25,40,
    112,40,112,112,112,40,25,112,0,0,0,0,0,0,29,112,0,40,0,112,0,112,29,0,0,0,0,
    0,0,0,29,112,0,40,54,112,0,112,29,0,0,0,0,0,0,0,29,0,0,40,54,112,0,0,29,0,0,
    0,0,0,0,0,0,0,40,112,25,112,112,0,0,0,0,0,0,0,0,0,0,0,40,112,25,112,112,0,0,
    0,0,0,0,0,0,0,0,0,40,112,112,112,112,0,0,0,0,0,0,0,0,0,0,0,0,40,112,112,0,0,
    0,0,0,0,0,0,0,0,0,0,0,40,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,0,0,0,0,0,
    0};    / 数据头四个字节分别由两个16位数据表示图片的长和宽,后面是图片8bit的颜色数据 /

    void copyright(void)
    { printf("Game Over. your score %ld\n",GameScore);
      printf("Thank you for play it, if you have any question please call me\n");
      printf("(0871)7167710 or lwwind@yeah.net, Lin Wei\n");

    }

    int game_init(void);
    int game_restore(void);

    void main(void)
    {
      if (!game_init()) return;                    / 游戏初始化 /
      printf("           - STAR WAR -\r");         /  打印标题  /
      GameStart();                                 / 游戏主循环 /
      game_restore();                              / 还原初始化 /

    (学 习 吧:www.xuexibar.cn)

    此文章为学 习 整理或来自网络,内容仅供访问者参考,版权归原作者所有,转载请注明出处!