代码
#include <bits/stdc++.h>
#include <windows.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
HANDLE han = GetStdHandle(-11);
void hide(),printstr(char *buf, int startY, int startX),color(int a),Start(),Zhuym(),ksyx();
void hide(){
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible = 0;
cursor.dwSize = 1;
SetConsoleCursorInfo(han,&cursor);
}
void printstr(char *buf, int startY, int startX)
{
HANDLE hd;
COORD pos;
pos.X = startX;
pos.Y = startY;
hd = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hd, pos);
cout<<buf;
}
void color(int a){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void Start()
{
system("mode con cols=71 lines=30");
hide();
cout<<"loading.......\n";
for (int i=1;i<=71;i++)cout<<"-",Sleep(100);
system("cls");
system("color FF");
system("color FF");
color(255);
for (int i=1;i<=71*30;i++)cout<<' ';
system("color FF");
Sleep(1000);
printstr("■■■ ■ ■■■ ■■■ ■ ■ ■■■",10,12);
printstr("■ ■ ■ ■ ■ ■ ■ ■ ",11,11);
printstr("■ ■■■ ■ ■■■ ■ ■■■",12,10);
printstr("■ ■ ■ ■ ■ ■ ■ ■ ",13,9);
printstr("■■■ ■ ■ ■ ■ ■■■ ■ ■ ■■■",14,8);
Sleep(3000);
system("color F7");
Sleep(250);
system("color F8");
Sleep(250);
system("color F0");
Sleep(1500);
printstr("抵制不良游戏,拒绝盗版游戏。注意自我保护,谨防受骗上当。\n适度游戏益脑,沉迷游戏伤身。合理安排时间,享受健康生活。",26,0);
Sleep(2000);
}
HWND h=GetForegroundWindow();
void Zhuym()
{
printstr("■■■ ■ ■■■ ■■■ ■ ■ ■■■",3,12);
printstr("■ ■ ■ ■ ■ ■ ■ ■ ",4,11);
printstr("■ ■■■ ■ ■■■ ■ ■■■",5,10);
printstr("■ ■ ■ ■ ■ ■ ■ ■ ",6,9);
printstr("■■■ ■ ■ ■ ■ ■■■ ■ ■ ■■■",7,8);
Sleep(1000);
color(248);
printstr("┌────────┐",13,25);
printstr("│ 开始游戏 │",14,25);
printstr("└────────┘",15,25);
while(1)
{
POINT p;
GetCursorPos(&p);
ScreenToClient(h,&p);
if (KEY_DOWN(VK_LBUTTON)&&207<=p.x&&p.x<=351&&214<=p.y&&p.y<=245)
{
color(120);
printstr("┌────────┐",13,25);
printstr("│ 开始游戏 │",14,25);
printstr("└────────┘",15,25);
color(248);
while(KEY_DOWN(VK_LBUTTON));
printstr("┌────────┐",13,25);
printstr("│ 开始游戏 │",14,25);
printstr("└────────┘",15,25);
ksyx();
}
Sleep(20);
}
while(1);
}
void ksyx()
{
exit(0);
//待开发……………………;
}
int main()
{
Start();
system("cls");
Zhuym();
}
引用
- 在控制台指定位置输出
- (C++)光标的设置与隐藏
- system调整控制台大小的问题
- 【题目讲解】c++怎么判断键盘按下?
- C++ 获取鼠标点击位置