Arts >> Arte y entretenimiento >  >> Teatro >> Comedia

Código "Friend or Foe Trash Bash" de Bob Esponja: Simulación en C++

El siguiente código en C++ simula la lógica del minijuego "Friend or Foe":

// Simulación Friend or Foe Trash Bash #include  #include  #include  #include  using namespace std; char generateCharacter() { return (rand() % 2 == 0) ? 'F' : 'S'; // Foe or Friend } void playGame() { int score = 0, timeLeft = 60; vector chars; for (int i = 0; i < 10; ++i) chars.push_back(generateCharacter()); while (timeLeft > 0 && score < 100) { char c = chars[0]; cout << "Approaching: " << c << " (F=Foe, S=Friend)\nYour guess: "; char guess; cin >> guess; if (toupper(guess) == c) { score += 10; cout << "Correct! +10\n"; } else { score -= 5; cout << "Wrong! -5\n"; } chars.erase(chars.begin()); --timeLeft; cout << "Score: " << score << " | Time: " << timeLeft << "\n\n"; } cout << (score >= 100 ? "You won!" : "Game over.") << endl; } int main() { srand(time(0)); playGame(); return 0; } 

Compila y ejecuta para jugar. Ajusta parámetros (tiempo, umbral de puntuación, número de personajes) como desees.

Comedia

Related Categories