| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6157 人关注过本帖
标题:控制台清屏闪烁的厉害
取消只看楼主 加入收藏
ch307458491
Rank: 1
等 级:新手上路
帖 子:27
专家分:2
注 册:2012-10-4
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:3 
控制台清屏闪烁的厉害
我想写一个有关推箱子的游戏,现在是人移动的代码 但是 闪烁的很厉害 怎么解决呢      



 #include <stdio.h>
#include <conio.h>
#include <stdlib.h>

void printMap(int map[][16])
{
    int i=0,j=0;
    for(i=0;i<14;i++)
    {
        for(j=0;j<16;j++)
        {
            switch(map[i][j])
            {
            case 0:printf("◎");
                break;
            case 1:printf("■");
                break;
            case 2:printf("★");
                break;

            }
            if(j==15)
                printf("\n");
        }
    }
}
void main()
{
   
    int i,j;
    char key;
    int map[14][16]=
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    };   
    i=9 ,j=8;


      while(1)
      {
           system("cls");
           printMap(map);
          key=getch();
            switch(key)
          {
            case 72:
              {
                  map[i-1][j]=2;
                  map[i][j]=0;
                  i--;
                  break;
            case 75:    //左箭头
                  map[i][j-1]=2;
                  map[i][j]=0;
                  j--;
                  break;
            case 77:    //右箭头
                  map[i][j+1]=2;
                  map[i][j]=0;
                  j++;
                  break;
            case 80:    //下箭头
                  map[i+1][j]=2;
                  map[i][j]=0;
                  i++;
            break;
            default:
            break;
            
              }
          }
      }

   
}
搜索更多相关主题的帖子: 控制台 include 
2012-11-24 23:52
ch307458491
Rank: 1
等 级:新手上路
帖 子:27
专家分:2
注 册:2012-10-4
收藏
得分:0 
回复 3楼 TonyDeng
能举个例子么
2012-11-25 00:40
ch307458491
Rank: 1
等 级:新手上路
帖 子:27
专家分:2
注 册:2012-10-4
收藏
得分:0 
我用的是VC++6.0  没有GOTOXY
2012-11-26 10:57
ch307458491
Rank: 1
等 级:新手上路
帖 子:27
专家分:2
注 册:2012-10-4
收藏
得分:0 
回复 9楼 cnfarer
我查了很久    能举几个简单的api么
2012-11-26 16:25
快速回复:控制台清屏闪烁的厉害
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026807 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved