ccg1_computer_nightmare.py

Created by mobluse

Created on September 19, 2025

1.07 KB

This game is a typing contest where you need to type the shown number (hold down the key). The game is Computer Nightmare from Usborne Creepy Computer Games (1983) by Jenny Tyler & Chris Oxlade (ed). Free pdf:s are on https://usborne.com/row/books/computer-and-coding-books. The ZX81 BASIC original was typed in by XavSnap on https://www.sinclairzxworld.com/viewtopic.php?f=4&t=1809. Converted to MicroPython for NumWorks calculator and simulator by mobluse/MOB-i-L. The converted program is close to ZX81 BASIC and not optimized or pythonic Python.


# Computer Nightmare from Usborne Creepy Computer Games (1983)
# s is used in variables and functions where $ was used in BASIC.
import ion as k
from random import random

nn=(k.KEY_ONE,k.KEY_TWO,k.KEY_THREE,k.KEY_FOUR,k.KEY_FIVE,k.KEY_SIX,k.KEY_SEVEN,k.KEY_EIGHT,k.KEY_NINE)

def CLS():
  for i in range(10):
    print()

def INKEYs():
  for i in range(len(nn)):
    if k.keydown(nn[i]):
      return str(i+1)
  return ""

Fs="0"
Cs=[None]*6
S=300
Cs[1]="** MICROS RULE. **"
Cs[2]="*PEOPLE ARE STUPID*"
Cs[3]="+A ROBOT FOR PRESIDENT!"
Cs[4]="!COMPUTERS ARE GREAT!"
Cs[5]="*I'M BETTER THAN YOU.*"
while True:
  CLS()
  N=int(random()*len(nn))+1
  print(5*" ",N,sep="")
  print(15*" ",S,sep="")
  if not random()>0.5:
    print()
    print(Cs[int(S/100)+1])
  if S<60:
    print("<THERE'S NO HOPE>")
  if S>440:
    print("URK! HELP!!")
  for i in range(1, 41):
    As=INKEYs()
    if As!="":
      Fs=As
  S=S-10
  if not int(Fs)!=N:
    S=S+10+N*2
  if S<0:
    print("YOU'RE NOW MY SLAVE")
    break
  if S>500:
    print("OK.. YOU WIN (THIS TIME)")
    break

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.