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

news2024/11/28 9:34:06

现在才发现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.coloradmin.cn/o/2222477.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

伺服电动缸用途分析

力姆泰克伺服电动缸是一种先进的电动执行器&#xff0c;由伺服电动机和传动机构组成。它能够提供高精度的位置控制和力量输出&#xff0c;并具有快速响应和高重复性的特点。 力姆泰克伺服电动缸可广泛应用于自动化系统和机械设备中&#xff0c;例如工业机械、机床、自动化生产…

什么是恶意爬虫,有什么应对措施

在当今数字化时代&#xff0c;网络爬虫作为一种重要的数据收集工具&#xff0c;广泛应用于搜索引擎、数据分析、商业情报等领域。然而&#xff0c;恶意爬虫的出现&#xff0c;却给网站安全带来了前所未有的挑战。今天我们就来简单了解下什么是恶意爬虫&#xff0c;爬虫对网站的…

npm install node-sass安装失败

需求&#xff1a;搭建前端开发环境时&#xff0c;npm install报错&#xff0c;错误提示安装node_modules时&#xff0c;node-sass依赖包安装失败&#xff0c;网上找了好久解决方法&#xff0c;大家提示采用淘宝源等方式安装&#xff0c;都失败了了&#xff0c;尝试了很久终于找…

基于WIFI的智能台灯设计

1系统整体设计 本次围绕LED台灯&#xff0c;来设计一款基于WIFI的智能台灯&#xff0c;结合STM32单片机和多种传感器来共同完成该设计&#xff0c;整个设计的主要功能如下&#xff1a; 1.有自动和手动模式&#xff0c;自动模式自动调节光强&#xff0c;手动模式即手动控制&am…

垂起固定翼无人机挂载迫击抛投器技术详解

垂起固定翼无人机挂载迫击抛投器技术是一种结合了固定翼无人机长航时、高速度和垂直起降灵活性的先进技术。以下是对该技术的详细解析&#xff1a; 一、技术背景与优势 垂起固定翼无人机通过结合固定翼和多旋翼的设计&#xff0c;实现了无需长距离滑行跑道的垂直起降&#xf…

写了一个SpringBoot的后端管理系统(仅后端)pine-manage-system

文章目录 前言正文&#x1f680; 技术栈&#x1f6e0;️ 功能模块&#x1f4c1; 项目结构&#x1f308; 接口文档&#x1f680; 项目启动 附录项目功能代码示例1、数据库拦截器-打印sql执行时间2、数据记录变更拦截器3、用户角色数据权限拦截器4、实体转换器接口5、触发器模版6…

青少年编程能力等级测评CPA C++ 四级试卷(2)

青少年编程能力等级测评CPA C 四级试卷&#xff08;2&#xff09; 一、单项选择题&#xff08;共15题&#xff0c;每题3分&#xff0c;共45分&#xff09; CP4_2_1. 下列有关面向对象程序设计的叙述中&#xff0c;不正确的是&#xff08; &#xff09;。 A&#xff0e;面向对…

__桥接模式

在C#中 初始版本 namespace _013_桥接模式 {/// <summary>/// 玩家抽象类/// </summary>public abstract class AbstractPlayer{protected IWeapon _weapon;//武器引用public void SetWeapon(IWeapon weapon){_weapon weapon;}//抽象方法使用武器public abstract…

Windows下Python3.8环境快速安装部署

为了帮助非python计算机软件开发人员快速上手使用python环境&#xff0c;我准备好了的Python 3.8免安装环境&#xff0c;并安装Jupyter Notebook以进行Python学习&#xff0c;以下是一个简单易懂的教程。请按照以下步骤操作&#xff1a; 步骤 1: 解压Python环境 下载并解压&a…

药智网数据库和摩熵医药数据库哪个好?

药智和摩熵医药(原药融云)作为医药行业内专业的医药数据库平台&#xff0c;它们各自在行业内占据着重要的地位&#xff0c;并且都在不断地创新和完善自己的数据库服务&#xff0c;以满足行业日益增长的需求为医药行业的数据服务、决策支持、研发分析等方面提供支持。. 但让大家…

java拆分地址中的省市县区,全国地址通用

package com.sure;import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * description: 拆分地址工具类 * fileName: AddressResolutionUtil.ja…

QExcel 保存数据 (QtXlsxWriter库 编译)

QtXlsxWriter 是一个用于在 Qt 应用程序中创建和操作 Excel XLSX 文件的库。它提供了一个简单的 API&#xff0c;使开发者能够轻松地生成和修改 Excel 文件&#xff0c;而无需依赖 Microsoft Excel 或其他外部应用程序。支持初始化、写文件、读文件、格式设置、合并单元格、加粗…

运维管理软件:如何引领一体化自动运维

在数字化转型的洪流中&#xff0c;运维团队正面临着前所未有的挑战与机遇。随着企业业务规模的不断扩大&#xff0c;IT架构的日益复杂&#xff0c;如何确保服务的连续性、稳定性和高效性&#xff0c;成为了运维团队亟待解决的核心问题。在此背景下&#xff0c;监控易运维管理软…

使用皮尔逊相关系数矩阵进行特征筛选

皮尔逊相关系数矩阵是一个用于量化多个变量之间线性关系的统计工具。它的每个元素表示两个变量之间的皮尔逊相关系数&#xff0c;取值范围从 -1 到 1&#xff1a; 1 表示完全正相关&#xff1a;当一个变量增加时&#xff0c;另一个变量也会增加。-1 表示完全负相关&#xff1a…

#每日一题#自动化 2024年10月

#每日一题#自动化 2024年10月 1、深拷贝和浅拷贝的区别是什么&#xff1f; 参考答案&#xff1a; 深拷贝是将对象本身复制给另一个对象。这意味着如果对对象的副本进行更改时不会影响原对象。在 Python 中&#xff0c;我们使用 deepcopy&#xff08;&#xff09;函数进行深拷贝…

Debezium和SeaTunnel实现MySQL到Hadoop的实时数据流和全量同步(基于尚硅谷的集群环境)

1、hadoop集群连接本地MySQL 1.1 首先测试集群是否可以ping通本地 虚拟机可以ping通网关&#xff08;192.168.10.2&#xff09;&#xff0c;但不能ping通192.168.10.1&#xff0c;这表明问题可能出在Windows主机的防火墙设置或VMware的网络配置上。 1.1.1 检查Windows防火墙…

个人信息窗口(三)

个人信息窗口&#xff08;三&#xff09; 前言 在上一集我们就可以显示我们就可以全部显示所有的未隐藏的组件了&#xff0c;但是隐藏的组件我们还没有蛆完成&#xff0c;所以我们这一集就需要去做隐藏组件的显示&#xff0c;以及如何切换到隐藏的组件的功能。 需求分析并实…

centos7 nginx优化

优化nginx进程个数的策略 在高并发、高访问量的web服务场景&#xff0c;需要事先启动好更多的nginx进程&#xff0c;以保证快速响应并处理大量并发用户的请求。worker_processes 1;一般调整到与CPU的颗数相同查看LInux可查看CPU个数及总核数grep processor /proc/cpuinfo|wc …

开放式耳机排行榜前十名,开放式耳机全价位段盘点

关于开放式蓝牙耳机的品牌选择&#xff0c;这是一个常见的问题。因为市面上的蓝牙耳机种类繁多&#xff0c;各种样式和类型层出不穷&#xff0c;让许多消费者感到困惑&#xff0c;不知道如何选择一款适合自己的蓝牙耳机。一款好的蓝牙耳机不仅需要音质好、配置高&#xff0c;还…

计算机毕业设计hadoop+spark知识图谱中药推荐系统 中药材推荐系统 中药可视化 中药数据分析 中药爬虫 机器学习 深度学习 人工智能 大数据

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 摘 要 本文所探讨的领域是…