资源简介
模仿QQ堂的SDL编写的linux下的小游戏

代码片段和文件信息
#include
#include
#include
#include
//图片路径定义
#define IMG_Player1 “image/boy2.bmp“ //“image/player.png“
#define IMG_INJURED “image/boy2_injured.bmp“
#define IMG_BUBBLE “image/bomb.png“ //“image/bubble.bmp“
#define IMG_BG “image/bg4.bmp“
#define IMG_FLAME2 “image/flame2.png“
#define IMG_FLAME4 “image/flame4.png“
#define IMG_GAMEOVER “image/gameover.gif“
#define IMG_MEDICINE “pics/medicine.bmp“
#define IMG_SHOES “pics/shoe.bmp“
#define IMG_LIFE “./pics/time.gif“
#define IMG_SPEED “./pics/time.gif“
//方向定义
#define DIR_UP 3
#define DIR_LEFT 1
#define DIR_DOWN 0
#define DIR_RIGHT 2
#define MAIN_ZONE_W 520
#define MAIN_ZONE_H 480
#define ATTACK 2
#define INTERVAL 30
#define BUBBLE_NUM 62
#define RAND_MAX 65536
#define WaitTime 10
#define ExistTime 5
//游戏中的人物
typedef struct _Player {
int w;
int h;
int x;
int y;
int ox;
int oy;
int dir;
int subframe;
int speed;
int life;
int timer;
SDL_Surface *image;
}Player;
typedef struct _Bubble {
int w;
int h;
int x;
int y;
int subframe;
int timer;
int level;
SDL_Surface *image;
}Bubble;
//各种附加工具的添加 此处用1代表是药炉 可添加一条命
//此处用0代表是鞋 可使速度加1
typedef struct _Tool{
int w;
int h;
int x;
int y;
int type;//0是鞋 1是药炉
int already_exist_time;//代表已经出现的时间
int WaitForNext;//代表下一个物品出现的时间还有多久
int flag;//代表是否有效
SDL_Surface *image[2];
}Tool;
//游戏状态
typedef enum _GameState {
GAME_RUNNING
GAME_OVER
}GameState;
//全局变量
int second[2]minute[2];
SDL_Surface *screen; //整个屏幕
SDL_Surface *back_image;
SDL_Surface *player_image;
SDL_Surface *injured_image;
SDL_Surface *medicine_image;
SDL_Surface *shoes_image;
SDL_Surface *life_image;
SDL_Surface *speed_image;
GameState game_state;
Player player1;
Bubble bubble[BUBBLE_NUM];
Tool MedOrShoes;
int current_num;
int boom; //当前屏幕上是否有泡泡
int erase;
int injured;
int g_timer=-1;
int away;
int interval=5;
int oldlife=3;
int oldspeed;
//加锁
void Slock(SDL_Surface *lock){
if(SDL_MUSTLOCK(lock)){
if(SDL_LockSurface(lock)<0){
return;
}
}
}
/*解锁*/
void Sulock(SDL_Surface *lock){
if(SDL_MUSTLOCK(lock)){
SDL_UnlockSurface(lock);
}
}
//初始化SDL
void Init_SDL() {
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
exit(1);
}
screen = SDL_SetVideoMode(64048016SDL_SWSURFACE);
if(screen == NULL) {
exit(1);
}
}
//Tool函数初始化
void Init_Tools(){
MedOrShoes.x=0;
MedOrShoes.y=0;
MedOrShoes.w=30;
MedOrShoes.h=30;
MedOrShoes.type=0;//最先初始化为鞋
MedOrShoes.flag=0;//最初无效
MedOrShoes.already_exist_time=0;//出险多于..s还没被吃掉则擦掉
MedOrShoes.WaitForNext = WaitTime;//每..s出现一个物品
medicine_image = IMG_Load(IMG_MEDICINE);
medicine_image = SDL_DisplayFormat(medicine_image);
shoes_image = IMG_Load(IMG_SHOES);
shoes_image = SDL_DisplayFormat(shoes_image);
MedOrShoes.image[0]=shoes_image;
MedOrShoes.image[1]=medicine_image;
SDL_SetColorKey(MedOrShoes.image[0]SDL_SRCCOLORKEYSDL_MapRGB(MedOrShoes.image[0]->format255255255));
SDL_SetColorKey(MedOrShoes.image[1]SDL_SRCCOLORKEYSDL_MapRGB(MedOrShoes.image[1]->f
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 20988 2006-11-30 09:55 game\bm
文件 14152 2006-11-30 09:52 game\bm.c~
文件 19853 2008-12-02 20:59 game\bubbleman.c
文件 19852 2008-12-02 20:58 game\bubbleman.c~
文件 14798 2006-11-30 07:51 game\bubbleman1.c~
文件 13457 2006-11-25 20:41 game\sdl
文件 1111 2006-11-25 18:30 game\sdl.c
文件 1109 2006-11-25 18:28 game\sdl.c~
文件 25065 2008-12-02 20:59 game\aaa
文件 11810 2006-11-30 09:17 game\bak\bubbleman.c
文件 11812 2006-11-30 07:50 game\bak\bubbleman.c~
文件 14798 2006-11-30 07:53 game\bak\bubbleman1.c
文件 1378 2007-08-29 08:30 game\image\baby.gif
文件 153718 2006-11-29 15:58 game\image\bg.bmp
文件 921654 2006-11-29 17:05 game\image\bg2.bmp
文件 921654 2006-11-29 17:07 game\image\bg3.bmp
文件 921654 2008-03-10 14:03 game\image\bg4.bmp
文件 10989 2006-11-29 10:35 game\image\bomb.png
文件 21654 2006-11-28 23:14 game\image\boy2.bmp
文件 8278 2006-11-29 21:07 game\image\boy2_injured.bmp
文件 2814 2006-11-28 23:36 game\image\bubble.bmp
文件 1674 2008-11-25 20:37 game\image\bubble.png
文件 5654 2006-11-29 11:32 game\image\flame.bmp
文件 7937 2006-11-29 14:50 game\image\flame.png
文件 2814 2006-11-29 13:19 game\image\flame2.bmp
文件 31389 2007-09-01 10:05 game\image\game.gif
文件 206909 2007-08-29 08:30 game\image\gameover.gif
文件 1674 2008-11-25 20:37 game\image\pla
文件 425 2007-09-01 10:05 game\image\time.gif
文件 63744 2008-03-12 20:52 game\image\flame4.png
............此处省略17个文件信息
- 上一篇:多重分形文章与代码
- 下一篇:Windows内核原理与实现 微软对高校提供的系统源码
相关资源
- uboot到linux logo显示不间断 补丁
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- linux下用多进程同步方法解决生产者
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
- 基于GTK的Linux环境下的简易任务管理器
- linux扫雷游戏代码
- CAN Linux驱动代码
- Linux系统教材
- intel 82579LM 网卡驱动Linux系统版 v1.9.
- SA1110处理器掌上电脑液晶显示器设计
- 基于Linux的串口服务器设计
- Windows下访问LINUX的利器-SSH
评论
共有 条评论