ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:20.64KB ,
资源ID:3785209      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3785209.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Linux街机游戏源码.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Linux街机游戏源码.docx

1、Linux街机游戏源码C语言编的街机游戏,全部源代码下载,这个是仿LINUX下KTron的游戏,已有其大部分功能 时间 : 2007-02-13 作者:佚名 编辑:本站 点击: 2650 评论 -综合 资源 电子书 社区 *游戏说明*Trone V0.1仿LINUX下街机游戏KTron。其实写本游戏的动机就是我一个朋友特别喜欢linux下的KTron这个游戏,但在WINDOWS下又没找到,而我朋友又不太熟悉LINUX操作,所以我就花了点时间写了Trone,Trone这个名字也是源于KTron。注意:此游戏需要EGAVGA.BGI文件才能运行,该文件在turboc2目录下可找到。游戏简介这是一个

2、双人玩的策略游戏,游戏有两个点,第一个游戏者可以按R,G,F,D控制第一个点的走向,第两个游戏都可以按四个光标键控制第二个点的走向,谁先碰到边界或已走的路线便输,祝大家玩得开心有任何问题或建议请与我联系。此游戏可任意复制,作者保留所有权力!如果你想要源代码,那么请发邮件给我。请不要删除此文件,有新功能增加可加在下面:Trone V0.1功能简介游戏者1控制键:R,F,D,G游戏者2控制键:UP,DOWN,LEFT,RIGHTF1:查看帮助信息F2:设定游戏速度等级,0为最快,1为正常,2最慢F3:设定游戏者1的颜色,有15种颜色可以选择,黑色是背景色,不能选F4:设定游戏者2的颜色F5:继续游

3、戏。Author:jadewater(gaowenfeng)email:*QQ:182824199如果这里不能下载你可以发邮件给我,其中包括4个文件:Trone.c(源代码),Trone.exe(已编译连接游戏文件),EGAVGA.BGI,游戏说明.txt*这个游戏已编译成可执行文件,可以在附件里找到,如果你不能编译的话可以与我联系,我可以把已编译的程序与源文件全发给你。下面的全是原代码。转载请注明作者,谢谢!共享是这个时代的主题!:)*#include #include #include #include #include #include #include /* 功能键设置 */#defi

4、ne ESC 0x001b /* 退出游戏 */#define F1 0x3b00 /* 查看帮助信息,调用HelpMassage()函数 */#define F2 0x3c00 /* 设定游戏速度等级,调用Set_Level()函数 */#define F3 0x3d00 /* 设定游戏者1的颜色,调用Set_Color()函数 */#define F4 0x3e00 /* 设定游戏者2的颜色,调用Set_Color()函数 */#define F5 0x3f00 /* 以下功能键暂时保留,如果增加功能可使用 */#define F6 0x4000#define F7 0x4100#defi

5、ne F8 0x4200#define F9 0x4300#define F10 0x4400/* Player1 hot key 游戏者1热键上下左右分别用RFDG控制 */#define RIGHT1 71#define LEFT1 68#define UP1 82#define DOWN1 70/* Player2 hot key 游戏者2热键,四个光标键控制方向 */#define RIGHT 0x4d00#define LEFT 0x4b00#define UP 0x4800#define DOWN 0x5000/* 定义画方框的坐标X,Y,以及颜色Color,Draw为是(1)否(

6、0)已走过 */struct information int color,draw; int x,y; ;typedef struct information INFOR;/* 记录游戏者在把在位置,X与Y其实就是全局数组coordinate的两个下标 */struct playerxy int x,y; ;typedef struct playerxy CurrentCoor;/* 此全局数组是记录画每个框的坐标及颜色以及是否已走过 */INFOR coordinate8060;time_t Timeout=1; /* 限制游戏的快慢,可用Set_Level()设定 */int size=8

7、,maxX=79,maxY=56; /* size定义画框的大小,单位为像素,maxX,maxY为数组coordinate下标的最大值 */* BackColor为游戏背景色,Player1Color与Player2Color为游戏者默认颜色,可调用Set_Color()函数设定 */int BackColor=BLACK,Player1Color=WHITE,Player2Color=LIGHTRED; /* 初始化图形模式 */void InitialGraphics(void) int graphdriver=VGA,graphmode=VGAHI; int errorcode; ini

8、tgraph(&graphdriver,&graphmode,); errorcode=graphresult(); if(errorcode!=grOk) printf(Graphics error:%sn,grapherrormsg(errorcode); GoodBye(); /* 退出游戏显示提示信息,只有不能初始化图形界面才会调用此函数 */int GoodBye(void) printf(Thank you very much!n); printf(If you have any question,n); printf(Please send email to me: * or A

9、dd QQ:182824199n); GetKey(); exit(0);/* 初始化游戏界面 */void InitFace(void) setbkcolor(BackColor); cleardevice(); setcolor(WHITE); rectangle(0,0,639,479); setcolor(LIGHTGREEN); rectangle(3,3,636,452); setcolor(LIGHTRED); rectangle(3,455,250,476); rectangle(253,455,636,476);/* 初始化全局数组coordinate */void Init

10、Coordinate(void) int x,y; for(x=0;xmaxX;x+) for(y=0;yx=maxX/3; player2-x=maxX/3*2; player1-y=maxY/2; player2-y=maxY/2;/* 画框函数,player为画框位置,who为哪一个游戏者 */void Drawbar(CurrentCoor player,int who) int x,y; /* 根据游戏者所在coordinate的下标位置取出在屏幕上的位置 */ x=coordinateplayer.xplayer.y.x; y=coordinateplayer.xplayer.y.

11、y; if(who=1) setfillstyle(1,Player1Color); coordinateplayer.xplayer.y.color=Player1Color; else setfillstyle(1,Player2Color); coordinateplayer.xplayer.y.color=Player2Color; bar(x,y,x+7,y+7); coordinateplayer.xplayer.y.draw=1;/* 帮助信息,按F1调用此函数 */void HelpMassage(void) setfillstyle(1,WHITE); bar(150,160

12、,500,340); setcolor(LIGHTRED); rectangle(152,162,498,338); setcolor(BLACK); rectangle(154,164,496,180); rectangle(154,182,496,336); setcolor(GREEN); outtextxy(280,170,Trone V0.1); setcolor(BLACK); outtextxy(160,190,Player1 control key:); outtextxy(160,200,Player2 control key:); outtextxy(160,220,Hel

13、p: Level: Exit:); outtextxy(160,230,Player color:); outtextxy(160,250,Author:); outtextxy(160,260,E_mail:); outtextxy(160,270,OICQ :); setcolor(RED); outtextxy(330,190,r,f,d,g); outtextxy(330,200,up,down,left,right); outtextxy(160,220, F1 F2 Esc); outtextxy(160,230, F3/F4); outtextxy(220,250,GaoWenf

14、eng); outtextxy(220,260,*); outtextxy(220,270,182824199); setcolor(BLUE); outtextxy(175,290,If you have any question or modify these); outtextxy(160,300,code,Please send email to me. Thank you); outtextxy(160,310,play this game!); setcolor(BLACK); outtextxy(410,320,02/04/2004);/* 获取按键,如果低八位非0则为ASCII

15、码,如为0则为控制键 */int GetKey(void) int key; key=bioskey(0); if(key Timeout) /* 如果超过游戏间隔则开始画 */ front_time=current_time; if(player1fx=RIGHT1 | player1fx=LEFT1) /* 如果现在方向为左或右则只有按下上下键才改变方向,反之相同 */ if(currentfx1=UP1 | currentfx1=DOWN1) if(currentfx1=UP1) player1.y-=1; else player1.y+=1; player1fx=currentfx1;

16、 else if(player1fx=RIGHT1) player1.x+=1; else player1.x-=1; else if(player1fx=UP1 | player1fx=DOWN1) if(currentfx1=RIGHT1 | currentfx1=LEFT1) if(currentfx1=RIGHT1) player1.x+=1; else player1.x-=1; player1fx=currentfx1; else if(player1fx=UP1) player1.y-=1; else player1.y+=1; if(player2fx=RIGHT | play

17、er2fx=LEFT) if(currentfx2=UP | currentfx2=DOWN) if(currentfx2=UP) player2.y-=1; else player2.y+=1; player2fx=currentfx2; else if(player2fx=RIGHT) player2.x+=1; else player2.x-=1; else if(player2fx=UP | player2fx=DOWN) if(currentfx2=RIGHT | currentfx2=LEFT) if(currentfx2=RIGHT) player2.x+=1; else pla

18、yer2.x-=1; player2fx=currentfx2; else if(player2fx=UP) player2.y-=1; else player2.y+=1; if(player1.x=maxX |player1.y=maxY | coordinateplayer1.xplayer1.y.draw=1) /* 判断是否到边界或是已走路,如果是则退出,否则画框 */ die1=1; die=1; else Drawbar(player1,1); if(player2.x=maxX | player2.y=maxY | coordinateplayer2.xplayer2.y.dr

19、aw=1) die2=1, die=2; else Drawbar(player2,2); if(die1 & die2) die=3; return die;/* 设定游戏等级函数 */void Set_Level(void) int key,pass=0,i=0; clock_t front_time,current_time; front_time=clock(); setfillstyle(1,WHITE); bar(180,150,460,300); setcolor(LIGHTRED); rectangle(182,152,458,298); setcolor(BLACK); re

20、ctangle(184,154,456,174); rectangle(184,176,456,296); setcolor(RED); outtextxy(260,160,Level Setting); setcolor(BLACK); outtextxy(190,200,Here have three level:); outtextxy(190,260,Please input a number0,1,2:); setcolor(BLUE); outtextxy(200,220,0: fast); outtextxy(200,230,1: normal); outtextxy(200,2

21、40,2: slow); while(pass=0) if(bioskey(1) key=GetKey(); if(key=0 | key=1 | key=2) /* 通过设置全局变量Timeout来确定游戏速度 */ pass=1; if(key=0) Timeout=0; else if(key=1) Timeout=1; else Timeout=2; else setcolor(LIGHTRED); outtextxy(190,280,Please input 0,1,2!); else current_time=clock(); if(current_time-front_time6

22、) /* 光标闪动效果,不知谁有更有效的方法? */ front_time=current_time; i=(i+1)%2; if(i=0) setcolor(BLACK); else setcolor(WHITE); outtextxy(420,260,_); /* 设置游戏者颜色,其实就是设置全局变量Player2Color与Player1Color,根据who来判断哪一个游戏者 */void Set_Color(int who) int pass=0,color,key,i=0; int x,y,count; clock_t front_time,current_time; setfil

23、lstyle(1,WHITE); bar(150,160,500,340); setcolor(LIGHTRED); rectangle(152,162,498,338); setcolor(BLACK); rectangle(154,164,496,180); rectangle(154,182,496,336); setcolor(LIGHTRED); if(who=1) outtextxy(245,170,Player1); else if(who=2) outtextxy(245,170,Player2); setcolor(GREEN); outtextxy(245,170, Color Setting); setcolor(BLACK); outtextxy(160,190,You can select underside color:); outtextxy(160,300,Please input color number1-f:); for(count=1;count16;count+) x=189+count*16; y=220; setfillstyle(1,count); bar(x,y,x+14,y+40); rectangle(x,y,x+14,y+40); outtextxy(

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1