閺€鎯版 (0) +1 鐠э拷 (0) +1 闊拷 (0) +1
閺€鎯版閹存劕濮�閺屻儳婀呴弨鎯版>>

正在阅读:利用C++实现的贪吃蛇游戏利用C++实现的贪吃蛇游戏

2004-10-08 14:53 出处:CSDN 作者:oosky2004 责任编辑:linjixiong


  if((key=bioskey(1))!=0)
  {
  switch(key)
  {
  case ESC:  return false;
  case UP:
  if(CurrentDirection!=down)
  CurrentDirection=up;
  ClearKeyBuf();
  break;
  case DOWN:
  if(CurrentDirection!=up)
  CurrentDirection=down;
  ClearKeyBuf();
  break;
  case LEFT:
  if(CurrentDirection!=right)
  CurrentDirection=left;
  ClearKeyBuf();
  break;
  case RIGHT:
  if(CurrentDirection!=left)
  CurrentDirection=right;
  ClearKeyBuf();
  break;
  case PAGEUP:speed=speed-100;
  if(speed<100)
  speed=100;
  ClearKeyBuf();
  break;
  case PAGEDOWN:speed=speed+100;
  if(speed>500)
  speed=500;
  ClearKeyBuf();
  break;
  default :break;
  }
  }
  int headx=snake.tail->x;
  int heady=snake.tail->y;
  switch(CurrentDirection)
  {
  case up: heady-=BlockHeight;break;
  case down: heady+=BlockHeight;break;
  case left: headx-=BlockWidth;break;
  case right: headx+=BlockWidth;break;
  }
  if(Hit(headx,heady))    //whether the snake hit the wall or itself
  return GameOver();

察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
閹靛婧€鐠佸潡妫�閸ョ偛鍩屾い鍫曞劥