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;
}
如果觉得不错就点个赞吧
相关文章:

C++ [项目] 愤怒的小鸟
现在才发现C游戏的支持率这么高,那就发几篇吧 零、前情提要 此篇为 制作,由于他没有CSDN,于是由我代发 一、基本介绍 支持Dev-C5.11版本(务必调为英文输入法),基本操作看游戏里的介绍,怎么做的……懒得说,能看懂就看注释,没有的自己猜,如果你很固执……私我吧 …...

群控系统服务端开发模式-市场分析
刚刚我把群控系统服务端开发模式的文档全部整理了一下,结果发现还缺市场分析这篇文档没有上传,不好意思啦。 一、前言 在互联网高速发展且稳定的时代,营销系统是自运营公司线上最好的系统。加上现在直播行业很火,引流很重要&#…...

智能听诊器革新宠物健康监测
在宠物健康护理领域,智能听诊器的引入标志着一个新时代的开启,它正成为宠物医疗保健的新宠。这款设备通过高精度传感器捕捉宠物的心跳和呼吸声,为宠物主人和兽医提供精确的健康数据。 智能听诊器的即时反馈功能,使得主人能够通过…...

2000-2023年上市公司绿色专利申请授权面板数据
2000-2023年上市公司绿色专利申请授权面板数据 1、时间:2000-2023年 2、来源:国家知识产权局、WPIO清单 3、指标:年份、股票代码、股票简称、行业名称、行业代码、省份、城市、区县、区县代码、上市状态、绿色专利申请总量、绿色发明专利申…...

vue使用xlsx以及file-saver进行下载xlsx文件以及Unit8Array、ArrayBuffer、charCodeAt的使用
先说Unit8Array、ArrayBuffer、charCodeAt的使用下面会用到这三个 Unit8Array:数组类型表示一个 8 位无符号整型数组,创建时内容被初始化为 0。创建完后,可以以对象的方式或使用数组下标索引的方式引用数组中的元素。 new Uint8Array(); //…...

日语表目的的两个句型,柯桥成人零基础日语培训
句型: (能做动词的)名词(或动词连用形)に来ました(或行きます) 例句: わたしは日本へ文学の勉強に来ました。/我是到日本来学习文学的。 翻译: (我&#…...

小程序中设置可拖动区域
官方说明文档:https://developers.weixin.qq.com/miniprogram/dev/component/movable-area.htmlhttps://developers.weixin.qq.com/miniprogram/dev/component/movable-view.html demo:浮动控件上下移动交互 .wxmx <movable-area><!-- y"…...

前端后台管理开发
1通常项目从头开发,有人是二开,有人是从头,也有人是复制之前人留的。 2通常要自己写就很费时间,多数都是接别人的二手代码继续干,导致很多人没有从头开发的经验,做两三年。 3项目开始一般要选择搭建环境&am…...

GDAL+C#实现矢量多边形转栅格
1. 开发环境测试 参考C#配置GDAL环境,确保GDAL能使用,步骤简述如下: 创建.NET Framework 4.7.2的控制台应用 注意: 项目路径中不要有中文,否则可能报错:can not find proj.db 在NuGet中安装GDAL 3.9.1和G…...

Python 爬虫实战之爬拼多多商品做数据分析
一、项目背景 在电商领域,拼多多作为一家具有广泛影响力的平台,拥有大量的商品信息和用户数据。通过爬取拼多多商品数据并进行分析,可以了解市场趋势、消费者需求以及竞争对手情况,为企业决策和产品优化提供有力支持。 二、技术准…...

爬虫基础
maven pom <dependencies><!--前端jqury--><dependency><groupId>org.jsoup</groupId><artifactId>jsoup</artifactId><version>1.16.1</version></dependency><!--http工具--><dependency><grou…...

HTML3D旋转相册
文章目录 序号目录1HTML满屏跳动的爱心(可写字)2HTML五彩缤纷的爱心3HTML满屏漂浮爱心4HTML情人节快乐...

[linux]快速入门
学习目标 通过学习能够掌握以下的linux操作 操作系统 按照应用领域的不同, 操作系统可以分为几类 桌面操作系统服务器操作系统移动设备操作系统嵌入式操作系统 不同领域的主流操作系统 桌面操作系统 Windows(用户数量最多)MacOS(操作体验好,办公人士首选)Linux…...

域3:安全工程 第6章 密码学与对称密钥算法
---域3主要包括OSG 6、7、8、9、10 章--- 随着信息化时代的推进,网络安全愈发关键。CISSP认证考试中的第6章,专注于密码学与对称密钥算法,这两者是网络安全的核心。 密码学,历经演变,从古代简单的替代密码到现代的复杂…...

MySQL注入load_file常用路径
在MySQL注入攻击中,攻击者可能会尝试利用LOAD_FILE()函数来读取服务器上的敏感文件。LOAD_FILE()函数允许从服务器的文件系统中读取文件,并将其内容作为字符串返回。然而,这个函数需要满足一定的权限条件,并且文件路径必须是服务器…...

ubuntu20.04版本 快速安装 python3.11(宝宝级攻略)
1.前言 深度学习领域中,Python是首选编程语言,因此安装python进行深度学习是必要的,我在安装时踩过了一些坑,就想出一个宝宝级的攻略,希望能够帮助大家。 本宝宝攻略无论是在双系统下还是在虚拟机的环境下均能安装&a…...

DeepSeek AI 推出 Janus 自回归框架,统一视觉、文本理解与生成的创新解决方案
❤️ 如果你也关注大模型与 AI 的发展现状,且对大模型应用开发非常感兴趣,我会快速跟你分享最新的感兴趣的 AI 应用和热点信息,也会不定期分享自己的想法和开源实例,欢迎关注我哦! 🥦 微信公众号ÿ…...

NORDIC nPM1100 是一款集成式电源管理
nPM1100 是一款集成式电源管理IC(PMIC),采用2.1x2.1毫米WLCSP或4.0x4.0 毫米 QFN 封装 ,内置线性模式锂离子/锂聚合物电池充电器。它采用高效DC/DC降压调节器,具有可配置的双模式 输出。 nPM1100是一款极其紧凑的PMIC器件,专为空间…...

深入RAG:知识密集型NLP任务的解决方案
在当今知识密集型任务日益增多的时代,如何有效地利用外部知识来增强语言模型的生成能力成为了一个重要的研究方向。RAG技术应运而生,通过从外部记忆源中检索相关信息,RAG不仅提高了模型生成的精准性和相关性,还解决了大型语言模型…...

vue-element-admin顶部导航栏的修改
基于vue-element-admin的顶部一级导航栏的调整,因为一级路由过多导致其他元素被挤到第二行,故现在将原来一级路由数组拆分成两个数组,第二个数组以子菜单显示 关键处调整代码 html <el-menu:active-text-color"variables.menuActiv…...

微信小程序 setData数据量过大的解决与分页加载的实现
我们经常使用setData方法来修改数据,从而达到更新页面的目的。但是当我们通过setData方法设置的数据过大时就会报如下错误。 vdSyncBatch 数据传输长度为 2260792 已经超过最大长度 1048576这是因为setData设置的数据量是有限制的,单次设置的数据大小不…...

体育动画直播嵌入方式以及作用
什么是体育动画直播? 体育动画直播是通过动画技术和实时数据,将体育赛事的进程以动态的方式展现出来。这种形式不仅可以实时呈现比赛的关键时刻,还能够将数据和信息以更生动、有趣的方式传达给观众。比如,在一场足球比赛中&#…...

腾讯云轻量服务器Lighthouse的前世今生
目录 序一、名字的由来二、Lighthouse的定位是什么,与CVM的差异化有哪些三、Lighthouse是如何实现简单易用的四、Lighthouse对于开发者有哪些具体的利好 序 印象中,腾讯云轻量应用服务器Lighthouse是在2020年正式上线的。 在其一经推出后,就…...

java实现redis的消息发送和消费,类似kafka功能
确保在 pom.xml 中添加了 Spring Data Redis 和 Jedis 的依赖。如下所示:<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency&g…...

【软件设计】常用设计模式--代理模式
文章目录 代理模式(Proxy Pattern)1. 概念2. 模式结构3. UML 类图4.实现方式C# 示例步骤1:定义主题接口步骤2:实现真实主题步骤3:实现代理类步骤4:客户端使用代理模式输出结果: Java 示例步骤1&…...

生命与自由,抑郁的来源
在中国文学史上,有一句极其伟大的话,它点出了所有人痛苦的根源。它出自《我与地坛》,太阳它每时每刻即是夕阳也都是旭日,当他从这一段熄灭着走下山去,收尽苍凉参照之际,也正是它在另一端燃烧着爬上山巅布散…...

CTFHUB技能树之文件上传——双写后缀
开启靶场,打开链接: 直接指明是双写绕过方法 上传06shaungxie.php,内容如下: 这一步其实最好换成.png或者.jpg或者.gif这三个符合文件格式的要求后缀 用burp抓包改包: 将php改成pphphp后再“Forward”: 上传…...

SpringBoot整合HTTPS
文章目录 1_Https 的作用2_获取证书3_配置项4_配置类5_控制类6_启动类 1_Https 的作用 保护用户的隐私信息安全: 在 HTTP 网站数据以明文方式传输,客户的隐私极容易被盗取和泄露,而部署 SSL 证书,数据以 HTTPS 加密传输…...

LVGL-从入门到熟练使用
LVGL简介 LVGL( Light and Versatile Graphics Library )是一个轻量、多功能的开源图形库。 1、丰富且强大的模块化图形组件:按钮 、图表 、列表、滑动条、图片等 2、高级的图形引擎:动画、抗锯齿、透明度、平滑滚动、图层混合等…...

【MySQL数据库】MySQL读写分离
文章目录 读写分离概念读写分离的动机读写分离的适用场景主从复制与读写分离MySQL 读写分离原理MySQL读写分离的实现方式代表性程序 MySQL读写分离实验搭建 MySQL 读写分离Amoeba 服务器配置测试读写分离 问答 读写分离 概念 读写分离是为了优化数据库性能,通过将…...