My version: p5.js Web Editor | Life or Death Door Final version: https://editor.p5js.org/YuhangZhang116/sketches/V8ftr2701

Life or Death Door — Basic Game Logic

My contribution was building the basic logic using variables and if / else statements. Each round, safeDoor = int(random(2)) assigns the safe door. The code detects the player’s click, checks the choice, and displays escape or a random death result. Clicking the result screen restarts the game and randomizes the safe door again.

Which choices are easier, harder? Which choices are false choices?

Clicking a door is easy, but deciding is difficult because both doors look identical and provide no clues. It feels like a false choice in terms of strategy: the outcomes differ, but the player cannot make an informed decision.

What internal or external factors influence the choice? How do others’ choices affect your choices?

Internal factors include habit, intuition, and previous experiences. External factors include visual cues and other people’s advice. Watching someone escape through the left door might encourage me to choose it, even though each new round is random and their result cannot predict mine.

What choices surprise you with unexpected outcomes?

Choosing the same door twice can lead to different outcomes because the safe door is reassigned each round. An incorrect choice also randomly produces fire, a pit, or a giant rock, adding another unexpected result.

Can you combine choices to create hard-to-predict results?

I used && to combine the conditions that check whether a click is inside a door:

if (mouseX >= 150 && mouseX <= 330 &&
    mouseY >= 160 && mouseY <= 420) {
  chosenDoor = 0;
}

All four conditions must be true. Currently, unpredictability comes from random(). A future version could use && and || to let the player escape by choosing the safe door and having a key, or activating a secret switch.

Working in Pairs: Can you divide and combine the idea? Can you swap sketches and build on each other’s work?

We divided the project into logic and visual output. Mason Li (me) built random door assignment, click detection, win/death conditions, random death selection, and restart behavior. Yuhang Zhang is responsible for visual effects.

I added placeholder graphics for testing. The variables gameState and deathType connect my logic to the visual output, allowing us to exchange the sketch and build on each other’s work without rewriting the basic interaction.