xxxxxxxxxx
116
let stages = [];
let childStages = [];
let currentStage = 0;
let childStage = 0;
let timer = 0;
let stageInterval = 60;
let childLifeStarted = false;
let boardImg;
function preload() {
boardImg = loadImage("board.png"); // Load the board game image
}
class Stage {
constructor(x, y, emoji, family = []) {
this.x = x;
this.y = y;
this.emoji = emoji;
this.family = family;
}
display() {
fill(100, 150, 200);
ellipse(this.x, this.y, 50, 50); // Background circle
fill(0);
textSize(30);
text(this.emoji, this.x, this.y); // Main emoji
textSize(16);
for (let i = 0; i < this.family.length; i++) {
text(this.family[i], this.x - 15 + i * 15, this.y + 25); // Display family emojis below
}
}
}
function setup() {
createCanvas(1024, 700); // Match the size of the board game image
textAlign(CENTER, CENTER);
// Define positions for the dad's life stages
stages = [
new Stage(100, 100, "🏥"), // Birth in Hospital
new Stage(200, 100, "🏠", ["👨", "👩", "👶"]), // Home
new Stage(300, 100, "📚", ["👨🎓"]), // School
new Stage(400, 100, "👩❤️👨"), // Meets Partner
new Stage(500, 100, "💍", ["🤵", "👰♀️"]), // Marriage
new Stage(600, 100, "👶", ["👨🦰", "👩🦰", "👶"]), // First Child
new Stage(700, 100, "🏡", ["👨🦰", "👩🦰", "👦"]), // First Home
new Stage(800, 100, "💼"), // Career
new Stage(900, 100, "🧓", ["👵"]), // Retirement
new Stage(1000, 100, "👴"), // Old Age
new Stage(1100, 100, "🏥"), // End in Hospital
];
// Define positions for the child's life stages
childStages = [
new Stage(100, 400, "👶"), // Born
new Stage(200, 400, "📚", ["👦🎓"]), // School
new Stage(300, 400, "🏈"), // Hobbies/Sports
new Stage(400, 400, "🎓", ["🎓", "🎉"]), // Graduation
new Stage(500, 400, "💼", ["💻", "📈"]), // Career
new Stage(600, 400, "🏡", ["🔑", "🏠"]), // Own Home
new Stage(700, 400, "💍", ["🤵", "👰"]), // Marriage
new Stage(800, 400, "👶", ["👨🦰", "👩🦰", "👶"]), // Next Generation
];
}
function draw() {
background(255);
image(boardImg, 0, 0, width, height); // Draw the board game background
// Draw the dad's life trail
stroke(0);
noFill();
beginShape();
for (let i = 0; i < currentStage + 1; i++) {
vertex(stages[i].x, stages[i].y);
}
endShape();
// Draw the child's life trail if started
if (childLifeStarted) {
beginShape();
for (let i = 0; i < childStage + 1; i++) {
vertex(childStages[i].x, childStages[i].y);
}
endShape();
}
// Display the dad's life stages
for (let i = 0; i < currentStage + 1; i++) {
stages[i].display();
}
// Display the child's life stages if started
if (childLifeStarted) {
for (let i = 0; i < childStage + 1; i++) {
childStages[i].display();
}
}
// Timer for stage progression
timer++;
if (timer == stageInterval) {
if (currentStage < stages.length - 1) {
currentStage++;
if (stages[currentStage].emoji === "👶") {
childLifeStarted = true; // Start the child's timeline
}
}
if (childLifeStarted && childStage < childStages.length - 1) {
childStage++;
}
timer = 0; // Reset timer
}
}