從字面上看就是這樣。當我點擊這里時,在這張照片中。汽車停了下來。
您可以在github的此鏈接中找到原始代碼。
#include<iostream>
#include <windows.h>
#include <time.h>
using namespace std; //don't hate me for it i started coding a day ago.
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coords;
int carY[3];
int carX[3];
int carFlag[3];
void gotoxy(int x, int y) { //change the cordinates the text outputs to
coords.X = x;
coords.Y = y;
SetConsoleCursorPosition(console, coords);
}
void gencar(int ind) {//ind means indeterminate.
carX[ind] = 40;
}
void drawcar(int ind) {
if (carFlag[ind] != false) {
gotoxy(carX[ind], carY[ind]); cout << "****";
gotoxy(carX[ind], carY[ind] 1); cout << " ** ";
gotoxy(carX[ind], carY[ind] 2); cout << "****";
gotoxy(carX[ind], carY[ind] 3); cout << " ** ";
}
}
void erasecar(int ind) { //fills old places with spaces
if (carFlag[ind] != false) {
gotoxy(carX[ind], carY[ind]); cout << " ";
gotoxy(carX[ind], carY[ind] 1); cout << " ";
gotoxy(carX[ind], carY[ind] 2); cout << " ";
gotoxy(carX[ind], carY[ind] 3); cout << " ";
}
}
它基本上在汽車下降時列印汽車,并用空格過度列印先前列印的位置。
int main()
{
carFlag[0] = 1;
carY[0] = 1;
gencar(0);
while (1) {
drawcar(0);
Sleep(60);
erasecar(0);
if (carFlag[0] == 1) //makes it move on the Y axis
carY[0] = 1;
}
return 0;
}
uj5u.com熱心網友回復:
在您的控制臺選項(左上角按鈕)中,轉到“屬性”并關閉“快速編輯模式”設定。這是一項 Windows 功能,單擊滑鼠會暫停正在運行的任何程式,并允許您從螢屏上選擇文本。您不希望將其用于您的程式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/477229.html
標籤:C
