r/PowerShell • • Sep 09 '26

Question Are games possible in power shell?

Hey gang, I hope this is the right subreddit but would anyone know if it is possible to run text games in powershell/cmd prompt? If so, what kind of pre built code is out there?

0 Upvotes

40 comments sorted by

58

u/pantherghast Sep 09 '26

You could also use a spoon to tunnel through a mountain, but I wouldn't recommend it.

11

u/Pisnaz Sep 09 '26

Shit. Where is my fork?

4

u/ScottBandit Sep 09 '26

pass the Spork please, my good Sir.

6

u/phoward8020 Sep 09 '26

Just let me know when someone manages to run Doom on the spoon.

4

u/codewario Sep 10 '26

We’ve got it running on a spork so we’re close

3

u/BrandaoFereira Sep 09 '26

Ahahaha I’m dying

15

u/MallocArray Sep 09 '26

How about a game in PowerShell to learn how to use PowerShell?

https://github.com/PowerShellOrg/PSKoans

2

u/BlackV Sep 10 '26

Ha, solid answer

1

u/alex015110 Sep 10 '26

You’re a saint!

18

u/DrSinistar Sep 09 '26

PowerShell is, at it's core, an automation tool for IT administrators and engineers.

Could you make a text game? Absolutely, but it would be slow and clunky.

If you want to make games, use C# instead. If you want to keep things simple, use Python. PowerShell is the wrong tool for the job.

7

u/ihaxr Sep 09 '26 edited Sep 09 '26

Yes, specifically you can use [Console]::SetCursorPosition to directly overwrite specific locations on the screen without having to run Clear-Host and redraw the entire frame.

You can lookup any console based games in any language and try to rewrite it in PowerShell or see how it's written.

I'm not really aware of any preexisting libraries for it.

Give it a try by creating a blank window, output an o to the window then detect key presses:

Clear-Host

$x = 0
$y = 0

while ($true) {

    [Console]::SetCursorPosition($x, $y)
    [Console]::Write("O")

    $key = [Console]::ReadKey($true).Key

    switch ($key) {
        UpArrow    { $y-- }
        DownArrow  { $y++ }
        LeftArrow  { $x-- }
        RightArrow { $x++ }
        Escape     { break }
    }
}

You'll want to improve it to only overwrite the old location and update the new location after a key is pressed instead of just duplicating the character, also detect the boundaries of the console to prevent errors, etc...

1

u/narcissisadmin Sep 15 '26

Looks like a great start to Snake.

1

u/That-Feeling-2399 Oct 12 '26

Thanks all, learned lots of good things 

1

u/Creative-Type9411 Sep 10 '26

1

u/That-Feeling-2399 Sep 12 '26

All traces of this game seem to have vanished lol

1

u/Creative-Type9411 Sep 12 '26

yea sorry, the person whose idea I based it on basically called it slop so I just pulled it down and maybe someone else will further his work instead, sorry about that

2

u/lordicarus Sep 10 '26

That's basically a C# game with a game loop in Powershell though. Not really a powershell game.

2

u/Creative-Type9411 Sep 10 '26

On Windows i view native PS C# and .NET all the same thing considering it all ships with .NET as one peice, at least these specific versions did

but you're correct

3

u/Tanner-TO Sep 09 '26

Just for fun I had qwen 3.8 make a tetris game the other day as an exercise to see if it could do it or not... and rather successfully..

3

u/AdministrativeFile78 Sep 14 '26

Yes but for the love of God, no

2

u/MonkeyNin Sep 09 '26

What kind of game are you trying to make? If you want a roguelike, there's libraries for python and javascript that are a lot easier .

But if you want text, tables, etc try Spectre It's a more modern TUI / Text-user-interface.

Then you don't have to mess with manually using [Console]::ReadKey

2

u/g3n3 Sep 09 '26

Pstetris

2

u/Proxiconn Sep 10 '26

2

u/BlackV Sep 10 '26

HA just came here to post this

2

u/Proxiconn Sep 10 '26 edited Sep 10 '26

Exactly bro, closed the post, think I scrolled 1 page and saw the new post maybe 43 min fresh.

Thought it deserved a copy paste effort for the cause.

1

u/Loki-L Sep 09 '26

Sure, I don't see why you would want to, but you definitely could.

You could probably easily port something like Zork to PowerShell.

It isn't really the right tool for this sort of job, but it can certainly do that.

1

u/stillnotlovin Sep 09 '26

One of our first powershell tasks at school was to make a hangman's game with word randomization.

1

u/AroTesCra Sep 09 '26

Since you can add-type and other compiled languages to the mix also you can call Win forms / WPF and directX you could make a window popup with a scripted game

1

u/ZZartin Sep 09 '26

It has access to the full .net library so sure?

Doom in powershell anyone?

1

u/x8code Sep 14 '26

Technically yes, but game loops are much better with a high performance language. Use Rust instead.

1

u/ki6cqe Sep 14 '26

Powershell has full access to the .Net framework. "Anything" you can do in C++ you could do in Powershell, but it will never be as fast or efficient as C++ (close, if you are using .Net libraries, those are compiled, but the control portion in PSH will be slow). Probably ok for a text-based adventure.