'STOP'​ the game
The code, by Albert Zakhia

'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!

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
        

To view or add a comment, sign in

More articles by Albert Zakhia

  • Navigating Web Chaos: The Modern Web Browsing Experience

    Web browsing today has devolved into a labyrinth of pop-ups, permissions, and an incessant barrage of advertisements…

  • An Open Letter from a Lebanese Citizen to Israel, et al.,

    I write to you as a concerned Lebanese citizen to address the ongoing Israeli-Palestinian conflict and the potential…

  • Working smarter!

    Trouble ahead. Working on a big database, I need, for each table, create an 'insert' stored procedure, a 'select all'…

  • Lost in databases!

    Where is that 'expression'? All programmers go through that! When having multiple databases and thousands of stored…

  • Stored Procedures Error Logging

    Stored Procedures are difficult to handle. Although on one hand, a good set of stored procedures can be a lifesaver and…

  • Watchdog, by Albert Zakhia

    Day and night, automated systems try to penetrate our networks, and most of the time they hit. And when they succeed…

    1 Comment

Insights from the community

Others also viewed

Explore topics