刚到一家新公司,老板要让我用VC写一个"探食蛇"的游戏,用在手机上的,我连听都没有听说过,他要我用三天时间,各位兄弟救命啊!

wolf416 2001-06-07 06:04:00
...全文
186 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
renyukun 2001-06-07
  • 打赏
  • 举报
回复
你老板太狠了,什么时候想扁它,喊我一声!!!
EastDawn 2001-06-07
  • 打赏
  • 举报
回复
手机上没有模拟器吗?哪家手机厂,这么弱?
iZap 2001-06-07
  • 打赏
  • 举报
回复
是否进公司时把自己吹得太牛太浮了了????这样的话阿,倒是活该,哈哈....
zshuc 2001-06-07
  • 打赏
  • 举报
回复
我不太清楚!不好意思 !
zshuc 2001-06-07
  • 打赏
  • 举报
回复
真是个倒霉的家伙啊!
netmuse 2001-06-07
  • 打赏
  • 举报
回复
这么夸张!
SmartHeart 2001-06-07
  • 打赏
  • 举报
回复
问题是用在手机上啊.
如果在PC上没有什么难的
NowCan 2001-06-07
  • 打赏
  • 举报
回复
TC程序,电脑演示。

#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<dos.h>
#include<ctype.h>
#include<bios.h>
#define NULL 0
#define len sizeof(struct liner)

struct liner
{int x;
int y;
struct liner *next;
};
int n;

struct liner *creat(int m)
{ int i;
struct liner *head,*p1,*p2;
n=0;
p1=(struct liner *)malloc(len);
p1->x=30;p1->y=20;
head=NULL;
p2=p1;
for(i=0;i<=m-1;i++)
{ n++;
if (n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct liner *)malloc(len);
p1->x=30;p1->y=20+2-i;
}
p2->next=head;
return(head);
}

struct liner *locate(struct liner *head)
{
return(head->next);
}

void *picture(int a)
{ void *p;
int size;
if(a) {setfillstyle(1,4);bar(0,0,10,10);rectangle(1,1,9,9);rectangle(4,4,6,6);}
size=imagesize(0,0,10,10);
p=malloc(size);
getimage(0,0,10,10,p);
cleardevice();
return(p);
}

void draw(int x,int y,void *p)
{putimage(x*10,y*10,p,COPY_PUT);}

struct liner *insert(struct liner *head,int x,int y)
{
struct liner *p;
p=(struct liner *)malloc(len);
p->x=x;p->y=y;
p->next=head->next;
head->next=p;
head=p;
n++;
return(head);
}

int search(int x,int y,struct liner *head)
{ int k;
struct liner *p;
p=head;
for(k=0;k<=n-1;k++)
{if ((p->x==x) && (p->y==y)) return(1);
else p=locate(p);
}
return(0);
}
void main()
{int gm=2,gd=VGA;
int s1,m1;
int time=100,mark=0;
int key;
void *p1,*p2;
int i,j;
int x,y;
int flag=1,bl=0,musicflag=0;
unsigned s2;
struct liner *head,*p;
struct time t[1];
gettime(t);
s1=t[0].ti_sec;
m1=t[0].ti_min;
s2=s1*m1;
srand(s2);
clrscr();
gotoxy(34,10);
printf("JieLong");
gotoxy(27,11);
printf("CopyRight 1995 by ljh");
gotoxy(29,17);
printf("MUISC=ON|OFF[y/n]n");
gotoxy(46,17);
if(tolower(getchar())=='y') musicflag=1; else musicflag=0;
initgraph(&gd,&gm,"");
p2=picture(0);
p1=picture(1);
head=creat(3);
p=head;
setfillstyle(1,1);
bar(0,0,630,349);
rectangle(0,0,639,349);
for(i=0;i<=2;i++)
{ draw(p->x,p->y,p1);
p=locate(p);
}
x=rand()%60+1;
y=rand()%15+1;
draw(x,y,p1);
//lo=0;
//hi=72;
p=head;
while(flag)
{
if(musicflag)
{
sound(400);
delay(10);
nosound();
}
/* if(kbhit())
{key=bioskey(0);
if(kbhit()) getch();
lo=key & 0x00ff;
if(lo==0) hi=(key & 0xff00)>>8;
} */

i=p->x;
j=p->y;
p=locate(p);
draw(p->x,p->y,p2);
gotoxy(10,24);printf("Target : %2d ,%2d Score",y,x);
gotoxy(10,25);printf("Current: %2d ,%2d",j,i);
{/*switch(hi)
{ case 72:if(h!=80) {h=72;j--;} else {hi=80;j++;} break;
case 80:if(h!=72) {h=80;j++;} else {hi=72;j--;} break;
case 75:if(h!=77) {h=75;i--;} else {hi=77;i++;} break;
case 77:if(h!=75) {h=77;i++;} else {hi=75;i--;} break; }*/

if((i>x)&&(j>y)&&!search(i,j-1,p))j--;
else if((i>x)&&(j>y)&&!search(i-1,j,p))i--;
else if((i>x)&&(j>y)&&!search(i+1,j,p))i++;
else if((i>x)&&(j>y)&&!search(i,j+1,p))j++;
else if((i<x)&&search(i+1,j,p))j++;
else if((i>x)&&search(i-1,j,p))j++;
else if((j<y)&&search(i,j+1,p))i++;
else if((j>y)&&search(i,j-1,p))i++;
else if(j==y){
if(i<x)i++;
if(i>x)i--;}
else{
if(j<y)j++;
if(j>y)j--;}


if((x==i)&&(y==j))
{
if(musicflag)
{
sound(1000);
delay(70);
nosound();
}
p=insert(p,x,y);
x=((unsigned int)rand())%50+1;y=((unsigned int)rand())%25+1;
draw(x,y,p1);
gotoxy(40,25);
printf("%d",++mark*100);
}
else
{if ((i<1)||(i>63)||(j<1)||(j>34)||search(i,j,p))
{if(bl==0) flag=0;}
else
{
p->x=i;p->y=j;
draw(i,j,p1);}
}
delay(time--);
if (time<=20) time=30;
bl=0;
}
}
if(musicflag)
{
sound(1000);
delay(80);
sound(700);
delay(50);
sound(1090);
delay(80);
nosound();
}
closegraph();
gotoxy(30,10);
printf("GAME OVER");
getch();
}



EastDawn 2001-06-07
  • 打赏
  • 举报
回复
游戏很简单,你可顺便练练手,不过如图方便,用Google搜一下,应该会有很多
efoxxx 2001-06-07
  • 打赏
  • 举报
回复
在linux下有此游戏,网上应该可以找到源代码!

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧