打印不印刷阵列显示虽然指定 [英] Print doesn't show in printed array although specified

查看:102
本文介绍了打印不印刷阵列显示虽然指定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个简单的糖果美眉游戏我今年1分配。

I'm working a simple candy crush game for my year 1 assignment.

我在这个阶段,我需要证明我的自制简单的标记(*制成的盒子'|'和'_'*)在董事会(中心板[5] [5] )一旦执行该程序。

I am at this stage where I need to show my self-made simple marker( *box made of '|' and '_'* ) on the center of the board ( board[5][5] ) once the program is executed.

下面是当前code:

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

//FUNCTION: Draw the Board
int drawBoard()
{
    //Declare array size
    int board[9][9];

    //initialize variables
    int rows, columns, randomNumber, flag;

    //random number seed generator
    srand(time(NULL));

        for ( rows = 0 ; rows < 9 ; rows++ )
        {

            for ( columns = 0 ; columns < 9 ; columns++ )
            {
                flag = 0;

                do
               {
                    //generate random numbers from 2 - 8
                randomNumber = rand() %7 + 2;

                board[rows][columns] = randomNumber;

                //Checks for 2 adjacent numbers.
                if  ( board[rows][columns] == board[rows - 1][columns] || board[rows][columns] == board[rows][columns - 1] )
                    {
                        flag = 0;
                        continue;
                    }

                else
                     {
                        flag = 1;
                        printf( "  %d  ", board[rows][columns] );
                     }

                } while ( flag == 0 );

            }//end inner for-loop

            printf("\n\n");

        }//end outer for-loop

//call FUNCTION marker() to display marker around board[5][5]
marker( board[5][5] );

}//end FUNCTION drawBoard

//FUNCTION: Mark the surrounding of the number with "|" and "_" at board[5][5]
void marker( int a )
{
    printf( " _ \n" );
    printf( "|%c|\n", a );
    printf( " _ \n" );
}

int main()
{
    drawBoard();
}

在函数结尾 drawBoard(),我把code 标记(板[5] [5])

这应该打印在协调板[5] [5] ..但出于某种原因,它会显示正确的董事会已打印。

This should have printed the markers around the number printed at coordinate board[5][5]..but for some reason it displays right after the board has been printed.

那么,为什么不将其打印在,虽然我在指定它的位置板[5] [5]

So why doesn't it print at that coordinate although I specified it at board[5][5]?

还有什么比这里是什么问题?

What could be the problem here?

推荐答案

有是在你这样做的方式没有持续的图纸。你只是直接打印到shell /命令提示符。你要做的事情是行不通的路。你画后,你需要基本上清除屏幕,然后再画,但与你指定的制造商不能编辑绘制的提示东西。

There is no persistent drawing in the way that you are doing this. You are just printing straight to the shell/command prompt. The way that you trying to do things will not work. You can't edit something drawn to the prompt after you have drawn it, you need to basically clear the screen and then draw again but with your indicated maker.

我不知道你是否能够使用图书馆的分配,但是可以让你做一个非常好的图书馆的 ncurses的

I don't know if you are able to use libraries in your assignment, but a very good library that WILL let you do is ncurses

修改 的答案全部重写

好吧,我在工作的一些停工,所以我写了一个项目,你需要什么,我要去发布code和解释它做什么,以及为什么需要它前进的道路。

Alright, I had some downtime at work, so I wrote a project to do what you need and I'm going to post code and explain what it does and why you need it along the way.

第一薄,你将需要一个基本渲染缓冲区或渲染背景。当你在一个图形API如OpenGL编程,你不只是直接呈现在屏幕上,你渲染,你必须是你的光栅化内容,并把它变成一个像素缓冲区中的每个对象。一旦它在这种形式中,API猛推所呈现的画面到屏幕上。我们将采取类似的做法在那里,而不是绘图GPU上的一个像素缓冲区,我们要绘制一个字符缓冲区。想到每个字符在屏幕上的一个像素。

First thin that you are going to need a basically a render buffer or a render context. Whenever you are programming in a graphics API such as OpenGL, you don't just render straight to the screen, you render each object that you have to a buffer that rasterizes your content and turns it into pixels. Once it's in that form, the API shoves the rendered picture onto the screen. We are going to take a similar approach where instead of drawing to a pixel buffer on the GPU, we are going to draw to a character buffer. Think about each character as a pixel on the screen.

下面是完整的源代码的引擎收录:
项目的完整源代码

的RenderContext

RenderContext

我们的课上做这将是的RenderContext 类。它具有我们填补我们缓冲区每当我们清除领域持有的宽度和高度,以及字符的数组和特殊字符。

Our class to do this will be the RenderContext class. It has fields to hold width and height as well as an array of chars and a special char that we fill our buffer with whenever we clear it.

这简直类持有数组和功能让我们渲染它。它确保当我们画它,我们是范围内。这是可能的一个目的是试图裁剪空间(关闭屏幕)的外绘制。然而,无论被吸入那里被丢弃。

This class simply holds an array and functions to let us render to it. It makes sure that when we draw to it, we are within bounds. It is possible for an object to try to draw outside of the clipping space (off screen). However, whatever is drawn there is discarded.

class RenderContext {
private:
   int m_width, m_height; // Width and Height of this canvas
   char* m_renderBuffer; // Array to hold "pixels" of canvas
   char m_clearChar; // What to clear the array to

public:
   RenderContext() : m_width(50), m_height(20), m_clearChar(' ') {
      m_renderBuffer = new char[m_width * m_height];
   }
   RenderContext(int width, int height) : m_width(width), m_height(height), m_clearChar(' ') {
      m_renderBuffer = new char[m_width * m_height];
   }
   ~RenderContext();
   char getContentAt(int x, int y);
   void setContentAt(int x, int y, char val);
   void setClearChar(char clearChar);
   void render();
   void clear();
};

这个类的两个最重要的功能是 setContentAt 渲染

setContentAt 的是一个对象,称之为填写像素的价值。为了使这一点更灵活,我们的类使用一个指向字符数组,而不是直阵列中(甚至是二维数组)。这让我们在运行时设置画布的大小。正因为如此,我们访问该数组 X +(Y * m_width)取代二维解引用,如改编[I]的元素[ J]

setContentAt is what an object calls to fill in a "pixel" value. To make this a little more flexible, our class uses a pointer to an array of chars rather than a straight array (or even a two dimensional array). This lets us set the size of our canvas at runtime. Because of this, we access elements of this array with x + (y * m_width) which replaces a two dimensional dereference such as arr[i][j]

// Fill a specific "pixel" on the canvas
void RenderContext::setContentAt(int x, int y, char val) {
   if (((0 <= x) && (x < m_width)) && ((0 <= y) && (y < m_height))) {
      m_renderBuffer[(x + (y * m_width))] = val;
   }
}

渲染 的是实际提请提示。它是所有遍历所有的像素在它的缓冲器,并将其放置在屏幕上,然后移动到下一行。

render is what actually draws to the prompt. All it does is iterate over all the "pixels" in it's buffer and place them on screen and then moves to the next line.

// Paint the canvas to the shell
void RenderContext::render() {
   int row, column;
   for (row = 0; row < m_height; row++) {
      for (column = 0; column < m_width; column++) {
         printf("%c", getContentAt(column, row));
      }
      printf("\n");
   }
}


I_Drawable


I_Drawable

我们的下一堂课是接口,让我们的合同,他们可以借鉴到我们的RenderContext对象。因为我们不希望真正能够实例它是纯虚,只是想从中得到。它的唯一功能是的 的,它接受的RenderContext。派生类使用这个调用来接收RenderContext中,然后用RenderContext中的setContentAt把像素到缓冲区中。

Our next class is an Interface that lets us contract with objects that they can draw to our RenderContext. It is pure virtual because we don't want to actually be able to instantiate it, we only want to derive from it. It's only function is draw which accepts a RenderContext. Derived classes use this call to receive the RenderContext and then use RenderContext's setContentAt to put "pixels" into the buffer.

class I_Drawable {
public:
   virtual void draw(RenderContext&) = 0;
};


游戏键盘


GameBoard

第一类来实现I_Drawable,从而能够呈现给我们的RenderContext,是游戏键盘类。这是大多数逻辑的用武之地。它有宽度,高度,以及持有板上的元素的值的整数数组领域。它也有间距其他两个字段。因为当你使用code绘制板,你必须每个元素之间的空格。我们并不需要纳入板的底层结构这一点,我们只需要在我们借鉴使用它们。

The first class to implement the I_Drawable, thus being able to render to our RenderContext, is the GameBoard class. This is where a majority of the logic comes in. It has fields for width, height, and a integer array that holds the values of the elements on the board. It also has two other fields for spacing. Since when you draw your board using your code, you have spaces between each element. We don't need to incorporate this into the underlying structure of the board, we just need to use them when we draw.

class GameBoard : public I_Drawable {
private:
   int m_width, m_height; // Width and height of the board
   int m_verticalSpacing, m_horizontalSpacing; // Spaces between each element on the board
   Marker m_marker; // The cursor that will draw on this board
   int* m_board; // Array of elements on this board

   void setAtPos(int x, int y, int val);
   void generateBoard();

public:
   GameBoard() : m_width(10), m_height(10), m_verticalSpacing(5), m_horizontalSpacing(3), m_marker(Marker()) {
      m_board = new int[m_width * m_height];
      generateBoard();
   }
   GameBoard(int width, int height) : m_width(width), m_height(height), m_verticalSpacing(5), m_horizontalSpacing(3), m_marker(Marker()) {
      m_board = new int[m_width * m_height];
      generateBoard();
   }
   ~GameBoard();
   int getAtPos(int x, int y);
   void draw(RenderContext& renderTarget);
   void handleInput(MoveDirection moveDirection);
   int getWidth();
   int getHeight();
};

这是主要的功能是 generateBoard handleInput ,并衍生出虚函数吸取。但是,请注意,它的构造函数创建一个新的int数组,并给它的指针。然后,每当董事会消失析构函数自动删除分配的内存。

It's key functions are generateBoard, handleInput, and the derived virtual function draw. However, do note that in its constructor it creates a new int array and gives it to its pointer. Then its destructor automatically removes the allocated memory whenever the board goes away.

generateBoard 的是我们用实际建立董事会和用数字填充。它会遍历在黑板上的每个位置。每一次,它看起来在元件直接向左侧和上方,并存储它们。然后,直到它产生不匹配任一存储元件的数量,然后将其存储在数组中的数量,就会产生一个随机数。我重写了这个摆脱标志使用的。这个函数的类的构造过程中调用。

generateBoard is what we use to actual create the board and fill it with numbers. It will iterate over each location on the board. Each time, it will look at the elements directly to the left and above and store them. Then it will generate a random number until the number it generates does not match either of the stored elements, then it stores the number in the array. I rewrote this to get rid of the flag usage. This function gets called during the construction of the class.

// Actually create the board
void GameBoard::generateBoard() {
   int row, column, randomNumber, valToLeft, valToTop;

   // Iterate over all rows and columns
   for (row = 0; row < m_height; row++) {
      for (column = 0; column < m_width; column++) {
         // Get the previous elements
         valToLeft = getAtPos(column - 1, row);
         valToTop = getAtPos(column, row - 1);

         // Generate random numbers until we have one 
         // that is not the same as an adjacent element
         do {
            randomNumber = (2 + (rand() % 7));
         } while ((valToLeft == randomNumber) || (valToTop == randomNumber));
         setAtPos(column, row, randomNumber);
      }
   }
}

handleInput 的是在棋盘上移动光标什么交易。这基本上是一个免费的东西和获得光标,绘制在董事会后,您的下一个步骤。我需要一种方法来测试图。它接受我们开机知道在哪里我们将光标移动到下一个枚举。如果你也许想有每当你到达一个边缘各地板光标包,你会想这样做在这里。

handleInput is what deals with moving the cursor around on the board. It's basically a freebie and your next step after getting the cursor to draw over the board. I needed a way to test the drawing. It accepts an enumeration that we switch on to know where to move our cursor to next. If you maybe wanted to have your cursor wrap around the board whenever you reach an edge, you would want to do that here.

void GameBoard::handleInput(MoveDirection moveDirection) {
   switch (moveDirection) {
      case MD_UP:
         if (m_marker.getYPos() > 0)
            m_marker.setYPos(m_marker.getYPos() - 1);
         break;
      case MD_DOWN:
         if (m_marker.getYPos() < m_height - 1)
            m_marker.setYPos(m_marker.getYPos() + 1);
         break;
      case MD_LEFT:
         if (m_marker.getXPos() > 0)
            m_marker.setXPos(m_marker.getXPos() - 1);
         break;
      case MD_RIGHT:
         if (m_marker.getXPos() < m_width - 1)
            m_marker.setXPos(m_marker.getXPos() + 1);
         break;
   }
}

的是非常重要的,因为它就是获取数字到RenderContext中。总之,它遍历在黑板上的每一个元素,并在正确的位置绘制在画布上正确的像素下配售的元素。这是我们结合的间距。此外,照顾和注意,我们在渲染这个函数指针。

draw is very important because it's what gets the numbers into the RenderContext. To summarize, it iterates over every element on the board, and draws in the correct location on the canvas placing an element under the correct "pixel". This is where we incorporate the spacing. Also, take care and note that we render the cursor in this function.

这是一个选择的问题,但您可以存储一个标记的游戏键盘类之外,自己呈现在主循环(这将是一个不错的选择,因为它松开游戏键盘类和标记类之间的耦合。然而,由于它们的的相当再加,我选择了让游戏键盘渲染它。如果我们用一个场景图,因为我们可能会用更复杂的场景/游戏,标志可能会是一个子节点该游戏键盘,所以这将是类似于此实现,但更通用的由游戏键盘类不存储一个明确的标记。

It's a matter of choice, but you can either store a marker outside of the GameBoard class and render it yourself in the main loop (this would be a good choice because it loosens the coupling between the GameBoard class and the Marker class. However, since they are fairly coupled, I chose to let GameBoard render it. If we used a scene graph, as we probably would with a more complex scene/game, the Marker would probably be a child node of the GameBoard so it would be similar to this implementation but still more generic by not storing an explicit Marker in the GameBoard class.

// Function to draw to the canvas
void GameBoard::draw(RenderContext& renderTarget) {
   int row, column;
   char buffer[8];

   // Iterate over every element
   for (row = 0; row < m_height; row++) {
      for (column = 0; column < m_width; column++) {

         // Convert the integer to a char
         sprintf(buffer, "%d", getAtPos(column, row));

         // Set the canvas "pixel" to the char at the
         // desired position including the padding
         renderTarget.setContentAt(
                 ((column * m_verticalSpacing) + 1),
                 ((row * m_horizontalSpacing) + 1),
                 buffer[0]);
      }
   }

   // Draw the marker
   m_marker.draw(renderTarget);
}


标记


Marker

标记类说起,让我们来看看现在。的标记类实际上是非常相似的游戏键盘类。但是,它缺乏了很多游戏键盘拥有,因为它并不需要担心了一堆电路板上元件的逻辑。最重要的是平局功能。

Speaking of the Marker class, let's look at that now. The Marker class is actually very similar to the GameBoard class. However, it lacks a lot of the logic that GameBoard has since it doesn't need to worry about a bunch of elements on the board. The important thing is the draw function.

class Marker : public I_Drawable {
private:
   int m_xPos, m_yPos; // Position of cursor
public:
   Marker() : m_xPos(0), m_yPos(0) {
   }
   Marker(int xPos, int yPos) : m_xPos(xPos), m_yPos(yPos) {
   }
   void draw(RenderContext& renderTarget);
   int getXPos();
   int getYPos();
   void setXPos(int xPos);
   void setYPos(int yPos);
};

的只是把四个符号上的RenderContext勾勒板上的所选元素。注意到,标记有没有关于游戏键盘类线索。它没有提到它,它不知道它是多么大,或者其持有什么样的元素。你应该不过注意,我得到了偷懒,并没有拿出硬codeD偏移那种依赖于该游戏键盘有填充。您应该实现一个更好的解决方案,这一点,因为如果你改变填充的游戏键盘类,你的光标将被关闭。

draw simply puts four symbols onto the RenderContext to outline the selected element on the board. Take note that Marker has no clue about the GameBoard class. It has no reference to it, it doesn't know how large it is, or what elements it holds. You should note though, that I got lazy and didn't take out the hard coded offsets that sort of depend on the padding that the GameBoard has. You should implement a better solution to this because if you change the padding in the GameBoard class, your cursor will be off.

除此之外,每当符号拿得出,它们将覆盖无论是在ContextBuffer。这是重要的,因为你的问题的重点是如何绘制光标在游戏键盘的顶部。这也去绘制顺序的重要性。比方说,当我们把我们的游戏键盘,我们每个元素之间画了一个'='。如果我们先提请光标板,游戏键盘会笼络光标使其不可见。

Besides that, whenever the symbols get drawn, they overwrite whatever is in the ContextBuffer. This is important because the main point of your question was how to draw the cursor on top of the GameBoard. This also goes to the importance of draw order. Let's say that whenever we draw our GameBoard, we drew a '=' between each element. If we drew the cursor first and then the board, the GameBoard would draw over the cursor making it invisible.

如果这是一个更复杂的场景中,我们可能需要做一些花哨像使用深度缓冲,将记录一个元素的的z-index 。然后当我们画了,我们会检查,看看是否新元素的Z-指数比任何已经在RenderContext中的缓冲区更近或更远。根据这一点,我们可能会跳过绘制像素干脆。

If this were a more complex scene, we might have to do something fancy like use a depth buffer that would record the z-index of an element. Then whenever we drew, we would check and see if the z-index of the new element was closer or further away than whatever was already in the RenderContext's buffer. Depending on that, we might skip drawing the "pixel" altogether.

我们没有的,所以要小心订购您绘制调用!

We don't though, so take care to order your draw calls!

// Draw the cursor to the canvas
void Marker::draw(RenderContext& renderTarget) {

   // Adjust marker by board spacing
   // (This is kind of a hack and should be changed)
   int tmpX, tmpY;
   tmpX = ((m_xPos * 5) + 1);
   tmpY = ((m_yPos * 3) + 1);

   // Set surrounding elements
   renderTarget.setContentAt(tmpX - 0, tmpY - 1, '-');
   renderTarget.setContentAt(tmpX - 1, tmpY - 0, '|');
   renderTarget.setContentAt(tmpX - 0, tmpY + 1, '-');
   renderTarget.setContentAt(tmpX + 1, tmpY - 0, '|');
}


CmdPromptHelper


CmdPromptHelper

这是我要谈的最后一类是CmdPromptHelper。你不必在你原来的问题这样的事。但是,您将需要尽快担心。这个类也只有在Windows上使用,所以如果你是在Linux / UNIX,您将不必担心处理绘图外壳自己。

The last class that I'm going to talk about is the CmdPromptHelper. You don't have anything like this in your original question. However, you will need to worry about it soon. This class is also only useful on Windows so if you are on linux/unix, you will need to worry about dealing with drawing to the shell yourself.

class CmdPromptHelper {
private:
   DWORD inMode; // Attributes of std::in before we change them
   DWORD outMode; // Attributes of std::out before we change them
   HANDLE hstdin; // Handle to std::in
   HANDLE hstdout; // Handle to std::out
public:
   CmdPromptHelper();
   void reset();
   WORD getKeyPress();
   void clearScreen();
};

的功能的每一个是重要的。构造函数获取句柄的std ::在的std ::出来当前命令提示符。在 getKey preSS 函数返回用户presses (按键式的事件被忽略)什么键。和 clearScreen 函数清除提示(不是真的,它实际上任何移动已经在提示上)。

Each one of the functions is important. The constructor gets handles to the std::in and std::out of the current command prompt. The getKeyPress function returns what key the user presses down (key-up events are ignored). And the clearScreen function clears the prompt (not really, it actually moves whatever is already in the prompt up).

getKey preSS 的只是确保你有一个句柄,然后读取了输入到控制台。它确保不管它是什么,它​​是一个关键,它正在pressed下来。然后,它返回键code作为一个Windows特定枚举通常美元的 pfaced p $ VK _

// See what key is pressed by the user and return it
WORD CmdPromptHelper::getKeyPress() {
   if (hstdin != INVALID_HANDLE_VALUE) {
      DWORD count;
      INPUT_RECORD inrec;

      // Get Key Press
      ReadConsoleInput(hstdin, &inrec, 1, &count);

      // Return key only if it is key down
      if (inrec.Event.KeyEvent.bKeyDown) {
         return inrec.Event.KeyEvent.wVirtualKeyCode;
      } else {
         return 0;
      }

      // Flush input
      FlushConsoleInputBuffer(hstdin);
   } else {
      return 0;
   }
}

clearScreen 的有点掩耳盗铃。你会认为它清除出在提示中的文本。据我所知,没有。我是pretty确保它居然高达改变所有的内容,然后写一吨字符的提示,使它看起来像屏幕被清除。

clearScreen is a little deceiving. You would think that it clears out the text in the prompt. As far as I know, it doesn't. I'm pretty sure it actually shifts all the content up and then writes a ton of characters to the prompt to make it look like the screen was cleared.

这个功能虽然带来了一个重要概念是缓冲渲染的想法。再次,如果这是一个更强大的系统中,我们将要实现双缓冲的这意味着渲染到一个不可见的缓冲器,等待,直到所有的绘制完成的概念,然后用可见光相互交换无形缓冲器。这使得的渲染,因为我们没有看到的东西,而他们仍然得到绘制的更清洁的观点。我们在这里做事的方式,我们看到了渲染过程发生就在我们的面前。这不是一个大问题,它只是看起来丑陋有时

An important concept that this function brings up though is the idea of buffered rendering. Again, if this were a more robust system, we would want to implement the concept of double buffering which means rendering to an invisible buffer and waiting until all drawing is finished and then swap the invisible buffer with the visible one. This makes for a much cleaner view of the render because we don't see things while they are still getting drawn. The way we do things here, we see the rendering process happen right in front of us. It's not a major concern, it just looks ugly sometimes.

// Flood the console with empty space so that we can
// simulate single buffering (I have no idea how to double buffer this)
void CmdPromptHelper::clearScreen() {
   if (hstdout != INVALID_HANDLE_VALUE) {
      CONSOLE_SCREEN_BUFFER_INFO csbi;
      DWORD cellCount; // How many cells to paint
      DWORD count; // How many we painted
      COORD homeCoord = {0, 0}; // Where to put the cursor to clear

      // Get console info
      if (!GetConsoleScreenBufferInfo(hstdout, &csbi)) {
         return;
      }

      // Get cell count
      cellCount = csbi.dwSize.X * csbi.dwSize.Y;

      // Fill the screen with spaces
      FillConsoleOutputCharacter(
              hstdout,
              (TCHAR) ' ',
              cellCount,
              homeCoord,
              &count
              );

      // Set cursor position
      SetConsoleCursorPosition(hstdout, homeCoord);
   }
}



main

,你需要担心的最后一件事是如何使用这些东西。这就是主要的用武之地。你需要一个游戏循环。游戏循环是可能在任何游戏中最重要的事情。任何游戏,你看会有一个游戏循环。

The very last thing that you need to worry about is how to use all these things. That's where main comes in. You need a game loop. Game loops are probably the most important thing in any game. Any game that you look at will have a game loop.

的理念是:


  1. 显示在屏幕上的东西

  2. 读取输入

  3. 处理输入

  4. GOTO 1

此程序是没有什么不同。它做的第一件事就是创建一个游戏键盘和的RenderContext。这也使得CmdPromptHelper它可以在命令行界面让。之后,又开始循环,让循环继续下去,直到我们打的退出条件(对我们来说这是pressing逃逸)。我们可以有一个单独的类或函数做调度的输入,但由于我们只是派遣输入到另一个输入处理程序,我一直是在主循环。当您得到输入,你若脱到相应改变自身的游戏键盘发送。下一个步骤是清除的RenderContext和屏幕/提示。然后重新运行循环,如果逃跑不是pressed。

This program is no different. The first thing it does is create a GameBoard and a RenderContext. It also makes a CmdPromptHelper which lets of interface with the command prompt. After that, it starts the loop and lets the loop continue until we hit the exit condition (for us that's pressing escape). We could have a separate class or function do dispatch input, but since we just dispatch the input to another input handler, I kept it in the main loop. After you get the input, you send if off to the GameBoard which alters itself accordingly. The next step is to clear the RenderContext and the screen/prompt. Then rerun the loop if escape wasn't pressed.

int main() {
   WORD key;
   GameBoard gb(5, 5);
   RenderContext rc(25, 15);
   CmdPromptHelper cph;
   do {
      gb.draw(rc);
      rc.render();

      key = cph.getKeyPress();
      switch (key) {
         case VK_UP:
            gb.handleInput(MD_UP);
            break;
         case VK_DOWN:
            gb.handleInput(MD_DOWN);
            break;
         case VK_LEFT:
            gb.handleInput(MD_LEFT);
            break;
         case VK_RIGHT:
            gb.handleInput(MD_RIGHT);
            break;
      }
      rc.clear();
      cph.clearScreen();
   } while (key != VK_ESCAPE);
}


您已经考虑到所有这些事情之后,你就明白为什么以及在哪里你需要绘制光标。这不是调用了一个又一个的功能的问题,你需要你的组合吸引。你不能只是绘制游戏键盘,然后绘制标记。至少不是用命令提示符。我希望这有帮助。这无疑缓解了停机时间在工作。


After you have taken into consideration all of these things, you understand why and where you need to be drawing your cursor. It's not a matter of calling a function after another, you need to composite your draws. You can't just draw the GameBoard and then draw the Marker. At least not with the command prompt. I hope this helps. It definitely alleviated the down time at work.

这篇关于打印不印刷阵列显示虽然指定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆