输出恰好一个字符,它是一个清晰的屏幕。命令,而不是空格。速度慢的是system(),因为它必须执行单独的进程。仍然错误。cls不执行DOS命令。它是system()执行一个过程,正如我已经说过的。您可以输出cls输出的单个字符,并保存所有这些代码。如果您不知道某些东西是如何工作的,不要在这里进行猜测。您是ri,c++,C++" /> 输出恰好一个字符,它是一个清晰的屏幕。命令,而不是空格。速度慢的是system(),因为它必须执行单独的进程。仍然错误。cls不执行DOS命令。它是system()执行一个过程,正如我已经说过的。您可以输出cls输出的单个字符,并保存所有这些代码。如果您不知道某些东西是如何工作的,不要在这里进行猜测。您是ri,c++,C++" />

使用系统(“cls”)而不关闭Pacman游戏 我一直在开发DeV C++的PACMN游戏开发。当玩家移动时,我使用循环和系统(“cls”)重新绘制整个更新的地图,这是可行的,但每次玩家按下按钮(箭头键)时,它都会导致快门。所以如果你们有什么想法,我不能只更新玩家“角色”而不重新绘制整个地图?或者任何代码都可以使系统(“cls”)在不导致关闭的情况下工作得更快。谢谢我真的很感谢你的帮助 int main() { char map[31][65] = { " " , " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " , " @ @ " , " @ @ " , " @ @ " , " @ @ " , " @@@@@@@@@@@@@@@@@@@@ C @ " , " @ @ " , " @ @ " , " @ @ " , " @ @@@@@@@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @@@@@@@@@@@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @@@@@@@@@@ @ " , " @ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ X @ @ " , // Position Of Character 'X' = map[27][27] " @ @ @ " , " @ @ " , " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " } ; for ( int y = 1 ; y < 31 ; y++ ) { for ( int x = 1 ; x < 65 ; x ++ ) { cout << map[y][x] ; } cout << endl ; } cout << map[27][27] ; int a = 27 , b = 27 ; int c = 0 ; // Define What Arrow Key Used to Control The Charater while (1) { c = 0 ; switch ( ( c=getch() ) ) { case KEY_UP : if ( map[a-1][b] != '@' ) { map[a][b] = ' ' ; cout << map[a][b] ; a-- ; map[a][b] = 'X' ; cout << map[a][b] ; } break ; case KEY_DOWN : if ( map[a+1][b] != '@' ) { map[a][b] = ' ' ; a++ ; map[a][b] = 'X' ; } break ; case KEY_LEFT : if ( map[a][b-1] != '@' ) { map[a][b] = ' ' ; b-- ; map[a][b] = 'X' ; } break ; case KEY_RIGHT : if ( map[a][b+1] != '@' ) { map[a][b] = ' ' ; b++ ; map[a][b] = 'X' ; } break ; } system("cls") ; for ( int y = 1 ; y < 31 ; y++ ) { for ( int x = 1 ; x < 65 ; x ++ ) { cout << map[y][x] ; } cout << endl ; } } return 0 ; } intmain() { 字符映射[31][65]= { " " , " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " , " @ @ " , " @ @ " , " @ @ " , " @ @ " , “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@, " @ @ " , " @ @ " , " @ @ " , " @ @@@@@@@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @@@@@@@@@@@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @@@@@@@@@@ @ " , " @ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , “@X@@@1,//字符“X”的位置=映射[27][27] " @ @ @ " , " @ @ " , " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " } ; 对于(int y=1;y CLS < /Cord>输出恰好一个字符,它是一个清晰的屏幕。命令,而不是空格。速度慢的是system(),因为它必须执行单独的进程。仍然错误。cls不执行DOS命令。它是system()执行一个过程,正如我已经说过的。您可以输出cls输出的单个字符,并保存所有这些代码。如果您不知道某些东西是如何工作的,不要在这里进行猜测。您是ri

使用系统(“cls”)而不关闭Pacman游戏 我一直在开发DeV C++的PACMN游戏开发。当玩家移动时,我使用循环和系统(“cls”)重新绘制整个更新的地图,这是可行的,但每次玩家按下按钮(箭头键)时,它都会导致快门。所以如果你们有什么想法,我不能只更新玩家“角色”而不重新绘制整个地图?或者任何代码都可以使系统(“cls”)在不导致关闭的情况下工作得更快。谢谢我真的很感谢你的帮助 int main() { char map[31][65] = { " " , " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " , " @ @ " , " @ @ " , " @ @ " , " @ @ " , " @@@@@@@@@@@@@@@@@@@@ C @ " , " @ @ " , " @ @ " , " @ @ " , " @ @@@@@@@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @@@@@@@@@@@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @@@@@@@@@@ @ " , " @ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ X @ @ " , // Position Of Character 'X' = map[27][27] " @ @ @ " , " @ @ " , " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " } ; for ( int y = 1 ; y < 31 ; y++ ) { for ( int x = 1 ; x < 65 ; x ++ ) { cout << map[y][x] ; } cout << endl ; } cout << map[27][27] ; int a = 27 , b = 27 ; int c = 0 ; // Define What Arrow Key Used to Control The Charater while (1) { c = 0 ; switch ( ( c=getch() ) ) { case KEY_UP : if ( map[a-1][b] != '@' ) { map[a][b] = ' ' ; cout << map[a][b] ; a-- ; map[a][b] = 'X' ; cout << map[a][b] ; } break ; case KEY_DOWN : if ( map[a+1][b] != '@' ) { map[a][b] = ' ' ; a++ ; map[a][b] = 'X' ; } break ; case KEY_LEFT : if ( map[a][b-1] != '@' ) { map[a][b] = ' ' ; b-- ; map[a][b] = 'X' ; } break ; case KEY_RIGHT : if ( map[a][b+1] != '@' ) { map[a][b] = ' ' ; b++ ; map[a][b] = 'X' ; } break ; } system("cls") ; for ( int y = 1 ; y < 31 ; y++ ) { for ( int x = 1 ; x < 65 ; x ++ ) { cout << map[y][x] ; } cout << endl ; } } return 0 ; } intmain() { 字符映射[31][65]= { " " , " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " , " @ @ " , " @ @ " , " @ @ " , " @ @ " , “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@, " @ @ " , " @ @ " , " @ @ " , " @ @@@@@@@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @@@@@@@@@@@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @@@@@@@@@@ @ " , " @ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , " @ @@@@@@@@@ @ " , " @ @ @ " , " @ @ @ " , " @ @ @ " , “@X@@@1,//字符“X”的位置=映射[27][27] " @ @ @ " , " @ @ " , " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " } ; 对于(int y=1;y CLS < /Cord>输出恰好一个字符,它是一个清晰的屏幕。命令,而不是空格。速度慢的是system(),因为它必须执行单独的进程。仍然错误。cls不执行DOS命令。它是system()执行一个过程,正如我已经说过的。您可以输出cls输出的单个字符,并保存所有这些代码。如果您不知道某些东西是如何工作的,不要在这里进行猜测。您是ri,c++,C++,如果使用windows,则可以使用更新字符 //Return the handle to the console GetStdHandle( STD_OUTPUT_HANDLE ); //Get the current buffer of the console GetConsoleScreenBufferInfo( h, &info ); //Write on the console buffer BOOL WINAPI WriteConsoleOutputCharacter(

如果使用windows,则可以使用更新字符

//Return the handle to the console
GetStdHandle( STD_OUTPUT_HANDLE );

//Get the current buffer of the console
GetConsoleScreenBufferInfo( h, &info );

//Write on the console buffer
BOOL WINAPI WriteConsoleOutputCharacter(
  _In_  HANDLE  hConsoleOutput,
  _In_  LPCTSTR lpCharacter,
  _In_  DWORD   nLength,
  _In_  COORD   dwWriteCoord,
  _Out_ LPDWORD lpNumberOfCharsWritten
);
更新: 这是一个演示如何在windows中使用API的简单示例

#include <stdio.h>
#include <iostream>
#include <vector>
#include <windows.h>

int main()
{
    //Handle to standard output console
    HANDLE g_console_handle;
    //Console informations
    CONSOLE_SCREEN_BUFFER_INFO g_console_info;
    //return
    DWORD ret;
    //get handle to console
    g_console_handle = GetStdHandle( STD_OUTPUT_HANDLE );

    GetConsoleScreenBufferInfo( g_console_handle, &g_console_info );
    //Get console size
    int rows = g_console_info.dwSize.Y;
    int cols = g_console_info.dwSize.X;
    //Create buffer
    std::vector<char> g_buffer = std::vector<char>( rows *cols, ' ' );
    //console coordinate
    COORD origin;
    //Start writing char from first cell
    origin.X = 0;
    origin.Y = 0;
    //Fill console with tilda
    int t, ti;
    for (t =0;t<rows;t++)
    {
        for (ti =0;ti<cols;ti++)
        {
            g_buffer[t*cols+ti] = '~';
        }
    }

    //Windows API to access the console buffer
    WriteConsoleOutputCharacter
    (
        g_console_handle,       //handle to console
        &g_buffer[0],           //pointer to buffer
        rows*cols,              //number of char to write
        origin,                 //coordinate where start writing
        &ret                    //return number of char actually written
    );

}
#包括
#包括
#包括
#包括
int main()
{
//标准输出控制台的句柄
手柄g_控制台_手柄;
//控制台信息
控制台屏幕缓冲区信息控制台信息;
//返回
德沃德·雷特;
//控制控制台
g_控制台_句柄=GetStdHandle(标准输出_句柄);
GetConsoleScreenBufferInfo(g_控制台句柄和g_控制台信息);
//获取控制台大小
int rows=g_console_info.dwSize.Y;
int cols=g_console_info.dwSize.X;
//创建缓冲区
std::vector g_buffer=std::vector(行*cols');
//控制台坐标
坐标原点;
//开始从第一个单元格写入字符
原点X=0;
原点Y=0;
//用蒂尔达填充控制台
int t,ti;

对于(t=0;t如果使用windows,则可以使用更新字符

//Return the handle to the console
GetStdHandle( STD_OUTPUT_HANDLE );

//Get the current buffer of the console
GetConsoleScreenBufferInfo( h, &info );

//Write on the console buffer
BOOL WINAPI WriteConsoleOutputCharacter(
  _In_  HANDLE  hConsoleOutput,
  _In_  LPCTSTR lpCharacter,
  _In_  DWORD   nLength,
  _In_  COORD   dwWriteCoord,
  _Out_ LPDWORD lpNumberOfCharsWritten
);
更新: 这是一个演示如何在windows中使用API的简单示例

#include <stdio.h>
#include <iostream>
#include <vector>
#include <windows.h>

int main()
{
    //Handle to standard output console
    HANDLE g_console_handle;
    //Console informations
    CONSOLE_SCREEN_BUFFER_INFO g_console_info;
    //return
    DWORD ret;
    //get handle to console
    g_console_handle = GetStdHandle( STD_OUTPUT_HANDLE );

    GetConsoleScreenBufferInfo( g_console_handle, &g_console_info );
    //Get console size
    int rows = g_console_info.dwSize.Y;
    int cols = g_console_info.dwSize.X;
    //Create buffer
    std::vector<char> g_buffer = std::vector<char>( rows *cols, ' ' );
    //console coordinate
    COORD origin;
    //Start writing char from first cell
    origin.X = 0;
    origin.Y = 0;
    //Fill console with tilda
    int t, ti;
    for (t =0;t<rows;t++)
    {
        for (ti =0;ti<cols;ti++)
        {
            g_buffer[t*cols+ti] = '~';
        }
    }

    //Windows API to access the console buffer
    WriteConsoleOutputCharacter
    (
        g_console_handle,       //handle to console
        &g_buffer[0],           //pointer to buffer
        rows*cols,              //number of char to write
        origin,                 //coordinate where start writing
        &ret                    //return number of char actually written
    );

}
#包括
#包括
#包括
#包括
int main()
{
//标准输出控制台的句柄
手柄g_控制台_手柄;
//控制台信息
控制台屏幕缓冲区信息控制台信息;
//返回
德沃德·雷特;
//控制控制台
g_控制台_句柄=GetStdHandle(标准输出_句柄);
GetConsoleScreenBufferInfo(g_控制台句柄和g_控制台信息);
//获取控制台大小
int rows=g_console_info.dwSize.Y;
int cols=g_console_info.dwSize.X;
//创建缓冲区
std::vector g_buffer=std::vector(行*cols');
//控制台坐标
坐标原点;
//开始从第一个单元格写入字符
原点X=0;
原点Y=0;
//用蒂尔达填充控制台
int t,ti;

对于(t=0;你使用的API不是有某种定位和打印吗?我敢说,老的Turbo C++接口到DOS?@ Bathsheba,我们不说它的名字。实际上我只是乞丐,我不明白你说的Turbo C++接口是什么意思?你可以看看使用<代码> NCurss<代码>……你所使用的API不是吗?有点像定位和打印?我敢说,老的Turbo C++接口到DOS?@ Bathsheba,我们不说它的名字。我实际上只是BugBin,我不明白Turbo C++接口的意思是什么?你可以看看使用<代码> NCurss<代码>…代码> CLS < /Cord>输出恰好一个字符,它是一个清晰的屏幕。命令,而不是空格。速度慢的是
system()
,因为它必须执行单独的进程。仍然错误。
cls
不执行DOS命令。它是
system()
执行一个过程,正如我已经说过的。您可以输出
cls
输出的单个字符,并保存所有这些代码。如果您不知道某些东西是如何工作的,不要在这里进行猜测。您是ri