如何用C#制作c 贪吃蛇游戏设计报告界面

君,已阅读到文档的结尾了呢~~
用C#做的贪吃蛇游戏的设计论文设计论文,小游戏的,贪吃蛇,游戏的,贪食蛇,贪吃蛇吧
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
用C#做的贪吃蛇游戏的设计论文
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口下次自动登录
现在的位置:
& 综合 & 正文
用C#实现贪吃蛇游戏
先说了,如果不会GDI+,类的定义这些基础东西的,请先搜索相关贴子学习。
都写在一个窗体上,应该有一个分层思想(界面还界面,数据处理还数据处理),如果还要网上对战的话,搞个三层吧(界面层,数据处理或逻辑层,
public enum SnakeDirection
Up, Down, Left, Right
public enum SnakeState
Normal = 50, Fast = 20, Low = 100
public enum FoodType
Normal, Fast, Slow, Long, Short, LENGTH
public class Snake
public Snake(Point headLocation, int snakeLength, SnakeDirection direction)
bodiesLocation = new List&Point&();
bodiesLocation.Add(headLocation);
for (int i = 0; i & snakeL i++)
bodiesLocation.Add(new Point(-1, -1));
this.direction =
this.speed = (int)SnakeState.N
/// &summary&
public void Run()
for (int i = bodiesLocation.Count - 1; i &= 1; i--)
bodiesLocation[i] = bodiesLocation[i - 1];
Point head = bodiesLocation[0];
switch (direction)
case SnakeDirection.Up:
head = new Point(head.X, head.Y - 1);
case SnakeDirection.Down:
head = new Point(head.X, head.Y + 1);
case SnakeDirection.Left:
head = new Point(head.X - 1, head.Y);
case SnakeDirection.Right:
head = new Point(head.X + 1, head.Y);
bodiesLocation[0] = //是Struct,是值类型,所以要赋值过来
/// &summary&
public SnakeDirection Direction
get { return }
set { direction = value; }
/// &summary&
public SnakeState State
get { return }
state = value;
speed = (int) //
/// &summary&
public Point HeadLocation
get { return bodiesLocation[0]; }
/// &summary&
public List&Point& BodiesLocation
get { return bodiesL }
/// &summary&
public int Speed
get { return }
set { speed = value; }
/// &summary&
private SnakeDirection
/// &summary&
private SnakeState
/// &summary&
private List&Point& bodiesL
/// &summary&
private int speed = (int)SnakeState.N
public class Food
&&&&推荐文章:
【上篇】【下篇】新手刚学图形界面 用一个窗体和一些Button做了个简易贪吃蛇_c#吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:98,063贴子:
新手刚学图形界面 用一个窗体和一些Button做了个简易贪吃蛇收藏
心血来潮,捣鼓了一下午,还有好多功能没有完善,比如不能撞到自己的身体,刷新新方块还没有判断位置,不能保证不在蛇的身体上刷新 有空再弄,窗体上我用循环遍布了400个20X20的Button然后用数组记录经过的Point,然后控制Button的Visible,然后asdw控制方向,暂时还没有想到如何判断撞到自己身体即输,求大大指点一二
c#培训选择达内的理由1,企业级开发环境2,项目实战教学3,c#课程可选4,金牌讲师授课5,周末/业余班任选.c#培训首选达内--美国上市公司!
暂时只能吃方块加长身体,头碰到窗体边框即输```
Button每移动一步就是走20的位置,窗体我刚好拖动到400X400,所以效果跟网格区别不大
判断头部是否与身体任一方块重合即可
为什么不考虑绘图呢?很简单的。
400个控件。。。为什么不在需要的时候再动态生成呢?
吓尿。。检测碰撞只需要在每次行进之后判断,遍历所有蛇身point,是否跟蛇头的point相同
一个下午就弄出贪吃蛇,尼玛我弄的时候花了2天不得不佩服啊
c#千锋VR培训0元入学,「高薪」就业!「预约申请2周免费试学」.火爆预约中!千锋VR培训,招生限大专以上学历,年龄30岁以下,符合条件即可报名,入学即签订就业协议!
刚接触图形界面几天,献丑了,只能用这种很笨的方法...
能不能教我我不会,明天要教了!
那得多少个button啊。。。。可以用一个button数组来保存每个button,然后没走一格都遍历一次,要是位置相同就算输呗。在移动之前遍历。
已经比我强了 我整想做呢
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或利用C++实现的贪吃蛇游戏
下面,图老师小编带您去了解一下利用C++实现的贪吃蛇游戏,生活就是不断的发现新事物,get新技能~
在tc 3.0下调试通过,因为tc 3.0不支持bool 类型,所以程序中自定义了个枚举类型变量bool  假如在vc或者bc中运行,可以把这个bool类型注释掉.  贪吃蛇的核心算法时如何实现移动和吃掉食物.  没有碰到食物的时候,把当前运动方向上的下个节点入队,并以蛇节点的颜色重绘这个节点.  然后把头指针所指的节点出队,并以游戏框架内部背景色重绘出队的节点,这样就可以达到移动的效果.  而在吃到食物的时候,则只需把食物入队即可.    // greedsnake.cpp  #include bios.h  #include conio.h  #include dos.h  #include graphics.h  #include stdlib.h  #include time.h  #include "conf.h"  typedef strUCt node  {  int x,y;  struct node *  }N  typedef struct  {  Node *head,*    }S  typedef struct&&&&&&&&&&&&&&&&&&&   {  int left,top,right,  }F  typedef enum&&&&&&&&&&&&&&&&&&& //四个方向  {  up,down,left,right  }D  typedef enum  {  false,true  }  void InitGraphMode();&&&&&&&&&&&&&&&&&&&& //初始化图形驱动  void CloseGraphMode();&&&&&&&&&&&&&&&   void Foot(int,int);&&&&&&&&&&&&&&&&&&&&&&&&&&&   void Head(int,int);  void CreateFrame();&&&&&&&&&&&&&&&&&&& //完成整个游戏框架的绘制&&&   void CreateSnake();&&&&&&&&&&&&&&&&&&& //创建一条两个节点的蛇,蛇的每一节是队列中的一个节点  bool PlayGame();&&&&&&&&&&&&&&&&&&&&&&& //游戏的主体函数,  int Hit(int,int);&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //判定是否越界,或者撞到自身,两个参数分别是新的头接点的x,y坐标  bool GameOver();&&&&&&&&&&&&&&&&&&&&&&& //绘制游戏结束时弹出的对话框&&&&&&&&&&&&&&&&&&&&&&   void Enqueue(Node);&&&&&&&&&&&&&&&&&&& //入队函数    
  Node Dequeue();&&&&&&&&&&&&&&&&&&&&&&& //出队函数  void ClearKeyBuf();&&&&&&&&&&&&&&&&&&&&&& //清除键盘缓冲,此函数可以消除不停的按无效键的影响  S  F  void main()  {  InitGraphMode();  do  {  CreateFrame();  }while(PlayGame());  CloseGraphMode();  }  void InitGraphMode()  {  int gdriver=DETECT,  initgraph(&gdriver,&gmode,"../bgi/");  cleardevice();  }  void CloseGraphMode()  {  cleardevice();  closegraph();  }  void CreateFrame()  {  setbkcolor(CYAN);&&&&&&&&&&&&&&&&&&&   //下面的四行代码用于计算主框架的左上角和右下角的坐标  frame.left=(getmaxx()+1-BlockWidth*RowOfFrame)/2;   frame.top=(getmaxy()+1-BlockHeight*ColumnOfFrame)/2;  frame.right=frame.left+BlockWidth*RowOfF  frame.bottom=frame.top+BlockHeight*ColumnOfF  Head(frame.left+100,frame.top-20);  setfillstyle(SOLID_FILL,LIGHTGRAY);  bar(frame.left,frame.top,frame.right,frame.bottom);  setlinestyle(SOLID_LINE,1,1);  setcolor(DARKGRAY);  line(frame.left,frame.top,frame.right,frame.top);  line(frame.left,frame.top,frame.left,frame.bottom);  setlinestyle(SOLID_LINE,1,1);  setcolor(WHITE);  line(frame.left,frame.bottom,frame.right,frame.bottom);  line(frame.right,frame.top,frame.right,frame.bottom);  setlinestyle(DOTTED_LINE,1,1);  setcolor(BLUE);  for(int row=1;rowRowOfFrow++)  line(frame.left+row*BlockWidth,frame.top,frame.left+row*BlockWidth,frame.bottom);  for(int column=1;columnColumnOfFcolumn++)  line(frame.left,frame.top+column*BlockHeight,frame.right,frame.top+column*BlockHeight);  Foot(frame.left,frame.bottom+20);  }    void CreateSnake()  {  Node *node1=new N  Node *node2=new N  node1-x=frame.left+BlockW  node1-y=frame.  node1-next=NULL;  snake.tail=node1;  node2-x=frame.  node2-y=frame.  node2-next=snake.  snake.head=node2;  snake.length=2;  setfillstyle(SOLID_FILL,BLUE);  bar(snake.head-x+1,snake.head-y+1,snake.head-x+BlockWidth-1,snake.head-y+BlockHeight-1);  bar(snake.tail-x+1,snake.tail-y+1,snake.tail-x+BlockWidth-1,snake.tail-y+BlockHeight-1);  }  bool PlayGame()  {  int speed=300,  Direction CurrentDirection=  Node randomN  Node newNode,outN  bool neednode=  bool overlap=  int randx,  CreateSnake();  while(true)  {  if(neednode==true)  {  randomize();    
  do  {  randx=frame.left+rand()%RowOfFrame*BlockW  randy=frame.top+rand()%ColumnOfFrame*BlockH&   for(Node *p=snake.p!=NULL;p=p-next)//hit itself  if(randx==p-x&&randy==p-y)  {overlap=}  }  while(overlap==true);  randomNode.x=  randomNode.y=  randomNode.next=NULL;  setfillstyle(SOLID_FILL,RED);  bar(randomNode.x+1,randomNode.y+1,randomNode.x+BlockWidth-1,randomNode.y+BlockHeight-1);  neednode=  }  if((key=bioskey(1))!=0)  {  switch(key)  {  case ESC:&  case UP:  if(CurrentDirection!=down)  CurrentDirection=  ClearKeyBuf();    case DOWN:  if(CurrentDirection!=up)  CurrentDirection=  ClearKeyBuf();    case LEFT:  if(CurrentDirection!=right)  CurrentDirection=  ClearKeyBuf();    case RIGHT:  if(CurrentDirection!=left)  CurrentDirection=  ClearKeyBuf();    case PAGEUP:speed=speed-100;  if(speed100)  speed=100;  ClearKeyBuf();    case PAGEDOWN:speed=speed+100;  if(speed500)  speed=500;  ClearKeyBuf();    default :  }  }  int headx=snake.tail-x;  int heady=snake.tail-y;  switch(CurrentDirection)  {  case up: heady-=BlockH  case down: heady+=BlockH  case left: headx-=BlockW  case right: headx+=BlockW  }  if(Hit(headx,heady))&&& //whether the snake hit the wall or itself  return GameOver();   更多内容请看C/C++技术专题&&网络游戏攻略&&游戏开发专题,或     else  {&&&&&& //eat  if(headx==randomNode.x&&heady==randomNode.y)  {  Enqueue(randomNode);  setfillstyle(SOLID_FILL,BLUE);  bar(randomNode.x+1,randomNode.y+1,randomNode.x-1+BlockWidth,randomNode.y-1+BlockHeight);  neednode=  }  else&&&& //no eat  {  newNode.x=  newNode.y=  newNode.next=NULL;  Enqueue(newNode);  outNode=Dequeue();  setfillstyle(SOLID_FILL,LIGHTGRAY);  bar(outNode.x+1,outNode.y+1,outNode.x+BlockWidth-1,outNode.y+BlockHeight-1);  setfillstyle(SOLID_FILL,BLUE);  bar(newNode.x+1,newNode.y+1,newNode.x-1+BlockWidth,newNode.y-1+BlockHeight);  }  }  delay(speed);  }  }  void ClearKeyBuf()  {  do  bioskey(0);  while(bioskey(1));  }  void Foot(int x,int y)  {  setcolor(BLUE);  outtextxy(x,y,"writer:[T]RealXL E-MAIL:");  }  void Head(int x,int y)  {  setcolor(RED);    
  outtextxy(x,y,"GREEDY SNAKE");  }  void Enqueue(Node inNode)  {  Node *p=new N  p-x=inNode.x;  p-y=inNode.y;  p-next=inNode.  snake.tail-next=p;  snake.tail=p;  snake.length++;  }     更多内容请看C/C++技术专题&&网络游戏攻略&&游戏开发专题,或     Node Dequeue()  {  Node *p=snake.  Node outNode=*p;  snake.head=p-  snake.length--;    return outN  }  int Hit(int x,int y)  {  if(xframe.leftx=frame.rightyframe.topy=frame.bottom)//hit the wall  return 1;  Node *p=snake.head-  for(int i=snake.length-1;i3;i--,p=p-next)//hit itself  if(x==p-x&&y==p-y)  return 1;  return 0;  }  bool GameOver()  {  int x=getmaxx()/2-50;  int y=getmaxy()/2-20;  setfillstyle(SOLID_FILL,DARKGRAY);  bar(x+3,y+3,x+103,y+43);  setfillstyle(SOLID_FILL,MAGENTA);  bar(x,y,x+100,y+40);  setlinestyle(0,3,1);  setcolor(RED);  rectangle(x,y,x+100,y+40);  outtextxy(x+20,y+10,"GAGE OVER!");    while(true)&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //按q或Q表示退出程序,按r或R表示重新开始游戏  {  c=getch();  if(c=='q'c=='Q')    else if(c=='r'c=='R')    }  }  //conf.h&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&   #ifndef _conf_h  #define _conf_h  #define RowOfFrame&&& 20&&&&&&&& //主框架的行数  #define ColumnOfFrame 20&&&&&&&& //主框架的列数  #define BlockWidth&&& 15&&&&&&& //每个蛇节点的宽度  #define BlockHeight&& 15&&&&&&& //每个蛇节点的高度  #define UP&& 18432  #define DOWN& 20480  #define LEFT& 19200  #define RIGHT& 19712  #define ESC&& 283  #define ENTER& 7181  #define PAGEUP& 18688  #define PAGEDOWN 20736  #endif
来源:/n/6614.html
热门搜索:
PS教程 萌照片转手绘
开机自动宽带连接设置方法
怎么关闭防火墙 教你简单关闭防火墙方法
电脑显示不出最近打开的文档记录怎么办
您可能会发现,经常看到在短视频有人在表演的时候说一些鼓励的话,然后就是双击666,听的您或许摸不清头脑,我就在这里为您解答一下,请给我点赞,让我解答更加有动力。
您是否熟悉我们生活的城市是怎么命名而来的呢?中国城市的命名可是有很深的文化底蕴和历史背景的,你都知道么?我从网上搜集了大量的城市名来源,让您好好的涨涨知识,您准备好了吗?
对于爱美人士来说,美白护肤是不分季节的,即使在冬季,依然需要做好皮肤护理工作。饮食调理是护肤的一项重要措施,那么冬天美白吃什么水果呢?接下来就和我一起来看看了解一下冬季美白吃什么水果好!
产妇顺产以后多久可以洗头发?有很多产妇为了防止自己受寒所以在产后不让自己洗头发,但是又特别难受,这篇文章讲述了产妇顺产以后多长时间可以洗头发,通过这篇文章了解产妇顺产以后多久可以洗头发吧。
阴阳师是现在相当火热的一款手游,最近阴阳师又有了新的更新,玩家可以通过挑战副本来获取妖刀姬樱雨刀舞皮肤。可是的很多人不知道阴阳师妖刀姬副本阵容是怎样的,下面就给大家来详细介绍吧。
阴阳师是现在很火热的一款手机游戏,这款游戏一直在更新完善,受到很多人的追捧,就在最近阴阳师又推出了小鹿男,小鹿男作为SSR式神,很多人对它还不是很了解,下面就给大家来介绍阴阳师小鹿男御魂以及阵容搭配吧。
我们在玩阴阳师完成悬赏任务的时候,都会要求玩家找到各种式神的位置,可是很多人不知道阴阳师跳跳哥哥在哪里刷、哪里多,下面就给大家来详细介绍吧,希望对大家玩游戏有所帮助。
京津冀及周边地区出现持续雾霾天气,很是让孕妈妈们担心。持续的雾霾天气对孕妇产生了很大的影响,那么雾霾天气对孕妇危害有多大?雾霾天气孕妇怎么办?下面的文章详细介绍 了雾霾天气对孕妇的危害,一起来看看吧。
我们知道宝宝刚刚出生的时候口腔里是没有牙齿的,一般孩子在四个月以后慢慢开始出牙,每个孩子的体质不一样,所以出牙的时间也是有所差异的,宝宝出牙的时候身体会出现一些症状,家长们要及时的护理好,下面一起来看看宝宝长牙的症状有哪些。
肚子上的赘肉看上去让人烦恼,尤其是对于想穿裙子的女生来说更是一件郁闷的事情。现在减肥的方法有很多,但是很多人并不知道专门瘦肚子的方法。那么,如何瘦肚子呢?下面就给大家介绍几种减肚子的方法吧。您的位置: &
C#版贪吃蛇游戏的设计与实现
优质期刊推荐

我要回帖

更多关于 贪吃蛇游戏制作 的文章

 

随机推荐