求一个linux下的c语言或c++程序。能运行的。小游戏之类的都行,一定要linux环境下的

求一个linux下的c语言或c++程序。能运行的。小游戏之类的都行,一定要linux环境下的,第1张

给个经典的不能再经典的程序

#include<stdio.h>

int main()

{

printf("hello world!\n")

return 1

}

在终端下用vi编辑该文件(vi hello.c 或vi hello.cpp),或者图形界面下用gedit编辑(gedit hello.c或 gedit hello.c)

然后在终端下cd到源文件所在目录,运行gcc hello.c -o hell 或者 g++ hello.cpp -o hello

最后./hello就可以运行了

注意:gcc要求程序返回值必须是int类型

本原代码是基于C语言的原程序。是经典中的小游戏。-primitive code is based on the C language of the original procedure. Classic is a small game.

一个小游戏,用C语言编写的:俄罗斯方块.C原码及应用程序都在里面哦 -a small game using the C language : Russian cubes. The original C code and application procedures inside oh

十全十美游戏原程序,c语言-perfect game program, language c

上数据结构时,自己用C语言做的小游戏,做得不好,请大家原谅。-structure on the data they used C language to the small games, done well, please forgive me.

大家都耍过文曲星中的猜数字的游戏吧 !! 最近我在学习C语言。写了个菜鸟的C语言的猜数字的游戏程序的原代码-rings off the viewing of the game! ! I recently learning C language. Wrote a birdie C language viewing of the games original code procedures

  这是我在大学二年级学习C语言课程时,作为“练笔”而编写的一个小程序(当时在我眼里可却是一个大程序!)其主要特点有:1、正真做到了全中文界面(不需要UCDOS *** 作系支持) 2、大量的图形特技(如图像的显隐技术、图像穿插技术、多任务仿真技术等) 3、纯C语言打造(不含任何C++知识) 4、实现了街机“俄罗斯方块”绝大部分功能(如动画、声音、速度变化) 5、用户可根据自据的习惯自由地调整“游戏 *** 作键” 6、方法独特,全部语句和技术都是我本人原创,没有参考过任何相关代码 7、防“跟踪调试”技术,防“版权篡改”技术 8、……-

  这个程序是模仿Windows中的扫雷小游戏制作的,该程序只是实现了扫雷游戏的主体部分,诸如计分、升级部分都没有做。这个程序可以作为初学者学习C语言绘图和游戏的实例。 该程序在Turbo C2.0 下编译通过 由于扫雷游戏是用鼠标 *** 作的,而Turbo C中提供的鼠标驱动程序在Windows xp下不可用,所以我随源程序提供了一个鼠标驱动的头文件,须将将该头文件复制到Turbo C2.0 的安装目录下的“include”文件夹中方可编译或运行,也可自行修改原文件使之包含该投文件。 注:该鼠标驱动程序是我在网上找到的,其出处我已无法考证,如果侵犯了作者的权利还请作者与我联系。 由于在我的电脑上Turbo C图形环境下显示数字会有问题(估计是系统问题),所以程序中雷周围的数字1-8我用a-h代替,看不顺眼的可以自己修改原程序。-

c语言 猜拳游戏的原代码就是这个 已经测试成功了呀-language of the original game is the code has been tested successfully ah

俄罗斯方块对战版c语言原代码。希望大家能喜欢。是比较简单的一个代码,游戏开发高手请指教。-Tetris screen version of the original C language code. Hope you will like. It is a relatively simple code, game development experts please advise.

用linuX 下的C语言 运用CURSES编写的俄罗斯方块游戏,很好,这个是本人原创,值得参考-linuX use the C language CURSES prepared by the Russian box game, well, this is the original, worthy of reference

#include<bits/stdc++.h>#include<stdlib.h>#include<dos.h>#define LEFT 0x4b00#define RIGHT 0x4d00#define DOWN 0x5000#define UP 0x4800#define ESC 0x011bint i,keyint score=0int gamespeed=32000struct Food /*食物的结构体*/{int x/*食物的横坐标*/int y/*食物的纵坐标*/int yes/*食物是否出现的变量*/}foodstruct Snack /*蛇的结构体*/{int x[N]int y[N]int node/*蛇的节数*/int direction/*蛇的方向*/int life/*蛇的生命,0活着,1死亡*/}snakevoid Init(void)/*图形驱动*/void Close(void)/*关闭游戏函数*/void DrawK(void)/*画图函数*/void GameOver(void)/*输出失败函数*/void GamePlay()/*游戏控制函数 主要程序*/void PrScore(void)/*分数输出函数*/DELAY(char ch)/*调节游戏速度*/{if(ch=='3'){delay(gamespeed)/*delay是延迟函数*/}else if(ch=='2'){delay(gamespeed)}}Menu()/*游戏开始菜单*/{char chprintf("Please choose the gamespeed:\n")printf("1-Fast 2-Normal 3-Slow\n")printf("\nPlease Press The numbers..\n")do{ch=getch()}while(ch!='1'&&ch!='2'&&ch!='3')clrscr()return(ch)}/*主函数*/void main(void){int chch=Menu()Init()DrawK()GamePlay(ch)Close()}void Init(void){int gd=DETECT,gminitgraph(&gd,&gm,"c:\\tc")cleardevice()}void DrawK(void){setcolor(11)setlinestyle(SOLID_LINE,0,THICK_WIDTH)for(i=50i<=600i+=10){rectangle(i,40,i+10,49)/*画出上边框*/rectangle(i,451,i+10,460)/*画出下边框*/}for(i=40i<=450i+=10){rectangle(50,i,59,i+10)/*画出左边框*/rectangle(601,i,610,i+10)/*画出右边框*/}}void GamePlay(char ch){randomize()/*随机数发生器*/food.yes=1/*1代表要出现食物,0表示以存在食物*/snake.life=0snake.direction=1snake.x[0]=100snake.y[0]=100snake.x[1]=110snake.y[1]=100snake.node=2PrScore()while(1) /*可以重复游戏*/{while(!kbhit()) /*在没有按键的情况下蛇自己移动*/{if(food.yes==1) /*需要食物*/{food.x=rand()%400+60food.y=rand()%350+60/*使用rand函数随机产生食物坐标*/while(food.x%10!=0)food.x++while(food.y%10!=0)food.y++/*判断食物是否出现在整格里*/food.yes=0/*现在有食物了*/}if(food.yes==0) /*有食物了就要显示出来*/{setcolor(GREEN)rectangle(food.x,food.y,food.x+10,food.y-10)}for(i=snake.node-1i>0i--) /*贪吃蛇的移动算法*/{snake.x[i]=snake.x[i-1]snake.y[i]=snake.y[i-1]/*贪吃蛇的身体移动算法*/}switch(snake.direction) /*贪吃蛇的头部移动算法,以此来控制移动*/{case 1:snake.x[0]+=10breakcase 2:snake.x[0]-=10breakcase 3:snake.y[0]-=10breakcase 4:snake.y[0]+=10break}for(i=3i<snake.nodei++) /*判断是否头部与身体相撞*/{if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0]){GameOver()snake.life=1break}}/*下面是判断是否撞到墙壁*/if(snake.x[0]<55||snake.x[0]>595||snake.y[0]<55||snake.y[0]>455){GameOver()snake.life=1}if(snake.life==1) /*如果死亡就退出循环*/breakif(snake.x[0]==food.x&&snake.y[0]==food.y) /*判断蛇是否吃到食物*/{setcolor(0)rectangle(food.x,food.y,food.x+10,food.y-10)/*吃的食物后用黑色将食物擦去*/snake.x[snake.node]=-20snake.y[snake.node]=-20/*现把增加的一节放到看不到的地方去*/snake.node++food.yes=1score+=10PrScore()}setcolor(4)/*每次移动后将后面的身体擦去*/for(i=0i<snake.nodei++)rectangle(snake.x[i],snake.y[i],snake.x[i]+10,snake.y[i]-10)delay(gamespeed)DELAY(ch)setcolor(0)rectangle(snake.x[snake.node-1],snake.y[snake.node-1],snake.x[snake.node-1]+10,snake.y[snake.node-1]-10)}if(snake.life==1)breakkey=bioskey(0)/*接受按键*/if(key==ESC)breakelseif(key==UP&&snake.direction!=4)/*判断是否改变方向*/snake.direction=3elseif(key==RIGHT&&snake.direction!=2)snake.direction=1elseif(key==LEFT&&snake.direction!=1)snake.direction=2elseif(key==DOWN&&snake.direction!=3)snake.direction=4}}void GameOver(void){cleardevice()setcolor(RED)settextstyle(0,0,4)outtextxy(200,200,"GAME OVER")getch()}void PrScore(void){char str[10]setfillstyle(SOLID_FILL,YELLOW)bar(50,15,220,35)setcolor(6)settextstyle(0,0,2)sprintf(str,"scord:%d",score)outtextxy(55,20,str)}void Close(void){getch()closegraph()}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8477962.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-16
下一篇2023-04-16

发表评论

登录后才能评论

评论列表(0条)

    保存