Back to Blog

I Was Winning Until ALIENS Abducted My Car 👽 | Gaming Life Ep.4

Celest KimCelest Kim
•

Video: I Was Winning Until ALIENS Abducted My Car 👽 | Gaming Life Ep.4 by Taught by Celeste AI - AI Coding Coach

Watch full page →

I Was Winning Until ALIENS Abducted My Car 👽 | Gaming Life Ep.4

In this episode of Gaming Life, Bug and Loopi are dominating a chaotic race until unexpected obstacles turn their victory upside down. From a herd of cows blocking the track to a UFO abducting their car, the race becomes a wild, unpredictable adventure full of humor and surprises.

Code

// Simple simulation of a racing game event with unexpected obstacles

class Racer {
  constructor(name) {
    this.name = name;
    this.position = 1; // 1 means leading
    this.isAbducted = false;
  }

  encounterObstacle(obstacle) {
    switch(obstacle) {
      case 'cows':
        console.log(`${this.name} is blocked by a herd of cows! Slowing down.`);
        this.position += 2; // lose two positions
        break;
      case 'banana':
        console.log(`${this.name} hits a giant banana peel and spins out!`);
        this.position += 1; // lose one position
        break;
      case 'ufo':
        console.log(`A UFO abducts ${this.name}'s car with a tractor beam!`);
        this.isAbducted = true;
        this.position = null; // no finish
        break;
      default:
        console.log(`${this.name} races smoothly.`);
    }
  }
}

const bug = new Racer('Bug');
const loopi = new Racer('Loopi');

// Initial race status
console.log('Race start: Bug and Loopi are leading!');

// Race events
bug.encounterObstacle('cows');
loopi.encounterObstacle('banana');
bug.encounterObstacle('ufo'); // Bug gets abducted

// Final race results
if (bug.isAbducted) {
  console.log('Bug did not finish the race due to alien abduction.');
}
console.log(`Final positions: Loopi is in position ${loopi.position}, Bug is out of the race.`);

Key Points

  • Unexpected obstacles like cows and banana peels can affect player positions dynamically in a race.
  • Special events such as alien abduction can remove a player from the race entirely, simulating a DNF (Did Not Finish).
  • Using a class to represent racers allows easy tracking of state changes during gameplay.
  • Switch statements help handle different obstacle effects clearly and maintainably.
  • Humor and unpredictability enhance the engagement and fun in game design and storytelling.