Giter VIP home page Giter VIP logo

dotnet-console-games's Introduction

dotnet-console-games

GitHub repo Language C# Target Framework Discord License Towel

Game examples implemented as .NET console applications primarily for providing education and inspiration. :)

Recommendation
Play the games, pick a game you like, and try to code the game yourself from scratch.

Game *Weight Notes                                                                      
Guess A Number 0 Play Now Status
Rock Paper Scissors 0 Play Now Status
Dice Game 0 Play Now Status
*Community Contribution
Flash Cards 0 Play Now Status
Quick Draw 1 Play Now Status
Tug Of War 1 Play Now Status
Whack A Mole 1 Play Now Status
Tic Tac Toe 1 Play Now Status
Simon 1 Play Now Status
Roll And Move 1 Play Now Status
Beep Pad 1 Status
Warning Only Supported On Windows OS
Draw 1 Play Now Status
Tower Of Hanoi 1 Play Now Status
Clicker 1 Play Now Status
Hangman 2 Play Now Status
Lights Out 2 Play Now Status
Wordle 2 Play Now Status
Memory 2 Play Now Status
Connect 4 2 Play Now Status
Minesweeper 2 Play Now Status
Wumpus World 2 Play Now Status
Rythm 2 Play Now Status
Type 2 Play Now Status
Drive 2 Play Now Status
Sliding Puzzle 2 Play Now Status
Snake 3 Play Now Status
Word Search 3 Play Now Status
Hurdles 3 Play Now Status
Pong 3 Play Now Status
Flappy Bird 3 Play Now Status
Oligopoly 3 Play Now Status
*Community Contribution
Reversi 3 Play Now Status
Darts 3 Play Now Status
Yahtzee 4 Play Now Status
Tanks 4 Play Now Status
Helicopter 4 Play Now Status
2048 4 Play Now Status
Sudoku 4 Play Now Status
Mancala 4 Play Now Status
Bound 4 Play Now Status
Tents 4 Play Now Status
Battleship 4 Play Now Status
Checkers 4 Play Now Status
*Community Contribution
Duck Hunt 5 Play Now Status
*Community Contribution
Blackjack 5 Play Now Status
Fighter 5 Play Now Status
Maze 5 Play Now Status
PacMan 5 Play Now Status
Gravity 5 Play Now Status
Tetris 5 Play Now Status
*Community Contribution
Shmup 5 Play Now Status
Warning Only Supported On Windows OS
Role Playing Game 6 Play Now Status
Console Monsters 7 Play Now Status
*Community Collaboration
Warning Work In Progress
First Person Shooter 8 Play Now Status
Warning Only Supported On Windows OS

*Weight: A relative rating for how advanced the source code is.
*Community Contribution: Special thanks to everyone who contributed games!
*Community Collaboration: Games where multiple members of the community participated in the development!

You can play the games in your browser:
Play Now
Hosted On GitHub Pages

Local Setup

Clone the repository or download the repository and unzip the contents. dotnet-console-games should build with any .NET build process, such as one of the following:

Visual Studio [Expand]

  1. Install Visual Studio if not already installed.

  2. Open the File dotnet-console-games.slnf file in Visual Studio.

  3. Run the games with the Debug->Start Debugging (default hotkey F5) option in the menu strip. You can switch games by right clicking the projects in the solution explorer and using the Set as Startup Project option.

Note This is optional, but here are some settings you can change in Visual Studio.

Visual Studio Code [Expand]

  1. Install the .NET SDK if not already installed.

  2. Install Visual Studio Code if not already installed.

  3. Open the Directory root folder of the repository in Visual Studio Code.

  4. Run the games using the Start Debugging green triangle button (default hotkey F5) in the Run and Debug tab. You can switch games in the drop down next to the Start Debugging button.

Note The following files are included in the repository:

  • .vscode/extensions.json recommends Vistual Studio Code extension dependencies
  • .vscode/launch.json includes the configurations for debugging the examples
  • .vscode/settings.json automatically applies settings to the workspace
  • .vscode/tasks.json includes the commands to build the projects

Note You will be prompted to install the necessary Visual Studio Code extensions when you open the folder:

  • ms-dotnettools.csharp C# support

Command Line [Expand]

  1. Install the .NET SDK if not already installed.

  2. Run the games using the dotnet run --project <PROJECT> command where <PROJECT> is the file path to one of the .csproj files. For example, running the dotnet run --project Projects/Drive/Drive.csproj command from the root of the repository will run the Drive game.

Relevant Articles

Beginner's Guide To Console Input In C# August 1, 2020

dotnet Console Games Tips And Tricks April 7, 2022

Get Involved

Want to show support? You can star the github repository.

Have any questions? Start a new discussion.

Find a bug or have a suggestion? Open an issue.

Want to chat with the developer(s)? Join the discord server.

Want to contribute? Look for open issues you can help with.


Supported by the

dotnet-console-games's People

Contributors

alexsrk09 avatar asrielkujo avatar coda-420 avatar daltonks avatar fuinny avatar hunterscouti avatar hurricankai avatar jahgii avatar javithegreat35 avatar mozin0 avatar rinzii avatar trba1810 avatar ultimatesingularity avatar wycott avatar zacharypatten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnet-console-games's Issues

Hangman wrap the disposable streams in a nested syntax

In the Hangman game, the new using syntax won't dispose of the object until the end of the current scope. So, the using statements need to be wrapped in a nested scope so they are only open during the initial load.

`Helicopter` reduce flickering

Helicopter is one of the older games and I never coded it properly to reducing the amount of flickering that happens. It should not flicker like it currently does.

`Website` code generator for porting console games to blazor webassembly

Currently the process of porting console to blazor webassembly is a manual process. For the most part you just copy-paste the console code into the Website project and add public readonly BlazorConsole Console = new(); and await in front of the Console member invocations. This should be easy to make a code generator for.

If there are any changes to the console games, it requires the same change be applied to the ports. However, if the ports were generated, we could just make any changes to the original console games and the generator would carry over any changes to the ports automatically.

A source generator would be good for this topic. :)

Demo / odiuM (Sith) 花蜜

MazeGenerator would be a really cool example...

I think that this could be used to create highway skeletons which can therein be physically lamented from the manifestation.

Simple case; I want to have a wooden version of my maze in 3d form with all sides connection to each other, I design a maze generator with the astute bias and utilize such seed to ensure the vectors conjugate about points which traverse the sides, this in short would probably just be rotations of a single generated matrix such that its end points may be allows to traverse around the side dimensions (maybe in also).

I would generate my maze, produce a WKT / Store it in a DB, send the WKT for conversion to GCODE and print it out.

Other case; I want to design a highway or city, I need to create the maze of the city such that the maze of the highway fits inside it, perhaps I want to also include utilities etc.

I would then lament the WKT / Store it in a DB and project such on a map for viewing (potentially in MVT / GeoJson /TopoJson) allowing me to view my city at scale in the real world.

Thank you for your library sir from its contents and your demeanor I can tell you are satoshi (聡)!

P.s. using libraries like NTS/Itinero it would be possible to have it traverse your mazes and find the shortest solutions from any given point to another (including the exit or the non traversable spot in an island of such)

See also https://en.wikipedia.org/wiki/Labyrinth

One type of thing I muse is a type of Maze which is a fractal, it is created in a likeness and then zoomed upon for arbitrary derivatives thus never having to ge-generate the maze again only refine its details...

`Website` prevent zoom on double tap of buttons

Some of the games in the Website project require rapid pressing of the buttons, however double tapping screens often causes zoom in/out. So the zooming caused by double tapping needs to be prevented. This is especially a problem for the Bound game.

`.editorconfig`

Since this repository is meant to help C# beginners setting foot in the programming world, I think it would be good to show some best practices and enforce them for contributors.

Currently, the .editorconfig file in the root directory is not even part of the solution. I'm not sure Visual Studio (or other IDEs) pick up on its rules as it stands.

I'm suggesting adding all .NET- and C#-specific rules and enforcing them in a way which is closest to the .NET standard. This way, new coders will learn good convention the moment they set foot into this repository. I'm happy to do this myself (I already have a complete .editorconfig file lying around).

`Gravity` add more levels

The Gravity game has 15 levels at the moment. It would be nice to add more.

Some possible ideas:

  • Levels with multiple player blobs. You would have to get each blob to the goal or perhaps separate/multiple goals.
  • Levels that are not stationary. Perhaps the goal moves around. Maybe spikes appear/disappear or move around.
  • Keys that make walls/doors open allowing access to the goal.

`Console Monsters` ascii art

In the Console Monsters project we need additional ascii art for monsters, maps, characters, items, etc. If possible, it would be nice if the ascii art would complement the current art style. Here are some examples of existing assets in the game (note that these may not render correctly on mobile browsers; viewing via desktop is recommended):

Characters...

 ╭═══╮ 
 │'_'│ 
╭╰───╯╮
│├───┤│
 │_|_│ 
 ╭───╮ 
 ├■_■┤ 
╭╰───╯╮
╰├───┤╯
 │_|_│ 
////\\\
//^_^\\
╭┴───┴╮
│├───┤│
 │_|_│ 

Map Tiles...

 ┬──┬─┐
╭┴──┴╮│
│Sign││
╰────╯│
      │
       
       
╦═════╦
╬═════╬
╩     ╩
  ╬╬╬  
 ╬╬╬╬╬ 
  ╬╬╬  
 _|_|_ 
 \___/ 
╔═════╗
║ ■■■ ║
║    o║
║     ║
╚═════╝
                       
 ║        @╮         ║ 
 ║    ╭═╨──∏──╨═╮    ║ 
 ╠══╗ ╰────╥────╯ ╔══╣ 
 ╨  ╨      ╨      ╨  ╨ 

Items...

       
 ╭───╮ 
 ╞═●═╡ 
 ╰───╯ 
       

Monsters...

╰╮             
╰╮╰╮      ╭───╮
╰╮╰╮╰╮    │^_^│
   ╰╮╰────╯  ╭╯
    ╰┬╮ ╭─┬╮ │ 
     ╰╰─╯ ╰╰─╯ 
 ╭───╮ 
 │^_^│ 
 │   │ 
 │   │ 
─┴───┴─
    ╭─────╮    
 (O)│ ‾o‾ │(O) 
╭─╨─╯╔═══╗╰─╨─╮
│ ╭╮╔╝   ╚╗╭╮ │
╰─╯╔╝     ╚╗╰─╯
   ╚╗     ╔╝   
  ╭╯╚╗   ╔╝╰╮  
  │ ╭╚═══╝╮ │  
  ╰─╯     ╰─╯  
           ╭────╮
           │ ^_^│
╭───╮ ╭───╮╰─╮╭─╯
││‾││_││‾││__││  
╰╯ ╰───╯ ╰────╯  
     \~\~\~|~/~/~/     
      \ ╭─────╮ /      
┌─┐ ┌──\│ o_o │/──┐ ┌─┐
  └─┘ ╭─╰─────╯─╮ └─┘  
      │ ╭─────╮ │      
      ╰─╯─╯ ╰─╰─╯      
 /\                  
/~~\  <‾__>╭───╮<__‾>
\   \      │^_^│     
 \___>╭────╯~~┬╯     
      │ ╭┬──╮ ││     
      ╰─╯╯  ╰─╯╯     
    ╭◦╮    
    /◦\    
╭─◦╯^_^╰◦─╮
╰◦╮◦ ◦ ◦╭◦╯
  /◦/‾\◦\  
 ╰◦╯   ╰◦╯ 
    ╭─┬──┬─╮
◦╮╭◦├ ╭─┴╮ ┤
╭┴┴─┼ ╰┬ ├ │
│^_^╰┬┼─┬╯ ┤
╰┬┬┬┬┴─┴─┴─╯
  ╭─────╮     
  │ ⱺ_ⱺ │     
╭─╰─┤ ├─╯─╮  
│ ╷╭┤ ├╮╷ │  
╰─╯││ ││╰─╯╭╮
 ╭╯╰┤ ├╯╰╮─╯│
 │ ╭┤ ├╮ ├──╯
 ╰─╯│ │╰─╯   
    │ │      
    ╯─╰      
   ╮╭    
  ╭/╰╮   
  │ⱺⱺ├<> 
  ╰╮/╯   
 <>┤│    
─^─┴┴^─^─
  ╭──╮╭──╮ 
 ╭┴─╭ⱺⱺ╮─┴╮
 ╰┬─╰─○╯─┬╯
  ╰┬┬╯╰──╯ 
   │├<>    
 <>┤│      
   ││      
─^─┴┴^─^─  
◄‾_>╭─────╮<_‾►  
    │▪^_^▪│      
    │╷╭─╮╷│      
    ├╯╰─╯╰┤◄/\/\>
    ╰─╯‾╰─╯      
        ◦╮ ╭◦       
  /‾‾‾\ ╭┴─┴╮ /‾‾‾\ 
 / ( ( >│^_^│< ) ) \
 \/\/\/ ╰┬─┬╯ \/\/\/
         │ │        
         ╹ ╹        
   ╭─────╮
   │ ‾o‾ │
 ╭─╰─────╯─╮
 │o╷╭───╮╷o│
 ╰═╯│^_^│╰═╯
 ╭╯ ┼┬─┬┼ ╰╮
 │  ╰╯ ╰╯  ├──╮
 │o╭─────╮o├──╯
 ╰═╯     ╰═╯
         ╭─╮
         │^╰─╮
    ╭─╮  │ ╭─╯
╭╭──╯~╰──╯ │
╯│        ╭╯
 │╭┬────┬╮│
 │││    │││
 ╰╯╯    ╰╰╯
           ╰╮╰╮
  ╰╮╰╮╰╮     /^╰─╮
  ╰╮╰╮╰╮╰╮╰╮/ /‾‾
   ╰/‾‾‾‾‾‾  /
    │\ \──┬\ \
    ││//  ││//
    ┕┙˅   ┕┙˅
╔═╭─────╮═╗
╔═│╭───╮│═╗
╔═╰│^ ^│╯═╗
   ╰╥═╥╯
    ╰ ╯
        //
        ││<>
/‾‾‾\╭──╯╰──╮
\___/│ o  O │/‾‾‾\
     │╭════╮│\___/
     ╰╰════╯╯
 _╭─────╮_
//│ ^_^ │\\
//╰╥───╥╯\\
  ╰‾╯ ╰‾╯
   ╭───╮
   │^_^│
  ╭╰───╯─╮
  │╭╮╭╮╭╮│
  ││││││││
  ╰╰╰╯╰╯╯╯

The current version of the code including all ascii art is in the console-monsters branch. If you would like to help out, please join the discord server to discuss. :)

How can you make ascii art? Just open a text editor and start. :) A useful tool is the "Character Map" application in Windows. It can help you find characters you need:
image
However, please stick to the "Consolas" font. Different fonts support different characters, but we are limiting our characters to what is seen in the "Consolas" font. In the website we are actually using the "Source Code Pro" font, but that is because it is very similar to "Consolas".

`Maze` disconnected invalid path

There is a minor bug in the randomized maze generator in the game Maze where it is possible for an invalid path to not be connected to a connected path.

Minor Bugs

  • remove "(work in progress)" from Bound page in Website header
  • remove "(work in progress)" from Bound page in launch.json
  • reorder Bound in launch.json to match readme order
  • Role Playing Game says "You were attacked, but..." instead of "You attacked, but..."

New Games

Thanks In Advance

Contributions are welcome and appreciated! :) If you write a .NET console game and would be willing to contribute it just fork the repo, add your game, and open a pull request. Your game will be marked with *Community Contribution to credit you for your contribution.

Brainstorming

Here are some ideas for games that dotnet-console-games does not have yet:

  • Rubix Cube
  • Chess
  • Solitaire
  • Match 3 Puzzle
  • Tower Defense like Plants Vs Zombies
  • I Love Hue
  • Vicious Fishes
  • Virtual Pet like Digimon
  • Scrabble
  • Red Light Green Light
  • Roguelike like Vampire Survivors
  • Top Down Action Adventure like The Legend of Zelda
  • Side Scrolling Run & Gun like Metal Slug

New Game Contribution Checklist

Here is a checklist of files that need to be updated when a new game is added. The maintainer(s) of this repository can help you with these topics after you open a pull request. <GAMENAME> is the name of the game being added.

  1. Projects/<GAMENAME> game source code here
    • Projects/<GAMENAME>/README.md don't forget a readme
  2. README.md add a row in the table
  3. dotnet-console-games-and-website.sln add project to solution
  4. dotnet-console-games.slnf add project to solution filters
  5. .vscode/tasks.json add a build task for the project
  6. .vscode/launch.json add a launch entry for the game
  7. .github/workflows/<GAMENAME>.yml add a GitHub Action
  8. Projects/Website/... (multiple files) add the game to the website (currently a manual process but see #23)

`Website` nav bar is being cut off

The navigation bar is being cut off under certain conditions:
image

An easy way to replicate is to zoom in on the web page.

The nav bar needs to be fixed so that it never cuts off and all links are always visible.

Minesweeper Win Condition Bug

Currently the Minesweeper game has a bug so you can't win. It checks to see if all the tiles are visible, and if yes, it declares victory. However that includes mines, and revealing mines is the lose condition. So... The win condition needs to be changed to count the number of visible tiles, and if that count equals width * height - mineCount the player wins.

`Website` improve game button layouts

https://zacharypatten.github.io/dotnet-console-games/Draw

The game buttons in the Website project are currently just slapped on without much thought. This makes the games pretty hard and annoying to play on mobile or any platform where the user can't use a keyboard. It would be nice to improve the button layout for every game to make it more sensible.

For example, in the Draw game from the screenshot above, the end key restarts the game with new random generation, but the end key is next to the right arrow key, making it easy to accidentally bump the end key when trying to draw to the right. Something like this might be better for the Draw game:
image

I'm open to ideas. Each game has different buttons, so there they will all require slightly different button layouts, but it would be nice to keep the button layouts as consistent as possible between the games.

Linux Compatibility

Not all the games are compatible out-of-the-box on Linux (they compile but some Console methods are not supported). Need to test and adjust accordingly or document incompatibilities in the individual README files.

Step-By-Step Visual In Maze Generation for Prims Algorithm

The default maze generation algorithm includes a using directive DebugRandomMazeGeneration that allows people to watch the building of the maze step-by-step with a Console.ReadLine() after each node exploration. It would be nice to add this using directive to the Prims algorithm too. @HurricanKai

Leaner console code suggestion

If your code makes heavy use of the Console class (which I suspect will be most games here, if not all), you can make method calls a little leaner by including:

using static System.Console;

This would reduce code like this:

Console.WriteLine("Dice Game");
Console.WriteLine();
Console.WriteLine("In this game you and a computer Rival will play 10 rounds");
Console.WriteLine("where you will each roll a 6-sided dice, and the player");
Console.WriteLine("with the highest dice value will win the round. The player");
Console.WriteLine("who wins the most rounds wins the game. Good luck!");
Console.WriteLine();
Console.Write("Press any key to start...");
Console.ReadKey(true);
Console.WriteLine();
Console.WriteLine();

To:

WriteLine("Dice Game");
WriteLine();
WriteLine("In this game you and a computer Rival will play 10 rounds");
WriteLine("where you will each roll a 6-sided dice, and the player");
WriteLine("with the highest dice value will win the round. The player");
WriteLine("who wins the most rounds wins the game. Good luck!");
WriteLine();
Write("Press any key to start...");
ReadKey(true);
WriteLine();
WriteLine();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.