This commit is contained in:
Baipyrus 2022-10-13 15:28:25 +02:00
parent 4aa8cbce76
commit 3feae88098

View File

@ -5,22 +5,25 @@ namespace FlappyBird {
class Program { class Program {
// Constants // Constants
static string scoreText = "Your score is: "; static string scoreText = "Your score is: ";
static float gravity = 0.175f; static float factor = 32/1.4f;
static float jumpVel = 1.75f;
static int pipeInterval = 60; static int pipeInterval = 60;
static int spaceHeight = 8; static int height = 15;
static int width = 30;
static int FPS = 60; static int FPS = 60;
// Game variables // Game variables
static char[,] board; static char[,] board;
static int birdX = 5, score = 0; static int spaceHeight = height/5;
static float birdY = 20f, velY = 0f; static float jumpVel = height/factor;
static bool gameOver, startOver = true; static bool gameOver, startOver = true;
static int birdX = width/16+1, score = 0;
static float birdY = height/2f, velY = 0f;
static float gravity = height/(factor*10);
static void Main() { static void Main() {
while (startOver) { while (startOver) {
gameOver = false; gameOver = false;
board = new char[82, 37]; board = new char[width + 2, height + 2];
// Fill the 'board' Array with blank spaces // Fill the 'board' Array with blank spaces
for (int i = 0; i < board.GetLength(0); i++) for (int i = 0; i < board.GetLength(0); i++)
@ -40,6 +43,8 @@ namespace FlappyBird {
for (int j = 0; j < board.GetLength(1); j++) { for (int j = 0; j < board.GetLength(1); j++) {
for (int i = 0; i < board.GetLength(0); i++) { for (int i = 0; i < board.GetLength(0); i++) {
string pipeCon = (i < board.GetLength(0)-1) ? "|" : ""; string pipeCon = (i < board.GetLength(0)-1) ? "|" : "";
bool yC = j%(board.GetLength(1)-1)==0;
pipeCon = (yC && pipeCon != "") ? "#" : pipeCon;
Console.Write($"{board[i, j]}{pipeCon}"); Console.Write($"{board[i, j]}{pipeCon}");
} }
Console.WriteLine(); Console.WriteLine();
@ -145,7 +150,7 @@ namespace FlappyBird {
if (uin.ToLower() == "n") if (uin.ToLower() == "n")
startOver = false; startOver = false;
else { else {
birdY = 20f; birdY = height/2f;
velY = 0f; velY = 0f;
score = 0; score = 0;
} }