STOP, the smallest playable game

Home Page Forums Computers and Stuff In code we trust STOP, the smallest playable game

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of albertzakhia albertzakhia 8 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #242 Reply
    Profile photo of albertzakhia
    albertzakhia
    Keymaster

    Source Code VB Snapshot[/caption]” alt=”VB Snapshot” />

    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’. I still remember this game, although I do not remember if it won or not, but here it is, modified to be runnable with Visual Basic, under Visual Studio.

    How to play?
    All you have to do is run the code. On the console window, 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 time is displayed, other wise you lose. But then, you can always run it again.

    How to write the code?
    Easy, in Visual Studio, or any VB, create a new project (File -> New Project) then select VB on the left pane finally select CONSOLE APPLICATION on the right, then OK. Now copy the whole code from below and paste as-is in the page MODULE1.VB. You won’t need to use any of the imports so paste replacing all. Finally, click the function key [F5] to run the cise and wait for yhe signal. Start typing!

    Minimal computer requirement: CPM, 8086 4 MHZ CPU running Microsoft DOS and 512K of RAM.

    Enjoy.

    Compliment of Albert Zakhia.

    Sub Main()
    Dim s = “”
    Dim t = New Stopwatch
    Dim pos As Int16
    Dim key As Char
    While True
    s = “”
    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(“|”)
    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.WriteLine(“X – Timeout, you lose”)
    Else
    Console.WriteLine(“{0}Great! You typed: {1} in {2} seconds”, vbCrLf, s, t.ElapsedMilliseconds / 1000)
    End If
    While Console.KeyAvailable
    Console.ReadKey()
    End While
    End While
    End Sub
    End Module

    • This topic was modified 8 months, 1 week ago by Profile photo of albertzakhia albertzakhia.
    • This topic was modified 8 months, 1 week ago by Profile photo of albertzakhia albertzakhia. Reason: Adding colors
    • This topic was modified 8 months, 1 week ago by Profile photo of albertzakhia albertzakhia.
    • This topic was modified 8 months, 1 week ago by Profile photo of albertzakhia albertzakhia.
    • This topic was modified 8 months ago by Profile photo of albertzakhia albertzakhia.
    • This topic was modified 8 months ago by Profile photo of albertzakhia albertzakhia.
    • This topic was modified 8 months ago by Profile photo of albertzakhia albertzakhia.
    • This topic was modified 8 months ago by Profile photo of albertzakhia albertzakhia.
    • This topic was modified 8 months ago by Profile photo of albertzakhia albertzakhia.
Viewing 1 post (of 1 total)
Reply To: STOP, the smallest playable game
Your information: