Beat the Bug Eyes
Book: Computer Spacegames
Author: Usborne Publishing
Translator: Marcus Medina
Story
You’re trapped! Everywhere you turn, you catch a glimpse of the steely cold light of a space bug’s eyes before it slithers down behind a rock again. Slowly the bugs edge towards you, hemming you in, waiting for a chance to bind you in their sticky web-like extrusions. Luckily, you have your proton blaster with you.
The bug eyes pop up in four different places on your screen, corresponding to keys 1 to 4. Press the correct key while the bug’s eyes are on the screen, and you will blast it. There are 10 bugs in total. The more you blast, the greater your chance of escape.
Pseudocode
START INITIALIZE score to 0 LOOP for 10 bugs CLEAR screen DELAY randomly RANDOMIZE bug position DISPLAY bug at position AWAIT player input IF input matches position THEN INCREASE score END LOOP PRINT final scoreENDFlowchart
flowchart TD
Start[Start] --> InitScore["Initialize score to 0"]
InitScore --> BugLoop["For each of 10 bugs"]
BugLoop --> ClearScreen["Clear screen"]
ClearScreen --> Delay["Random delay"]
Delay --> RandomizeBug["Randomize bug position"]
RandomizeBug --> DisplayBug["Display bug on screen"]
DisplayBug --> WaitInput["Await player input"]
WaitInput --> CheckInput["Does input match bug position?"]
CheckInput -->|Yes| IncreaseScore["Increase score"]
CheckInput -->|No| BugLoop
IncreaseScore --> BugLoop
BugLoop -->|After 10 Bugs| PrintScore["Print final score"]
PrintScore --> End["End"]
Code
Pages


ZX-81 BASIC
10 PRINT "BUG EYES"20 LET S=030 FOR T=1 TO 1040 CLS50 FOR I=1 TO INT(RND*30+20)60 NEXT I70 LET R=INT(RND*4+1)80 GOSUB 210+30*R90 PRINT "00"100 FOR I=1 TO 20110 LET R$=INKEY$120 IF R$<>"" THEN GOTO 140130 NEXT I140 IF VAL(R$)=R THEN GOTO 210150 LET S=S+1210 PRINT "YOU BLASTED ";S;"/10 BUGS"220 STOP230 LET D=5240 LET A=1250 GOTO 350260 LET A=9270 GOTO 350280 LET A=9290 GOTO 350300 LET A=18310 GOTO 350320 GOTO 350330 LET D=10340 LET A=7350 FOR I=1 TO D360 PRINT370 NEXT I380 PRINT TAB (A) : "*"390 RETURNC#
using System;using System.Threading;
class BugEyes{ static void Main() { Random rnd = new Random(); int score = 0;
Console.WriteLine("BUG EYES");
for (int t = 1; t <= 10; t++) { Console.Clear(); Thread.Sleep(rnd.Next(500, 1500)); // Random delay
int bugPosition = rnd.Next(1, 5); Console.WriteLine($"BUG AT POSITION {bugPosition}");
Console.Write("PRESS 1-4: "); string input = Console.ReadLine();
if (int.TryParse(input, out int playerInput) && playerInput == bugPosition) { score++; Console.WriteLine("HIT!"); } else { Console.WriteLine("MISS!"); } }
Console.WriteLine($"YOU BLASTED {score}/10 BUGS"); }}Python
import randomimport time
def main(): score = 0 print("BUG EYES")
for _ in range(10): print("\033[H\033[J", end="") # Clear screen time.sleep(random.uniform(0.5, 1.5)) # Random delay
bug_position = random.randint(1, 4) print(f"BUG AT POSITION {bug_position}")
player_input = input("PRESS 1-4: ") if player_input.isdigit() and int(player_input) == bug_position: score += 1 print("HIT!") else: print("MISS!")
print(f"YOU BLASTED {score}/10 BUGS")
if __name__ == "__main__": main()Java
import java.util.Scanner;import java.util.Random;
public class BugEyes { public static void main(String[] args) { Random rnd = new Random(); Scanner scanner = new Scanner(System.in); int score = 0;
System.out.println("BUG EYES");
for (int t = 1; t <= 10; t++) { System.out.print("\033[H\033[J"); // Clear screen try { Thread.sleep(rnd.nextInt(1000) + 500); // Random delay } catch (InterruptedException e) { Thread.currentThread().interrupt(); }
int bugPosition = rnd.nextInt(4) + 1; System.out.println("BUG AT POSITION " + bugPosition);
System.out.print("PRESS 1-4: "); int playerInput = scanner.nextInt();
if (playerInput == bugPosition) { score++; System.out.println("HIT!"); } else { System.out.println("MISS!"); } }
System.out.println("YOU BLASTED " + score + "/10 BUGS"); }}Go
package main
import ( "fmt" "math/rand" "time")
func main() { rand.Seed(time.Now().UnixNano()) score := 0
fmt.Println("BUG EYES")
for t := 1; t <= 10; t++ { fmt.Print("\033[H\033[J") // Clear screen time.Sleep(time.Duration(rand.Intn(1000)+500) * time.Millisecond) // Random delay
bugPosition := rand.Intn(4) + 1 fmt.Printf("BUG AT POSITION %d\n", bugPosition)
var playerInput int fmt.Print("PRESS 1-4: ") fmt.Scan(&playerInput)
if playerInput == bugPosition { score++ fmt.Println("HIT!") } else { fmt.Println("MISS!") } }
fmt.Printf("YOU BLASTED %d/10 BUGS\n", score)}C++
#include <iostream>#include <cstdlib>#include <ctime>#include <thread>#include <chrono>
using namespace std;
int main() { srand(time(0)); int score = 0;
cout << "BUG EYES" << endl;
for (int t = 1; t <= 10; t++) { system("clear"); // Clear screen (Linux/Unix) this_thread::sleep_for(chrono::milliseconds(rand() % 1000 + 500)); // Random delay
int bugPosition = rand() % 4 + 1; cout << "BUG AT POSITION " << bugPosition << endl;
cout << "PRESS 1-4: "; int playerInput; cin >> playerInput;
if (playerInput == bugPosition) { score++; cout << "HIT!" << endl; } else { cout << "MISS!" << endl; } }
cout << "YOU BLASTED " << score << "/10 BUGS" << endl;
return 0;}Explanation
In Beat the Bug Eyes, the player has 10 opportunities to hit bugs that appear randomly in one of four positions on the screen. The player must react quickly by pressing the corresponding key. The program tracks the player’s score and provides feedback after each attempt.
Challenges
- Speed Adjustment: Make the game faster or slower by changing the random delay range.
- Extended Gameplay: Allow the player to play more than 10 rounds.
- Additional Positions: Increase the number of positions bugs can appear in.
Copyright
These programs are adaptations of the original Usborne Computer Guides published in the 1980s. The books are free to download for personal or educational use from Usborne’s Computer and Coding Books. Programs and adaptations may not be used for commercial purposes.
Return to Computer Spacegames.