'STOP' the game
Back in the good old days of DOS and Microsoft BASIC (MSBASIC), the BASIC written by Bill Gates himself, someone somewhere held a coding competition: "who can write the 'smallest playable game' in a single line of code" and was by using one of the oldest versions of BASIC! That was back in the Triassic era of compute age.
I still remember this game to present!
In the 30th memory of this game (circa 2016), I decided to give it a go, to honor it.
Here it is, modified to be runnable using Visual Basic under Visual Studio.
About the game: The game is about a moving object that will hit a wall within 1 second (modifiable)! You will need to type STOP to stop the object before it hits the wall.
How to play? All you have to do is run the code. On the console window, once you run the code, wait for the GO, then try typing the word STOP as fast as you can. You have 1 second. If you are able to type STOP in under 1 second, you win and your typing speed is displayed, other wise you lose. But then, you can always run it again.
How to write the code? Easy, in VB for Visual Studio, create a new project, choose CONSOLE APPLICATION, then OK. Now copy the whole code from below and paste as-is in the page that is automatically labeled MODULE1.VB. You won't need to use any of the imports that come per default, so you can paste the code replacing everything. Finally, click the function key [F5] to run the code and wait for the signal. Once you have the GO signal, Start typing!
Recommended by LinkedIn
This game is highly hungry for computer resources :) :Minimal computer requirement: CPM operating system as a minimum, 8086 4 MHZ CPU running Microsoft DOS and 256K of RAM.
Btw, this is a true playable game! Make it more challengeable by changing the line
t.ElapsedMilliseconds > 1000
To
t.ElapsedMilliseconds > 500
Hope you enjoy it.
Module Program
Sub Main()
Dim s = ""
Dim t = New Stopwatch
Dim pos As Int16
Dim key As Char
Dim foreGround As ConsoleColor
foreGround = Console.ForegroundColor
While True
' By Albert Zakhia
Console.ForegroundColor = foreGround
Console.WriteLine("Press [X] to exit or any key to start!")
key = Console.ReadKey().KeyChar
If Char.ToUpper(key) = "X" Then Exit While
pos = 1
Console.WriteLine("GO!")
Console.SetCursorPosition(11, Console.CursorTop)
Console.Write("|")
s = ""
t.Restart()
While Not s.ToLower().Contains("stop") And t.ElapsedMilliseconds <= 1000
If Console.KeyAvailable Then s = s & Console.ReadKey().KeyChar
Console.SetCursorPosition(pos, Console.CursorTop)
pos = pos + 1
Threading.Thread.Sleep(100)
End While
If t.ElapsedMilliseconds > 1000 Then
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine(vbCrLf + "X - Timeout, you lose")
Else
Console.ForegroundColor = ConsoleColor.Green
Console.WriteLine("{0}Great! You typed: {1} in {2} seconds", vbCrLf, s, t.ElapsedMilliseconds / 1000)
End If
End While
End Sub
End Module