C++ [项目] 愤怒的小鸟

现在才发现C++游戏的支持率这么高,那就发几篇吧

零、前情提要

此篇为

制作,由于他没有CSDN,于是由我代发

一、基本介绍

        支持Dev-C++5.11版本(务必调为英文输入法),基本操作看游戏里的介绍,怎么做的……懒得说,能看懂就看注释,没有的自己猜,如果你很固执……私我吧

二、代码部分

#include <bits/stdc++.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
using namespace std;
const double pi = 3.1415926536;
int toint (float a) {return ((int) (a * 10 + 5)) / 10;
}
void Color (int a) {if (a == 0 || a == 14 || a == 20) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);} else if (a == 1 || a == 12) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);} else if (a == 2) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);} else if (a == 3) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);} else if (a == 4 || a == 11) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);} else if (a == 5 || a == 13) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);} else if (a == 7) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_BLUE);} else if (a == 15) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);} else if (a == 16) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_GREEN);} else if (a == 17) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED);} else if (a == 8) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);} else if (a == 6) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);} else if (a == 9) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|BACKGROUND_RED|BACKGROUND_GREEN);}
}
void SetPos (float x, float y) {int xx = toint (x), yy = toint (y);COORD pos;pos.X = yy * 2;pos.Y = xx;SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), pos);
}
struct node {int W, W2, S, mS;float X, Y;float vx, vy;float ax, ay;bool go, boom;
} blt[100001], pig[100001], boo[100001];
int T, yX, yY, Xy, put, K, K2, Sle, What;
int Bot, Pit, Blt, Pig, Sco, pigk, scok;
int m[41][41];
void Cout (int a, int x, int y) {if (a == 1) {SetPos (x, y);Color (5);cout << put << ' ';}if (y == 202) {SetPos (pig[a].X, pig[a].Y);cout << ". ";if ((pig[a].W == 2 || pig[a].W == 3) && pig[a].X >= 2) {SetPos (pig[a].X - 2, pig[a].Y);cout << ". ";SetPos (pig[a].X - 1, pig[a].Y);cout << ". ";} else if (pig[a].W == 4) {SetPos (pig[a].X, pig[a].Y - 1);cout << ". ";} else if(pig[a].W == 5) {SetPos (pig[a].X - 1, pig[a].Y);cout << ". ";SetPos (pig[a].X - 1, pig[a].Y - 1);cout << ". ";}}if (a == 2) {for (int i = 0; i <= 40; i++) {for (int j = 0; j <= 40; j++) {if (i <= 18 && m[i][j] == 1) {SetPos (i, j);Color (7);cout << "■";}if (m[i][j] >= 2 && m[i][j] <= 19) {SetPos (i, j);Color (5);cout << "█";m[i][j]++;}if (m[i][j] > 19 && m[i][j] <= 29) {SetPos (i, j);Color (0);cout << "█";m[i][j]++;if (m[i][j] == 30) {SetPos (i, j);Color (0);cout << "  ";m[i][j] = 0;}if (m[i][j] >= 31 && m[i][j] <= 49) {SetPos (i, j);Color (0);cout << "■";m[i][j]++;}if (m[i][j] == 50) {SetPos (i, j);Color (7);cout << "■";m[i][j] = 1;}}}}}if (y == 666) {SetPos (blt[a].X, blt[a].Y);Color (10 + blt[a].W);cout<<"●";}Color (0);
}
void Go (int a) {SetPos (blt[a].X, blt[a].Y);cout << "..";blt[a].X += blt[a].vx / 2;blt[a].Y += blt[a].vy / 2;blt[a].vx += blt[a].ax / 2;blt[a].vy += blt[a].ay / 2;if (blt[a].X >= 20) {blt[a].X = 19;}if (blt[a].X > 20 || blt[a].Y > 38 || blt[a].X < 0 || blt[a].Y <= 0) {blt[a].go = 1;}if (blt[a].W2 == 1 && blt[a].Y >= Xy) {blt[a].go = 1;Sle = 0;//地跑鸟}if (blt[a].W2 == 0) {for (int i = 0; i <= blt[a].vx / 2 + 1; i++) {if (blt[a].vx > 0 && m[toint (blt[a].X) + i][toint (blt[a].Y)] == 1) {if (blt[a].W != 5) {blt[a].boom = 1;}blt[a].X = toint (blt[a].X) + i - 1;blt[a].Y += blt[a].vy / 2;blt[a].vx = -blt[a].vx * 0.4;blt[a].vy = blt[a].vy * 0.8;if (blt[a].W == 3) {blt[a].ax = 0.5;}if (blt[a].W == 7) {blt[a].vx *= 2;}if (blt[a].W == 10) {blt[a].go = 1;Bot++;boo[Bot].X = blt[a].X;boo[Bot].Y = blt[a].Y;boo[Bot].S = 1;boo[Bot].mS = 4;}}if (blt[a].vx < 0 && m[toint (blt[a].X) - i][toint(blt[a].Y)] == 1) {if (blt[a].W != 5) {blt[a].boom = 1;}blt[a].X = toint (blt[a].X) + i + 1;blt[a].Y += blt[a].vy / 2;blt[a].vx = -blt[a].vx;blt[a].vy=blt[a].vy * 0.8;if (blt[a].W == 3) {blt[a].ax = 0.5;}if (blt[a].W == 7) {blt[a].vx *= 2;}if (blt[a].W == 10) {blt[a].go = 1;Bot++;boo[Bot].X = blt[a].X;boo[Bot].Y = blt[a].Y;boo[Bot].S = 1;boo[Bot].mS = 4;}}}if (abs (blt[a].vx) <= 0.1 && abs (blt[a].vy) <= 0.1 && abs (blt[a].ay) <= 0.1) {blt[a].go = 1;if (blt[a].W == 5) {Bot++;boo[Bot].X = blt[a].X;boo[Bot].Y = blt[a].Y;boo[Bot].S = 1;boo[Bot].mS = 4;blt[a].go = 1;}}}if (blt[a].go == 0) {Cout (a, 0, 666);}
}
void Kill (int a) {if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {Cout (a, 202, 202);pig[a].Y = 16;}if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) {pig[a].W = 1;}int R = rand () % 50;Cout (a, 202, 202);//清除猪猪pig[a].X += pig[a].vx / 2;pig[a].Y += pig[a].vy / 2;pig[a].vx += pig[a].ax / 2;pig[a].vy += pig[a].ay / 2;for (int i = -2; i <= pig[a].vx / 2 + 1; i++) {if (m[toint (pig[a].X) + i][toint (pig[a].Y)] == 1) {pig[a].X = toint (pig[a].X) + i - 1;pig[a].Y += pig[a].vy / 2;pig[a].vx = -pig[a].vx * 0.5;pig[a].vy = pig[a].vy * 0.8;}}for (int i = Blt - 10; i <= Blt; i++) {if (pig[a].W == 5 && blt[i].go == 0 && abs (pig[a].X - blt[i].X) <= 1&& abs (pig[a].Y - blt[i].Y) <= 1) {m[toint (pig[a].X) - 1][toint (pig[a].Y)] = 2;pig[a].W2++;Sco += 2;break;}if (pig[a].W == 5 && m[toint (pig[a].X)][toint (pig[a].Y)] >= 2 &&m[toint (pig[a].X)][toint (pig[a].Y)] < 30) {m[toint (pig[a].X) - 1][toint (pig[a].Y)] = 2;pig[a].W2++;Sco += 2;break;}if (blt[i].go == 0 && abs (pig[a].X - blt[i].X) <= 1 && abs (pig[a].Y - blt[i].Y) <= 1) {if (pig[a].W == 6) {Bot++;boo[Bot].X = pig[a].X;boo[Bot].Y = pig[a].Y;boo[Bot].S = 1;boo[Bot].mS = 4;blt[i].go = 1;}m[toint (pig[a].X)][toint (pig[a].Y)] = 2;pig[a].go = 1;Pig--;Sco+=10;break;}if (m[toint (pig[a].X)][toint (pig[a].Y)] >= 2 &&m[toint (pig[a].X)][toint (pig[a].Y)] < 30) {if (pig[a].W == 6) {Bot++;boo[Bot].X = pig[a].X;boo[Bot].Y = pig[a].Y;boo[Bot].S = 1;boo[Bot].mS = 4;}pig[a].go = 1;Pig--;Sco += 10;break;}if ((pig[a].W == 2 || pig[a].W == 3) && blt[i].go == 0 &&abs (pig[a].X - 2 - blt[i].X) <= 1 && abs (pig[a].Y - blt[i].Y) <= 1) {m[toint (pig[a].X)][toint (pig[a].Y)] = 2;pig[a].go = 1;Pig--;Sco += 10;break;}if ((pig[a].W == 2 || pig[a].W == 3) &&m[toint (pig[a].X - 2)][toint (pig[a].Y)] >= 2&& m[toint (pig[a].X - 2)][toint (pig[a].Y)] < 30) {pig[a].go = 1;Pig--;Sco += 10;break;}}//弄死猪猪if (pig[a].go == 0) {if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {Cout (a, 202, 202);pig[a].Y = 16;}if (pig[a].go == 0 && pig[a].W == 4 &&pig[a].Y < 20) {pig[a].W = 1;}int Xx = toint (pig[a].X), Xy = toint (pig[a].Y);if (pig[a].W == 6) {SetPos (pig[a].X, pig[a].Y);Color (9);cout << "C4";Color (0);} else {SetPos (pig[a].X, pig[a].Y);Color (2);cout << "●";if ((pig[a].W == 2 || pig[a].W == 3) && pig[a].X >= 2) {SetPos (pig[a].X - 2, pig[a].Y);Color (0);cout << "○";SetPos (pig[a].X - 1, pig[a].Y);cout << "|";} else if (pig[a].W == 4) {SetPos (pig[a].X, pig[a].Y - 1);Color (2);cout << "﹃";} else if (pig[a].W == 5) {SetPos (pig[a].X - 1, pig[a].Y);Color (8);SetPos (pig[a].X - 1, pig[a].Y - 1);cout << "▁";if (pig[a].W2 == 0) {cout << "▅";} else if (pig[a].W2 == 1) {cout << "▃";} else if (pig[a].W2 == 2) {cout << "▂";} else if (pig[a].W2 == 3) {pig[a].W = 1;pig[a].W2 = 0;SetPos (pig[a].X - 1, pig[a].Y - 1);cout << "  ";}}}//输出猪猪if (pig[a].W == 2 && pig[a].X > pig[a].S) {pig[a].W = 3;pig[a].ax = -0.4;pig[a].vx = 1.5;} else if (pig[a].W == 3 && pig[a].X <= pig[a].S) {pig[a].W = 2;pig[a].ax = 0.4;pig[a].vx = -1.5;}if ((pig[a].W == 2 || pig[a].W == 3) && (pig[a].Y <= 10 || pig[a].Y >= 38)) {pig[a].vy *= -1;}if (pig[a].W == 4 && R == 0 && pig[a].X == 20) {pig[a].vx = -((rand () % 40) / 10);}if(pig[a].W == 4) {int r = rand () % 20;for (int i = Blt - 10; i <= Blt; i++) {if (r <= 5 && blt[i].go == 0 && pig[a].Y - blt[i].Y <= 5 &&abs (blt[i].X - pig[a].X) <= 1.5 && r < 5) {r = 0;break;}}if (r == 0) {m[toint (pig[a].X)][toint (pig[a].Y) - 2] = 10;m[toint (pig[a].X)][toint (pig[a].Y) - 3] = 2;for (int j = toint (pig[a].Y) - 1; j >= toint (pig[a].Y) - 5; j--) {for (int i = Blt - 10; i <= Blt; i++) {if (blt[i].go == 0 && !(blt[i].W == 3 && blt[i].boom == 1)&& blt[i].W2 == 0 && toint (blt[i].Y) == j&& abs (blt[i].X - pig[a].X) <= 2) {blt[i].vy = -2;}}for (int i = Pit - 50; i <= Pit; i++) {if (pig[i].go == 0 && toint (pig[i].Y) == j && abs (pig[i].X - pig[a].X) <= 2) {pig[i].vy = -1;}}}}}//移动猪猪if (pig[a].go == 0 && pig[a].W != 2 && pig[a].W != 3 && pig[a].Y < 16) {Cout (a, 202, 202);pig[a].Y = 16;}if (pig[a].go == 0 && pig[a].W == 4 && pig[a].Y < 20) {pig[a].W = 1;}if (pig[a].X > 20 || pig[a].Y > 38 || pig[a].X < 0 || pig[a].Y <= 0) {pig[a].go = 1;Pig--;Cout (a, 202, 202);}//清除猪猪}
}
void Creat (int a, int p) {if (a == -1 && p == -1) {Blt++;blt[Blt].W = What;blt[Blt].W2 = 1;blt[Blt].vy = 1;blt[Blt].X = 19;blt[Blt].Y = 0;blt[Blt].boom = 1;} else if (a == 0 && p == -1) {int u = rand () % 7 + 1, U = rand() % 30;if (u >= 5) {Pit++;pig[Pit].Y = rand () % 15 + 20;pig[Pit].X = 2;pig[Pit].ax = 0.5;pig[Pit].W = 1;} else if (u == 1) {Pit++;pig[Pit].Y = rand () % 15 + 20;pig[Pit].X = 2;pig[Pit].vy = 0.5;pig[Pit].ax = 0.5;pig[Pit].S = rand () % 5 + 7;pig[Pit].W = 2;} else if (u == 2) {Pit++;pig[Pit].Y = rand () % 15 + 20;pig[Pit].X = 2;pig[Pit].ax = 0.5;pig[Pit].W = 4;} else if (u == 3) {Pit++;pig[Pit].Y = rand () % 15 + 20;pig[Pit].X = 2;pig[Pit].ax = 0.5;pig[Pit].W = 5;} else if (u == 4) {Pit++;pig[Pit].Y = rand () % 15 + 20;pig[Pit].X = 2;pig[Pit].ax = 0.5;pig[Pit].W = 6;}if (U == 1) {Bot++;boo[Bot].Y = rand () % 13 + 15;boo[Bot].X = (rand () % 4) * 3 + 8;boo[Bot].S = 0;boo[Bot].mS = rand () % 2 + 2;boo[Bot].W2 = 1;}} else {Blt++;blt[Blt].W = What;if (a == 1) {blt[Blt].X = yX;blt[Blt].Y = yY;blt[Blt].ax = 0.5; //抛物线}blt[Blt].vx = -3.5 * sin (p * pi / 180);blt[Blt].vy = 3 * cos (p * pi / 180);if (p <= 45) {blt[Blt].vy *= 1 + (0.33 - 0.01 * (45 - p));}if (p >= 45) {blt[Blt].vy *= 1 + (0.33 - 0.01 * (p - 45));}if (blt[Blt].W == 6) {blt[Blt].vy *= 1.2;blt[Blt].ax = 0.4;}}
}
void Boom (int a) {if (boo[a].W2 == 0) {int ms = boo[a].mS, s = boo[a].S, x = boo[a].X, y = boo[a].Y;if (s == ms) {return ;}for (int i = x - s; i <= x + s; i++) {for (int j = y - s; j <= y + s; j++) {float k = (i - x) * (i - x) + (j - y) * (j - y) - s * s;if (k <= s && k >= -s && i <= 20 && j <= 38 && i >= 0 && j > 0 && m[i][j] != 1) {m[i][j] = 2;}}}boo[a].S++;}if (boo[a].W2 == 1) {int ms = boo[a].mS, s = boo[a].S, x = boo[a].X, y = boo[a].Y;if (s == ms) {return ;}if (y - s > 10) {m[x][y-s] = 31 - 31 * (boo[a].W2 - 1);}if (y + s < 40) {m[x][y+s] = 31 - 31 * (boo[a].W2 - 1);}boo[a].S++;}
}
void Move (int a) {Color (5);if (a == -2) {SetPos (17, Xy);cout << "        ";SetPos (18, Xy);cout << "        ";SetPos (19, Xy);cout << "        ";SetPos (20, Xy);cout << "       ";}if (a == -1) {SetPos (17, Xy);cout << "        ";SetPos (18, Xy);cout << "  ┃  ┃";SetPos (19, Xy);cout << "  ╰┳╯";SetPos (20, Xy);cout << "     ▏";}if (a == 0) {SetPos (18, Xy);cout << "  ┃";Color (What + 10);cout << "●";Color (5);cout << "┃";SetPos (19, Xy);cout << "  ╰┳╯";SetPos (20, Xy);cout << "     ▏";}if (a == 1) {SetPos (18, Xy);cout << "  ";Color (What + 10);cout << "●";Color (5);cout << "  ┃";SetPos (19, Xy);cout << "  ╰┳╯";SetPos (20, Xy);cout << "     ▏";}if (a == 2) {SetPos (18, Xy);Color (What + 10);cout << "●";Color (5);cout << "┃  ┃";SetPos (19, Xy);cout << "  ╰┳╯";SetPos (20, Xy);cout << "     ▏";}if (a == 3) {SetPos (18, Xy);cout << "  ┃  ┃";SetPos (19, Xy);Color (What + 10);cout << "●";Color (5);cout << "╰┳╯";SetPos (20, Xy);cout << "     ▏";}if (a == 4) {SetPos (18, Xy);cout << "  ┃  ┃";SetPos (19, Xy);cout << "  ╰┳╯";SetPos (20, Xy);Color (What + 10);cout << "●";Color (5);cout << "   ▏";}if (a == 5) {SetPos (18, Xy);cout << "  ┃  ┃";SetPos (19, Xy);cout << "  ╰┳╯";SetPos (20, Xy);cout << "  ";Color (What + 10);cout << "●";Color (5);cout << " ▏";}if (a == 6) {SetPos (18, Xy);cout << "  ┃  ┃";SetPos (19, Xy);cout << "  ╰┳╯";SetPos (20, Xy);cout << "    ";Color (What + 10);cout << "●";Color (5);cout << " ";}Color (0);
}
void Start () {char g;Color (5);system ("cls");SetPos (1, 1);cout << "------- 愤 怒 的 小 鸟 -------";Color (0);SetPos (3, 1);cout << "空格瞄准,按X触发小鸟技能,←→移动弹弓";SetPos (5, 1);cout << "猪猪技能自动触发,空中会有墙出现。";SetPos (7, 1);cout << "危险值由命中率,猪的存活时间计算!";SetPos (9, 1);cout << "危险值点满后失败!1500分通关!";SetPos (1, 20);cout << "-------- 小 鸟 技 能 --------";SetPos (3, 20);Color (11);cout << "●";Color (0);cout << ":无技能";SetPos (5, 20);Color (12);cout << "●";Color (0);cout << ":分身!不同分身初速度大小相同,";SetPos(6,20);cout<<"        方向不同。";SetPos (7, 20);Color (13);cout << "●";Color (0);cout << ":加速!以当前速度做匀速直线运动,";SetPos (8, 20);cout << "          且免疫狙击猪的冲击。";SetPos (9, 20);Color (14);cout << "●";Color (0);cout << ":投蛋!并获得向上速度做匀速直线";SetPos (10, 20);cout << "          运动,快达可以穿墙。";SetPos (11, 20);Color (15);cout << "●";Color (0);cout << ":爆炸!";SetPos (13, 20);Color (16);cout << "●";Color (0);cout << ":回旋!开始做向左加速运动!发射";SetPos (14, 20);cout << "          时获得双倍水平速度。";SetPos (15, 20);Color (17);cout << "●";Color (0);cout << ":[被动] 弹跳力为普通鸟三倍。发射";SetPos (16, 20);cout << "          时获得1.5倍水平、竖直速度。";SetPos (11, 1);cout << "-------- 猪 猪 技 能 --------";SetPos (13, 2);Color (2);cout << "●";Color (0);cout << ":无技能";SetPos (14, 1);Color (8);cout << "▁▅";SetPos (15, 2);Color (2);cout << "●";Color (0);cout << ":防御力为普通猪三倍";SetPos (16, 2);cout << "○";SetPos (17, 2);cout << "│:做空中简谐运动,受死范围";SetPos (18, 2);Color (2);cout << "●";Color (0);cout << "  为普通猪两倍。";SetPos (19, 2);cout << "    有几率跳起或发射冲击波,冲";SetPos (20, 1);Color (2);cout << "﹃●";Color (0);cout << ":开小鸟与同类,可以引爆TNT!";SetPos (18, 20);Color (5);cout << "按 y 开始游戏!";
A:if (kbhit ()) {g = _getch ();}if(g != 'y') {goto A;}
}
int main () {system ("mode con cols=79 lines=22");CONSOLE_CURSOR_INFO cursor_info = {1, 0};SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cursor_info);srand ((unsigned)time(NULL));St:Start ();system ("cls");memset (blt, 0, sizeof (blt));memset (pig, 0, sizeof (pig));memset (boo, 0, sizeof (boo));memset (m, 0, sizeof (m));T = put = K = K2 = Sle = What = Pig = Sco = 0;pigk = scok = -1;Xy = 4;yX = 18;yY = 6;Blt = 20;Bot = 20;Pit = 60;Color (7);SetPos (19, 14);cout << "■";SetPos (20, 13);cout << " █▍";m[19][14] = m[20][13] = m[20][14] = 1;SetPos (21, 0);for (int i = 0; i < 39; i++) {cout << "■";m[21][i] = 1;}Color (0);What = rand () % 5 + 1;while (1) {if (Sco >= 1500) {break;}T++;K = 0;Color (0);if (Sco != scok) {SetPos (1, 1);cout << "分数:" << Sco << ' ';}if (Pig != pigk) {SetPos (3, 1);cout << "危险值:";int aa = min (Sco / 100, 10);Pig += aa;SetPos (3, 5);if (Pig <= 2) {Color (2);} else if (Pig <= 4) {Color (16);} else if (Pig <= 6) {Color (7);} else if (Pig <= 9) {Color (6);} else if (Pig <= 12) {Color (3);} else if (Pig <= 15) {Color (17);} else {Color (11);}for (int i = 1; i <= Pig; i++) {cout << "■";}Color (0);cout << ' ' << Pig;for (int i = 1; i <= 5; i++) {cout << "  ";}if (Pig > 18) {break;}Pig -= aa;}scok = Sco;pigk = Pig;if (GetAsyncKeyState (VK_LEFT)&0x8000 && Xy > 0) {Move (-2);Xy--;K = 1;}if (GetAsyncKeyState (VK_RIGHT)&0x8000 && Xy < 10) {Move (-2);Xy++;K = 1;}if (K == 1) {if (put == 0 && Sle == 0) {Move (0);} else {Move (-1);}}if (kbhit ()) {char g = _getch ();if (g == 'x' || g == 'X') {for (int i = Blt - 10; i <= Blt; i++) {if (blt[i].go == 0 && blt[i].boom == 0 && blt[i].W != 1 && blt[i].W != 7) {blt[i].boom = 1;if (blt[i].W == 2) {Blt++;blt[Blt].W = 2;blt[Blt].vy = blt[i].vy * 1.2;blt[Blt].vx = blt[i].vx + 1;blt[Blt].ax = blt[i].ax;blt[Blt].X = blt[i].X;blt[Blt].Y = blt[i].Y;blt[Blt].boom = 1;Blt++;blt[Blt].W = 2;blt[Blt].vy = blt[i].vy * 0.7;blt[Blt].vx = blt[i].vx - 1;blt[Blt].ax = blt[i].ax;blt[Blt].X = blt[i].X;blt[Blt].Y = blt[i].Y;blt[Blt].boom = 1;}if (blt[i].W == 3) {blt[i].vy = fmax (blt[i].vy * 1.5, 2.5);blt[Blt].vx++;blt[i].ax = 0;}if (blt[i].W == 4) {blt[i].vx = -3;blt[i].ax = 0.1;Blt++;blt[Blt].boom = 1;blt[Blt].W = 10;blt[Blt].X = blt[i].X;blt[Blt].Y = blt[i].Y;blt[Blt].ax = blt[i].ax;blt[Blt].vx = 1;}if (blt[i].W == 5) {Bot++;boo[Bot].X = blt[i].X;boo[Bot].Y = blt[i].Y;boo[Bot].S = 1;boo[Bot].mS = 5;blt[i].go = 1;}if (blt[i].W == 6) {blt[i].ay = -1;blt[i].ax = 0.3;blt[i].vx = min (blt[i].vx / 2, (float)0);}break;}}}}if (GetAsyncKeyState (' ')&0x8000 && K == 0 && Sle == 0) {if (put <= 5) {Move (1);yX = 18;yY = Xy + 1;} else if (put <= 20) {Move (2);yX = 18;yY = Xy;} else if (put <= 40) {Move (3);yX = 19;yY = Xy;} else if (put <= 60) {Move (4);yX = 20;yY = Xy;} else if (put <= 80) {Move (5);yX = 20;yY = Xy + 1;} else {Move (6);yX = 20;yY = Xy + 2;}if (put == 0) {K2 = 1;}if (put == 90) {K2 = -1;}if (K2 == 1) {put += min (rand () % 7 + 1, 90 - put);}if (K2 == -1) {put-=min(rand()%7+1,put);}Cout (1, 17, Xy + 2);}if ((!(GetAsyncKeyState (' ')&0x8000) && (put != 0)) || (put != 0 && K == 1)) {Move (-1);Creat (1, put);put = 0;yX = 18;yY = 5;Sle = 1;What = rand () % 7 + 1;Creat (-1, -1);Sco = max (Sco - 5, 0);}for (int i = Blt - 10; i <= Blt; i++) {if (blt[i].go == 0) {Go (i);}}for (int i = Bot - 10; i <= Bot; i++) {if (boo[i].go == 0) {Boom (i);Cout (2, 0, 0);}}for (int i = Pit - 50; i <= Pit; i++) {if (pig[i].go == 0) {Kill (i);}}if (Sle != 0) {Move (-1);} else if (put == 0) {Move (0);}if (T % 300 == 0) {system ("cls");pigk = scok = -1;}if (T % 100 == 0) {Color (7);for (int i = 0; i <= 18; i++) {for (int j = 0; j <= 40; j++) {if (m[i][j] == 1 && T % 100 == 0) {SetPos (i, j);cout << "■";}}}SetPos (19, 14);cout << "■";SetPos (20, 13);cout <<" █▍";SetPos (21, 0);for (int i = 0; i < 39; i++) {cout << "■";Color (0);}}if (T % min (50, (2000 - Sco) / 30) == 0) {Pig++;Creat (0, -1);}Sleep (15);}if (Sco < 500) {if (MessageBox (NULL, "很遗憾,您输了,您还想再来一次吗?", "温馨提示", MB_YESNO) == IDYES) {goto St;} else {return 0;}} else {if (MessageBox (NULL, "恭喜您赢了!您还想再来一次吗?", "温馨提示", MB_YESNO) == IDYES) {goto St;} else {return 0;}}return 0;
}

如果觉得不错就点个赞吧

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/456780.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Oracle SQL Developer 同时打开多个table的设置

Oracle SQL Developer 同时打开多个table的设置 工具 》 首选项 》数据库 》对象查看器&#xff0c;勾选 “自动冻结对象查看器窗口”

数据结构------手撕顺序表

文章目录 线性表顺序表的使用及其内部方法ArrayList 的扩容机制顺序表的几种遍历方式顺序表的优缺点顺序表的模拟实现洗牌算法 线性表 线性表&#xff08;linear list&#xff09;是n个具有相同特性的数据元素的有限序列。 线性表是一种在实际中广泛使用的数据结构&#xff0c;…

TLS协议基本原理与Wireshark分析

01背 景 随着车联网的迅猛发展&#xff0c;汽车已经不再是传统的机械交通工具&#xff0c;而是智能化、互联化的移动终端。然而&#xff0c;随之而来的是对车辆通信安全的日益严峻的威胁。在车联网生态系统中&#xff0c;车辆通过无线网络与其他车辆、基础设施以及云端服务进行…

Lucas带你手撕机器学习——套索回归

好的&#xff0c;下面我将详细介绍套索回归的背景、理论基础、实现细节以及在实践中的应用&#xff0c;同时还会讨论其优缺点和一些常见问题。 套索回归&#xff08;Lasso Regression&#xff09; 1. 背景与动机 在机器学习和统计学中&#xff0c;模型的复杂性通常会影响其在…

【云原生】Kubernets1.29部署StorageClass-NFS作为存储类,动态创建pvc(已存在NFS服务端)

文章目录 在写redis集群搭建的时候,有提到过使用nfs做storageclass,那时候kubernetes是1.20版本,https://dongweizhen.blog.csdn.net/article/details/130651727 现在使用的是kubernetes 1.29版本,根据之前的修改方式并未生效,反而提示:Error: invalid argument "Re…

Claude Financial Data Analyst:基于Claude的金融数据分析工具!免费开源!

大家好&#xff0c;我是木易&#xff0c;一个持续关注AI领域的互联网技术产品经理&#xff0c;国内Top2本科&#xff0c;美国Top10 CS研究生&#xff0c;MBA。我坚信AI是普通人变强的“外挂”&#xff0c;专注于分享AI全维度知识&#xff0c;包括但不限于AI科普&#xff0c;AI工…

智创 AI 新视界 -- 探秘 AIGC 中的生成对抗网络(GAN)应用

&#x1f496;&#x1f496;&#x1f496;亲爱的朋友们&#xff0c;热烈欢迎你们来到 青云交的博客&#xff01;能与你们在此邂逅&#xff0c;我满心欢喜&#xff0c;深感无比荣幸。在这个瞬息万变的时代&#xff0c;我们每个人都在苦苦追寻一处能让心灵安然栖息的港湾。而 我的…

【算法设计与分析】-回溯法的回忆-学习【期末复习篇章】

引言 简单说,迷宫问题的求解方法就是走的通就走&#xff0c;走不通 就回头寻找另外的路径的一种满足某约束条件的穷举式 搜索技术 回溯法是一种在解空间中搜索可行解或最优解的方法。 该方法通常将解空间看做树形结构&#xff0c;即状态空间树。从根结 点开始,以深度优先对状态…

李沐读论文-启发点记录2:Resnet--残差连接--kaiming老师神作

&#xff08;一&#xff09;可以借鉴&#xff1a; 1. 计算机视觉的论文&#xff0c;都会在第一页的右上角&#xff0c;放上一张好看的图&#xff01; 2.bottleNet的设计——很大程度上节省了计算FLOPs开销&#xff0c;这是Resnet50及其更大版本都会用到的设计。 3.Resnet在de…

[RK3566-Android11] 使用SPI方式点LED灯带-JE2815/WS2812,实现呼吸/渐变/随音量变化等效果

问题描述 之前写了一篇使用GPIO方式点亮LED灯带的文章 https://blog.csdn.net/jay547063443/article/details/134688745?fromshareblogdetail&sharetypeblogdetail&sharerId134688745&sharereferPC&sharesourcejay547063443&sharefromfrom_link 使用GPIO…

OceanBase 首席科学家阳振坤:大模型时代的数据库思考

2024年 OceanBase 年度大会 即将于10月23日&#xff0c;在北京举行。 欢迎到现场了解更多“SQL AI ” 的探讨与分享&#xff01; 近期&#xff0c;2024年金融业数据库技术大会在北京圆满举行&#xff0c;聚焦“大模型时代下数据库的创新发展”议题&#xff0c;汇聚了国内外众多…

详细尝鲜flutter

flutter 161由于官方的汉化文档感觉还是有很多没有汉化的地方 &#xff0c;所以自己打一遍的同时写下了以下笔记 社区生态 官方文档 所有的控件:Widget 目录 | Flutter 中文文档 - Flutter 中文开发者网站 - Flutter 官方论坛的教程 Flutter Widget框架概述 - Flutter中文网…

微信小程序中关闭默认的 `navigationBar`,并使用自定义的 `nav-bar` 组件

要在微信小程序中关闭默认的 navigationBar&#xff0c;并使用自定义的 nav-bar 组件&#xff0c;你可以按照以下步骤操作&#xff1a; 1. 关闭默认的 navigationBar 在你的页面的配置文件 *.json 中设置 navigationBar 为 false。你需要在页面的 JSON 配置文件中添加以下代码…

JS 中 reduce()方法及使用

摘要&#xff1a; 开发中经常会遇到求合计的状况&#xff01;比如和&#xff0c;积等&#xff01;这次遇到的是求合计的和&#xff01; reduce()方法是JavaScript中Array对象的一种高阶函数&#xff0c;用于对数组中的每个元素执行一个由您提供的reducer函数&#xff08;回调函…

内置数据类型、变量名、字符串、数字及其运算、数字的处理、类型转换

内置数据类型 python中的内置数据类型包括&#xff1a;整数、浮点数、布尔类型&#xff08;以大写字母开头&#xff09;、字符串 变量名 命名变量要见名知意&#xff0c;确保变量名称具有描述性和意义&#xff0c;这样可以使得代码更容易维护&#xff0c;使用_可以使得变量名…

STM32-Modbus协议(一文通)

Modbus协议原理 RT-Thread官网开源modbus RT-Thread官方提供 FreeModbus开源。 野火有移植的例程。 QT经常用 libModbus库。 Modbus是什么&#xff1f; Modbus协议&#xff0c;从字面理解它包括Mod和Bus两部分&#xff0c;首先它是一种bus&#xff0c;即总线协议&#xff0c;和…

学习threejs,利用THREE.ExtrudeGeometry拉伸几何体实现svg的拉伸

&#x1f468;‍⚕️ 主页&#xff1a; gis分享者 &#x1f468;‍⚕️ 感谢各位大佬 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! &#x1f468;‍⚕️ 收录于专栏&#xff1a;threejs gis工程师 文章目录 一、&#x1f340;前言1.1 ☘️THREE.ExtrudeGeometry拉伸…

通过ssh端口反向通道建立并实现linux系统的xrdp以及web访问

Content 1 问题描述2 原因分析3 解决办法3.1 安装x11以及gnome桌面环境查看是否安装x11否则使用下面指令安装x11组件查看是否安装gnome否则使用下面指令安装gnome桌面环境 3.2 安装xrdp使用下面指令安装xrdp&#xff08;如果安装了则跳过&#xff09;启动xrdp服务 3.3 远程服务…

C2W4.LAB.Word_Embedding.Part1

理论课&#xff1a;C2W4.Word Embeddings with Neural Networks 文章目录 Word Embeddings First Steps: Data PreparationCleaning and tokenizationSliding window of wordsTransforming words into vectors for the training setMapping words to indices and indices to w…

七,Linux基础环境搭建(CentOS7)- 安装Scala和Spark

Linux基础环境搭建&#xff08;CentOS7&#xff09;- 安装Scala和Spark 大家注意以下的环境搭建版本号&#xff0c;如果版本不匹配有可能出现问题&#xff01; 一、Scala下载及安装 Scala是一门多范式的编程语言&#xff0c;一种类似java的编程语言&#xff0c;设计初衷是实现…