手机版
你好,游客 登录 注册
背景:
阅读新闻

C++“超级玛丽”游戏的源代码

[日期:2012-03-05] 来源:Linux社区  作者:Linux [字体:大 中 小]

C++“超级玛丽”游戏的源代码示例:

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<mem.h>
#include<dos.h>
#include<string.h>
#include<alloc.h>
#include<time.h>
#include<f:\smb\key.c>  //KEYBOARD HANDLER FILE
    //(f:\smb\ = directory of file key.c)

#include<f:\smb\xline.h>        //Xlib Header files for Mode X graphics
#include<f:\smb\xrect.h>  //Functions!
#include<f:\smb\xpoint.h> //(f:\smb\ = directory of x*.h)
#include<f:\smb\xvsync.h>
#include<f:\smb\xpbitmap.h>
#include<f:\smb\xbmtools.h>

#define TEXTCOLOR  35
#define BACKGROUND 32

typedef struct
{
  char red;
  char green;
  char blue;
}colorpal;

//DEFINE GRAPHICS ARRAYS/////////////////////////////////////////////////////
typedef struct
{
  char mario[7][16][16];
  char far *block[52];
  char world[14][217];
  char far *coin[3];
  short int bumped[2];
  short int bumploop;
  short int sprite;
  short int direction;
  short int maxlength;
  short int startpos[2];
  colorpal palette[256];
  colorpal marioc[2];
  colorpal luigic[2];
} graphics;

//PLAYER INFO STRUCTURE//////////////////////////////////////////////////////
typedef struct
{
  unsigned int score[2];
  short int coins[2];
  short int level;
  short int lives;
  short int screenx;
} stats;

typedef struct ct
{
  short int coinx;
  short int coiny;
  short int coinloop;
  short int dy;
  struct ct *next;
}cointype;

typedef struct st
{
  short int scorex;
  short int scorey;
  short int scoreloop;
  char num[5];
  struct st *next;
}scoretype;

//GLOBAL VARIABLES///////////////////////////////////////////////////////////
unsigned char far *charset=(unsigned char far *)0xF000FA6EL;
graphics data;
stats player[2];
struct time t;
unsigned int times[3];
short int curplay;
int mariox;
int marioy;
short int landed;
cointype *bcoin;
scoretype *bscore;

//FUNCTION PROTOTYPES////////////////////////////////////////////////////////
void init();
void fillscreen(int color);
int  getinputs();
void getmario();
char *getpcx(FILE *file, char *temp, int length);
void setpalette(int index, colorpal color);
void graphchar(int xc, int yc, char c,int color, unsigned offset);
void drawscreen(int x);
void graphstring(int x,int y,char *string,int color,unsigned offset);
void drawmario(int x, int y);
void status();
int startscreen();
void levelscreen();
void setcolors();
void rotatepal(int *palloopp, colorpal *tempcp);
void check_keybuf(int *movep, int *finishp, int *upp, int *downp, int *jumploop);
void animate_mario(int move);
void move_mario(int *movep);
void addcoin(int x,int y);
void removecoin();
void drawcoin();
void addscore(int x,int y, char *pscore);
void removescore();
void drawscore();
void exitgame();
void check_jump(int *upp, int *downp, int *jumploopp);
void check_blocks();
void check_finish(int *finishp);

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2012年资料/3月/5日/C++“超级玛丽”游戏的源代码/

linux
相关资讯       C++ 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款