甲壳虫变速箱多少钱:c语言可以编什么样的游戏
只要你有能力,有想法,什么游戏都可以
连操作系统都可以
像大名顶顶的LINUX操作系统就是用C语言编的
给个c语言编的赛车游戏给你
#include "graphics.h"
#include "conio.h"
#include "stdio.h"
enum shu {daolu, kongdi, qiche, qita};
enum setvalue {veryeasy, easy, normal, hard, veryhard};
enum setvalue set_sudu=veryeasy,set_nandu=veryeasy;
main()
{int gdriver, gmode;
void hua_lu(); void hua_che(); void sheng_lu(); void chushi_lu();
void hua_biankuang(); int ceshi_key(); void chongxin_bisai();
void chuli_che(); int ceshi_chugui();
enum shu matrix[128][96];
int chezhong[2]={64,86};
char keyvalue='a';
int kyh,shenming=100;
long i=0;
/*提示信息*/
kkkk:
printf("\n\n\t\t\tNAME: MiniCar\n\t\t\tVERSION: 1.4\n\t\t\tCREATOR: kanker\n\n");
printf("NARRATE: This function is a race game, be use 'j,k,l' and 'i' to control the car. press 'e' means exiting the game, press 'r' means restart the race\n");
printf("\nTHE GAME SET: Please input the value of speed and dificulty (0-4),");
printf("for example input '0,0' means speed=0 and dificulty=0,and so on.\n");
printf("\n\n\tGOOD LUCKY!\n\n\tplease input===>");
scanf("%d,%d",&set_sudu,&set_nandu);
if (set_sudu<5 &&set_nandu<5)
{ printf ("\nGOOD! SET OK!\n please waiting...");sleep(1.5);}
else
{ printf("\n\nINPUT ERROR,REINPUT\n"); goto kkkk; }
gdriver =9; gmode =2;
initgraph(&gdriver,&gmode,"d:\\turboc2");
chushi_lu(matrix,set_nandu); /*初始化道路*/
for (;kyh!=10;i++)
{ hua_biankuang();
sheng_lu(matrix,set_sudu);
hua_lu(matrix);
hua_che(chezhong);
if ( kbhit()==0 ) { keyvalue='c'; }
else { keyvalue=getche();}
kyh=ceshi_key(keyvalue); /*处理键盘输入*/
if (kyh==6) { nosound(); goto kkkk;shenming=100;i=0;}
chuli_che(chezhong,kyh);
shenming=shenming-ceshi_chugui(chezhong,matrix);
sleep(0.75); if(i>10) { sound(50+((int)(i/5))%100); } /*赛车声音*/
if (shenming<1)
{setcolor(0); outtextxy(280,25,"GAME START");
setcolor(15); outtextxy(280,175,"GAME OVER"); kyh=10;
}
}
nosound();
getch();
closegraph();
printf("\n\n Your score is:%ld\n\nTHANKS,BYEBYE!",i*(set_nandu+set_sudu+1));
sleep(5);
return 0;
}
void chushi_lu(enum shu aa[128][96],enum set nandu)
{int i,j;
for (i=20;i<=108;i++)
{ for (j=10;j<=86;j++)
{ if (i<80-nandu && i>50+nandu) { aa[i][j]=daolu; }
else aa[i][j]=qita;
}
}
}
void sheng_lu(enum shu aa[128][96],enum set sudu)
{int i=0,j=0,k,kang;
kang=(int) rand() % 10;
for (i=20;i<=108;i++)
{ for (j=86;j>10+sudu;j--)
{aa[i][j]=aa[i][j-1-sudu];
}
}
if (kang<5 && aa[20][10]==qita)
{for (k=0;k<=sudu;k++)
{ for (i=20;i<108;i++)
{ aa[i][10+k]=aa[i+1][10+k]; }
aa[108][10+k]=qita;
}
}
if (kang>=5 && aa[108][10]==qita)
{for (k=0;k<=sudu;k++)
{ for (i=108;i>20;i--)
{ aa[i][10+k]=aa[i-1][10+k]; }
aa[20][10+k]=qita;
}
}
}
void hua_lu(enum shu aa[128][96])
{int i,j;
for (i=20;i<=108;i++)
{ for (j=10;j<=86;j++)
{ if (aa[i][j] != daolu)
{ putpixel(i*5,j*5,7); }
else
{ putpixel(i*5,j*5,0); }
}
}
}
void hua_che(int zhongxin[2]) /* the car's profile */
{int i,j,x,y;
x=zhongxin[0]; y=zhongxin[1];
for (i=0;i<5;i++)
{ for (j=0;j<8;j++)
{
{ if (i!=0 && i!=4) putpixel ((x-4+i*2)*5,(y-j*2)*5,7);
else
{if (j!=7 && j!=3 && j!=4)
putpixel ((x-4+i*2)*5,(y-j*2)*5,7);
}
}
}
}
}
void hua_biankuang ()
{enum shu bb[128][96];
setcolor(15);
rectangle(10,10,630,470);
rectangle(20*5,10*5,108*5,86*5);
outtextxy(280,25,"GAME START");
outtextxy(30,100,"SPEED:");
if (set_sudu+set_nandu<2) outtextxy(35,120,"VERYEASY");
if (set_sudu+set_nandu<4) outtextxy(35,120,"EASY");
if (set_sudu+set_nandu<6) outtextxy(35,120,"NORMAL");
if (set_sudu+set_nandu<8) outtextxy(35,120,"HARD");
if (set_sudu+set_nandu>=8) outtextxy(35,120,"VERYHARD");
/*can add some other text and line*/
}
int ceshi_key(char a)
{ int i=0;
if (a=='j') i=1;
if (a=='k') i=2;
if (a=='l') i=3;
if (a=='i') i=4;
if (a=='r') i=6;
if (a=='e') i=10;
return i;
}
void chongxin_bisai()
{
}
void chuli_che(int zhongxin[2],int k)
{if (k==0 && zhongxin[1]<=84) zhongxin[1]=zhongxin[1];
if (k==1 && zhongxin[0]>=26) zhongxin[0]=zhongxin[0]-2;
if (k==3 && zhongxin[0]<=102) zhongxin[0]=zhongxin[0]+2;
if (k==2 && zhongxin[1]<=84) zhongxin[1]=zhongxin[1]+2;
if (k==4 && zhongxin[1]>=18) zhongxin[1]=zhongxin[1]-2;
if (k==6) chongxin_bisai();
}
int ceshi_chugui(int zhongxin[2],enum shu aa[128][96])
{int i,j,ming=0;
for (i=0;i<5;i++)
{for (j=0;j<8;j++)
{if (aa[zhongxin[0]-4+2*i][zhongxin[1]-j*2]!=daolu) ming++;
}
}
return ming;
}
比较 简单的 就是 扫雷
C语言编游戏,那绝对是高手,相当于专家级人物
难度有点可怕
游戏算什么,windows都是C编的
简单的说~你看过的游戏~C也可以做到!
简单吧?!
只要你够牛~~~想写什么也许也可以!