#include <iostream> #include <windows.h> #include <conio.h> using namespace std; int main(){ HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); COORD coord = {0,0}; SetConsoleCursorPosition(handle,coord); cout<<"zs"; HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE); COORD Coord = {0,0}; SetConsoleCursorPosition(Handle,Coord); int key; while(1){ if(kbhit()){ key = getch(); SetConsoleCursorPosition(handle,coord); cout<<" "; if(key==72) coord.Y--; if(key==75) coord.X--; if(key==77) coord.X++; if(key==80) coord.Y++; if(key==87 || key==65 || key==68 || key==83){ Coord.X = coord.X,Coord.Y = coord.Y; while(Coord.Y!=1 && Coord.Y!=30 && Coord.X!=1 && Coord.X!=30){ if(key==87){ Coord.Y--; }else if(key==65){ Coord.X--; }else if(key==83){ Coord.Y++; }else if(key==68){ Coord.X++; } SetConsoleCursorPosition(Handle,Coord); cout<<"h"; Sleep(50); SetConsoleCursorPosition(handle,coord); cout<<"zs"; SetConsoleCursorPosition(Handle,Coord); cout<<" "; } } SetConsoleCursorPosition(handle,coord); cout<<"zs"; } } return 0; }
标签:HANDLE,单人,子弹,coord,发射,handle,include From: https://www.cnblogs.com/wangyihang-xh/p/18147803