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;
}

如果觉得不错就点个赞吧

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

蘑菇书(EasyRL)学习笔记(1)

1、强化学习概述 强化学习&#xff08;reinforcement learning&#xff0c;RL&#xff09;讨论的问题是智能体&#xff08;agent&#xff09;怎么在复杂、不确定的环 境&#xff08;environment&#xff09;里面去最大化它能获得的奖励。如下图所示&#xff0c;强化学习…

huggingface的数据集下载(linux下clone)

1. 安装lfs sudo apt-get install git-lfs 或者 apt-get install git-lfs 2. git lfs install git lfs install 3. git clone dataset包 第2&#xff0c;3步骤的截图如下&#xff1a;

Kubernetes学习笔记

Kubernetes学习笔记 API格式前缀API组API版本 Pod概念优势局限性创建Pod ReplicationController概念配置Pod模板 Kubernetes架构概述节点定义管理节点名称唯一性节点自注册手动节点管理节点状态节点心跳节点控制器逐出速率限制资源容量跟踪 API Kubernetes把其管理的资源均视为…

现代数字信号处理I-P4 CRLB+LMMSE 学习笔记

目录 学习资料视频链接&#xff1a; 1. 估计参数的CRLB回顾 2. 参数变换下的CRLB拓展 3. 矢量参数下的CRLB扩展 3.1 矢量参数下的CRLB公式 3.2 两个矩阵不等式关系的意义说明 3.3 矢量参数下CRLB公式的证明过程 4. 线性估计 重点注意事项&#xff1a;此处的线性估计&am…

零磁通电流探头的原理

在电力电子和自动化控制领域&#xff0c;电流测量的准确性至关重要。传统的开环式电流探头&#xff0c;尽管在交流电流测量中表现出色&#xff0c;但在直流或大电流测量时&#xff0c;常面临磁芯饱和、剩磁及温度变化带来的测量误差问题。为此&#xff0c;零磁通电流探头&#…

​​Spring6梳理17——基于XML的自动装配

以上笔记来源&#xff1a; 尚硅谷Spring零基础入门到进阶&#xff0c;一套搞定spring6全套视频教程&#xff08;源码级讲解&#xff09;https://www.bilibili.com/video/BV1kR4y1b7Qc 目录 ①引入 ②场景模拟 2.1 创建UserController类文件 2.2 创建UserService接口文件 2…

同济大学计算机考研

文章目录 一、初试1.院校情况1.复试名单2.报录比3.学硕人数 二、复试(一) 数据库2016复试题一、选择题 &#xff08;Multiple Choices&#xff09;二、简答题 2018复试题一、选择题&#xff08;一&#xff09;数据库&#xff1a;1-10&#xff08;二&#xff09;C语言&#xff1…

植物大战僵尸杂交版游戏分享

植物大战僵尸杂交版游戏下载&#xff1a;夸克网盘分享 无捆绑之类的隐形消费&#xff0c;下载即玩

【软件工程】过程和生命周期的建模

&#x1f308; 个人主页&#xff1a;十二月的猫-CSDN博客 &#x1f525; 系列专栏&#xff1a; &#x1f3c0;软件开发必练内功_十二月的猫的博客-CSDN博客 &#x1f4aa;&#x1f3fb; 十二月的寒冬阻挡不了春天的脚步&#xff0c;十二点的黑夜遮蔽不住黎明的曙光 目录 1. 过…

springboot整合xxl-job实现定时任务

搭建调度中心xxl-job-admin 下载调度中心项目 gitee github 注&#xff1a; 下载项目的版本应与集成项目pom引用xxl-job版本号对应上。 执行初始化数据库SQL sql路径&#xff1a; doc/db/tables_xxl_job.sql XXL-JOB调度模块基于自研调度组件并支持集群部署&#xff0c;调…

flv格式如何转换mp4?将flv转换成MP4格式的9种转换方法

flv格式如何转换mp4&#xff1f;在进行flv转MP4的转换之前&#xff0c;了解两种格式的基本特点和差异也是至关重要的。flv格式以其流媒体传输的高效性和对Flash Player的依赖而闻名&#xff0c;而MP4则以其广泛的兼容性、高质量的音视频同步以及灵活的编码选项而著称。通过对比…

vue mixins使用示例

混入 (mixins)&#xff1a; 是一种分发 Vue 组件中可以复用功能灵活的方式。混入对象可以包含任意组件的选项。当组件使用混入对象的时候&#xff0c;所有混入对象的选项将被混入该组件本身的选项。 使用示例: 定义使用的mixins对象 export const HelloWorldMixin {data() {r…

Chromium 沙盒Sandbox源码介绍(3)

本篇主要说下沙箱的环境变量策略【Environment】&#xff1a; 一、环境变量&#xff1a; getEnvironmentStrings 函数返回指向内存块的指针&#xff0c;该内存块包含调用进程的环境变量 (系统和用户环境变量) getEnvironmentStrings 函数 (processenv.h) - Win32 apps | Mic…

ubuntu2204配置cuda

ubuntu2204配置cuda ✅系统版本&#xff1a;ubuntu22.04 LTS ✅显卡&#xff1a;英伟达2070S ✅CPU&#xff1a;i9 10900 ✅主板&#xff1a;戴尔品牌机 教程&#x1f4a8;&#x1f4a8;&#x1f4a8;&#x1f4a8;&#xff1a; ps&#xff1a;本人按照该方法一遍成功&#…

EasyX:初始化绘图窗口initgraph() 的使用

前言 学习使用EasyX图形库的initgraph窗口函数。 一、创建新项目 二、创建C空项目 三、找个地方存一下&#xff0c;创建 四、如果左边的框框找不到 五、点视图&#xff0c;然后点解决方案管理器&#xff0c;左边的框框就出来了 六、源文件添加新建项 七、给文件取个名&#x…

qt QPushButton详解

QPushButton是Qt Widgets模块中的一个基本控件&#xff0c;用于提供可点击的按钮。它是用户界面中最为常见和常用的控件之一&#xff0c;通过点击按钮&#xff0c;用户可以触发特定的应用程序操作。 重要方法 QPushButton(const QIcon &icon, const QString &text, QWi…

数据通信与网络课程展示图谱问答展示系统

&#x1f4a1; 你是否在学习“数据通信与网络”时感觉知识点分散&#xff0c;难以整理&#xff1f;学了后面忘记前面&#xff0c;知识点的关联也难以梳理&#xff1f;别担心&#xff01;我们公司推出的【数据通信与网络课程展示图谱问答系统】帮你一次性解决所有问题&#xff0…

手撕反向传播

关于二分类的交叉熵损失部分数学推导过程。 有些地方加以注释&#xff0c;公式太多懒得MD格式了 #%% import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn import datasetsiris_data datasets.load_iris() in_put_data iris_data.data corr…

Golang | Leetcode Golang题解之第494题目标和

题目&#xff1a; 题解&#xff1a; func findTargetSumWays(nums []int, target int) int {sum : 0for _, v : range nums {sum v}diff : sum - targetif diff < 0 || diff%2 1 {return 0}neg : diff / 2dp : make([]int, neg1)dp[0] 1for _, num : range nums {for j …

【嵌入式Linux】Linux设备树详解

设备树是是Linux中一种用于描述硬件配置的数据结构&#xff0c;它在系统启动时提供给内核&#xff0c;以便内核能够识别和配置硬件资源。设备树在嵌入式Linux系统中尤其重要&#xff0c;因为这些系统通常不具备标准的硬件配置&#xff0c;需要根据实际的硬件配置来动态配置内核…