C++#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
HWND hWnd=GetConsoleWindow();
HDC hdc=GetDC(hWnd);
HANDLE Out=GetStdHandle(STD_OUTPUT_HANDLE);
HPEN white=CreatePen(PS_SOLID,1,RGB(255,255,255)),black=CreatePen(PS_SOLID,2,RGB(0,0,0)),red=CreatePen(PS_SOLID,5,RGB(255,0,0));
int Cx,Cy;
struct character
{
int x,y,style;
};
vector<character> drawlist;
void del(int u)
{
drawlist[u].style=0;
}
void Dp(int x,int y)
{
MoveToEx(hdc,x,y-10,NULL);
LineTo(hdc,x+7,y+7);
LineTo(hdc,x,y+3);
LineTo(hdc,x-7,y+7);
LineTo(hdc,x,y-10);
}
void Cursor()
{
while(1){
POINT p;
GetCursorPos(&p);
ScreenToClient(hWnd,&p);
Cx=p.x,Cy=p.y;
}
}
void draw()
{
while(1)
{
SelectObject(hdc,white);
Rectangle(hdc,0,0,1980,1080);
SelectObject(hdc,black);
Dp(Cx,Cy);
for(int i=0;i<drawlist.size();i++)
{
int style=drawlist[i].style,x=drawlist[i].x,y=drawlist[i].y;
if(style==1)
{
SelectObject(hdc,black);
MoveToEx(hdc,x,y-3,NULL);
LineTo(hdc,x+3,y);
LineTo(hdc,x,y+3);
LineTo(hdc,x-3,y);
LineTo(hdc,x,y-3);
}
else if(style==2){
SelectObject(hdc,red);
Dp(x,y);
}
}
Sleep(10);
}
}
void bullet(int u){
while(drawlist[u].y>=10){
drawlist[u].y-=10;
Sleep(1);
}
del(u);
}
int main()
{
CONSOLE_CURSOR_INFO d;
GetConsoleCursorInfo(Out,&d);
d.bVisible=false;
SetConsoleCursorInfo(Out,&d);
thread GetC(Cursor);
thread print(draw);
while(1)
{
char s=getch();
if(s=='z'){
drawlist.push_back({Cx,Cy,1});
int *p=&drawlist[drawlist.size()-1].y;
thread b(bullet,drawlist.size()-1);
b.detach();
}
Sleep(100);
}
return 0;
}
C++#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
HWND hWnd=GetConsoleWindow();
HDC hdc=GetDC(hWnd);
HANDLE Out=GetStdHandle(STD_OUTPUT_HANDLE);
HPEN white=CreatePen(PS_SOLID,1,RGB(255,255,255)),black=CreatePen(PS_SOLID,2,RGB(0,0,0)),red=CreatePen(PS_SOLID,5,RGB(255,0,0));
int Cx,Cy;
struct character
{
int x,y,style;
};
vector<character> drawlist;
void del(int u)
{
drawlist[u].style=0;
}
void Cursor()
{
while(1){
POINT p;
GetCursorPos(&p);
ScreenToClient(hWnd,&p);
Cx=p.x,Cy=p.y;
}
}
void draw()
{
while(1)
{
SelectObject(hdc,white);
Rectangle(hdc,0,0,1980,1080);
SelectObject(hdc,black);
Rectangle(hdc,Cx-10,Cy-15,Cx+10,Cy+15);
for(int i=0;i<drawlist.size();i++)
{
int style=drawlist[i].style,x=drawlist[i].x,y=drawlist[i].y;
if(style==1)
{
SelectObject(hdc,black);
MoveToEx(hdc,x,y-3,NULL);
LineTo(hdc,x+3,y);
LineTo(hdc,x,y+3);
LineTo(hdc,x-3,y);
LineTo(hdc,x,y-3);
}
else if(style==2){
SelectObject(hdc,red);
Rectangle(hdc,x-10,y-15,x+10,y+15);
}
}
Sleep(10);
}
}
void bullet(int u){
while(drawlist[u].y>=10){
drawlist[u].y-=10;
Sleep(1);
}
del(u);
}
int main()
{
CONSOLE_CURSOR_INFO d;
GetConsoleCursorInfo(Out,&d);
d.bVisible=false;
SetConsoleCursorInfo(Out,&d);
thread GetC(Cursor);
thread print(draw);
while(1)
{
char s=getch();
if(s=='z'){
drawlist.push_back({Cx,Cy,1});
int *p=&drawlist[drawlist.size()-1].y;
thread b(bullet,drawlist.size()-1);
b.detach();
}
Sleep(100);
}
return 0;
}