c++俄罗斯方块

//上下左右键控制
#include<bits/stdc++.h>
#include<windows.h>
int a[24][17],i,j,tim=800,ti=800,shape=0,b,bn,ta[4][4],turn[4][4],nex[4][4],nextshape,add=0,score=0,speed=1,ok=1,mouse=0,best=0;
void Place(const int x, const int y)
{
   
COORD PlaceCursorHere;
PlaceCursorHere.X = y;
PlaceCursorHere.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), PlaceCursorHere);
return;
}
void color(int x)
{
   
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
}
void appear()
{
   
for(i=3; i<=22; i++) for(j=1; j<=15; j++) if(a[i][j]!=0)
        {
   
            Place(i-2,2*j);
            printf("■");
        }
}
void disappear()
{
   
for(i=3; i<=22; i++) for(j=1; j<=15; j++) if(a[i][j]==2)
        {
   
            Place(i-2,2*j);
            printf(" ");
        }
}
int search(int x0,int y0,int x,int y)
{
   
POINT pt;
HWND h=GetForegroundWindow();
GetCursorPos(&pt);
ScreenToClient(h,&pt);
if(pt.x>=x0&&pt.y>=y0&&pt.x<=x&&pt.y<=y)
{
   
    if(mouse!=0)
    {
   
        Sleep(100);
        return 2;
    }
    else return 1;
}
else return 0;
}
void button(int x)
{
   
int m=x*10;
if(x<3)
{
   
    Place(22,m);
    printf("┌┄┄┄┐");
    Place(23,m);
    {
   
        if(x==0)
        {
   
            if(ok!=0) printf("┆开始 ┆");
            else printf("┆暂停 ┆");
        }
        if(x==1) printf("┆重置 ┆");
        if(x==2) printf("┆退出 ┆");
    }
    Place(24,m);
    printf("└┄┄┄┘");
}
else
{
   
    Place(9,m-33);
    printf("┌┄┄┐");
    Place(10,m-33);
    {
   
        if(x==4) printf("┆是┆");
        else printf("┆否┆");
    }
    Place(11,m-33);
    printf("└┄┄┘");
}
}
void menu(int x)
{
   
int k,l;
if(x==0)
{
   
    if(ok!=0)
    {
   
        ok=0;
        return;
    }
    else while(1)
        {
   
            mouse=GetAsyncKeyState(VK_LBUTTON);
            Place(9,13);
            printf("暂停");
            if(search(7,360,71,390)==2) break;
            Sleep(50);
        }
    Place(9,12);
    for(j=1; j<=6; j++) printf(" "); //appear();
}
else
{
   
    for(i=1; i<=20; i++) for(j=2; j<=30; j++)
        {
   
            Place(i,j);
            printf(" ");
        }
    Place(7,2);
    for(i=1; i<=15; i++) printf("┄");
    Place(12,2);
    for(i=1; i<=15; i++) printf("┄");
    Place(8,6);
    printf("你想要 ");
    if(x==1) printf("重置?");
    if(x==2) printf("exit?");
    button(4);
    button(5);
    while(1)
    {
   
        mouse=GetAsyncKeyState(VK_LBUTTON);
        for(i=0; i<=1; i++)
        {
   
            k=search(63+i*80,150,
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值