Skip to content

florianAriasu/mini-game-CSharp-freeCodeCamp-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

Challenge-project-Create-methods-in-CSharp


Warning

I have posted a topic in the Discussions section of this repository to seek advice and solutions for some bugs in this program. I will review all suggested solutions and approve all comments that successfully address the issues.

Note

Starter and Final code for the Challenge project: Create methods C# console applications from the Microsoft Learn collection Getting started with C#

Predefined functions

This mini project comes with a starter code, containing the following functions:

void InitializeGame();
bool TerminalResized();
void ShowFood();
void ChangePlayer();
void FreezePlayer();
void Move();

Important

Move() function has 2 optional parameters check and speed for tasks 1 and 3. If I call Move() without any arguments, the default parameters come into play.

Implemented by me

First task

  • Game Termination: The game should end if the terminal window is resized.
  • Optional Parameter in Move Function: I added an optional parameter to Move() that stops the game when any non-directional key is pressed.

To achieve these, I:

  • Created a function called AnnounceTerminating() for the resizing condition.
  • Used an instance of the Random class to decide the optional parameter's value (1 to stop the game, 0 to continue).

Function implemented:

void AnnounceTerminating();

Second task

  • Food String Update: Update the food if there's nothing left.
  • Change Player's Appearance: Update the player's appearance by calling the ChangePlayer() function

Function implemented:

bool JustAteFood();

Third task

  • Freeze the player temporarily if his appearance is (X_X), therefore I have created the function CheckFreezeCondition()
  • Increase player's speed to left/right by 3 based on this exact appearance (^-^), therefore I have created the CheckMovementSpeed() function

Functions implemented:

bool CheckMovementSpeed();
bool CheckFreezeCondition();

Tip

Thanks for reading! Practice daily and have fun!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages