Code Sketch
Bixuu02
Category: Programming
// ============================================================
// 12 GREAT HISTORICAL & LEGENDARY PERSONALITIES SYSTEM
// ============================================================
cleari()
originBottomLeft()
// ============================================================
// APP STATES & VARIABLES
// ============================================================
var screen = 0
var selectedPersonality = ""
// Animation Variables for background stars/sparkles
class Star(val x: Double, val y: Double, val size: Double) {
var phase = randomDouble(6.28)
def step() { phase += 0.04 }
def view(canvas: CanvasDraw) {
val brightness = 150 + (math.sin(phase) * 80).toInt
canvas.noStroke()
canvas.fill(255, 255, 200, brightness)
canvas.ellipse(x, y, size, size)
}
}
val stars = ArrayBuffer.empty[Star]
for (i <- 0 until 50) {
stars.append(new Star(randomDouble(cwidth), randomDouble(cheight), 1.0 + randomDouble(2.5)))
}
// ============================================================
// SCREEN 0: WELCOME LETTER SCREEN
// ============================================================
def drawLetterScreen(canvas: CanvasDraw) {
canvas.background(20, 30, 50)
repeatFor(stars) { s => s.view(canvas) }
// Letter Card
canvas.fill(255, 250, 240)
canvas.stroke(218, 165, 32)
canvas.strokeWeight(4)
canvas.rect(cwidth/2 - 250, cheight/2 - 190, 500, 380)
// Title
canvas.fill(139, 0, 0)
canvas.text("12 GREAT HISTORICAL PERSONALITIES", cwidth/2 - 165, cheight/2 + 150)
// Letter Body
canvas.fill(40, 40, 40)
canvas.text("Dear Reader,", cwidth/2 - 220, cheight/2 + 110)
canvas.text("Welcome! Explore the inspiring biographies, commemorative", cwidth/2 - 220, cheight/2 + 80)
canvas.text("days, major works, and powerful thoughts of 12 legendary", cwidth/2 - 220, cheight/2 + 55)
canvas.text("icons, social reformers, and brave freedom fighters.", cwidth/2 - 220, cheight/2 + 30)
canvas.fill(0, 100, 0)
canvas.text("Click below to view all 12 personalities.", cwidth/2 - 220, cheight/2 - 10)
// Button: See All Personalities
canvas.fill(30, 144, 255)
canvas.noStroke()
canvas.rect(cwidth/2 - 150, cheight/2 - 110, 300, 50)
canvas.fill(255, 255, 255)
canvas.text("SEE ALL 12 PERSONALITIES", cwidth/2 - 115, cheight/2 - 80)
}
// ============================================================
// SCREEN 1: SELECT PERSONALITIES SCREEN (12 ICONS GRID - 2 Columns x 6 Rows)
// ============================================================
def drawPersonalitiesSelectionScreen(canvas: CanvasDraw) {
canvas.background(30, 20, 40)
repeatFor(stars) { s => s.view(canvas) }
canvas.fill(255, 215, 0)
canvas.text("CHOOSE A GREAT ICON (12 LEGENDS)", cwidth/2 - 145, cheight - 30)
// Array of 12 Legends (6 rows, 2 columns)
val names = Array(
"Chhatrapati Shivaji", "Chhatrapati Sambhaji",
"Mahatma Jyotiba", "Savitribai Phule",
"B. R. Ambedkar", "Mahatma Gandhi",
"Netaji Subhas Bose", "Lokmanya Tilak",
"Rani Lakshmibai", "Rajmata Jijau",
"Sarojini Naidu", "Swami Vivekananda"
)
for (i <- 0 until 12) {
val col = i % 2
val row = i / 2
val bx = if (col == 0) cwidth/2 - 220 else cwidth/2 + 20
// Perfectly spaced 6 rows vertically
val by = (cheight/2 + 130) - (row * 46)
// Option Card Box
canvas.fill(255, 248, 220)
canvas.stroke(212, 175, 55)
canvas.strokeWeight(1.5)
canvas.rect(bx, by, 200, 38)
// Text inside box
canvas.fill(80, 0, 0)
canvas.noStroke()
canvas.text(names(i), bx + 10, by + 24)
}
// "GO TO LAST" Button at the top
canvas.fill(180, 50, 50)
canvas.noStroke()
canvas.rect(cwidth/2 - 100, 15, 200, 30)
canvas.fill(255, 255, 255)
canvas.text("GO TO LAST", cwidth/2 - 40, 33)
}
// ============================================================
// SCREEN 2: DISPLAY BIO, COMMEMORATIVE DAYS & THOUGHTS
// ============================================================
def drawThoughtsScreen(canvas: CanvasDraw) {
canvas.background(15, 25, 35)
repeatFor(stars) { s => s.view(canvas) }
// Header showing selected personality
canvas.fill(255, 215, 0)
canvas.text(selectedPersonality, cwidth/2 - (selectedPersonality.length * 4), cheight - 35)
// Content Box for Bio, Festival Day & Quotes
canvas.fill(245, 245, 220)
canvas.stroke(200, 150, 50)
canvas.strokeWeight(3)
canvas.rect(cwidth/2 - 245, cheight/2 - 165, 490, 310)
canvas.fill(30, 30, 30)
canvas.noStroke()
// Display details for all 12 personalities
if (selectedPersonality == "Chhatrapati Shivaji") {
canvas.text("Era: 1630 - 1680 | Day: Shivjayanti (19 Feb)", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Founder of Swarajya, Rayat-Priya King", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Established Hindavi Swarajya, Navy Pioneer", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Freedom is a boon, which everyone has the right to receive.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"Never bend your head, always hold it high!\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Chhatrapati Sambhaji") {
canvas.text("Era: 1657 - 1689 | Day: Shivrajyabhishek / Martyrdom", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Brave Chhatrapati, Fearless Warrior", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Defended Maratha Empire with supreme valor", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"True bravery lies in standing firm against injustice.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"Dharma and Swarajya protect those who protect them.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Mahatma Jyotiba") {
canvas.text("Born: 11 Apr 1827 | Day: Jyotirao Phule Jayanti (11 Apr)", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Social Reformer, Founder of Satyashodhak Samaj", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Championed education for lower castes & women", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Education is the key to upliftment and freedom.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"Knowledge brings light, ignorance brings darkness.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Savitribai Phule") {
canvas.text("Born: 3 Jan 1831 | Day: Balika Divas (3 Jan)", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: First Female Teacher of India, Poetess", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Pioneer of modern women's education in India", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Awake, arise and search for knowledge.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"Without education, intellect is lost.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "B. R. Ambedkar") {
canvas.text("Born: 14 Apr 1891 | Day: Constitution Day (26 Nov)", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Chief Architect of Indian Constitution", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Social Reformer, Economist, Jurist", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Educate, Agitate, Organize.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"Cultivation of mind should be the ultimate aim.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Mahatma Gandhi") {
canvas.text("Born: 2 Oct 1869 | Day: Gandhi Jayanti (2 Oct)", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Apostle of Peace, Father of the Nation", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Led Indian Independence via Ahimsa & Satyagraha", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Be the change that you wish to see in the world.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"In a gentle way, you can shake the world.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Netaji Subhas Bose") {
canvas.text("Born: 23 Jan 1897 | Day: Parakram Divas (23 Jan)", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Netaji, Supreme Commander of INA", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Azad Hind Fauj, 'Delhi Chalo' Movement", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Give me blood, and I shall give you freedom!\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"Freedom is not given, it is taken.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Lokmanya Tilak") {
canvas.text("Born: 23 July 1856 | Day: Lokmanya Jayanti", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Father of Indian Unrest, Nationalist Leader", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Sarvajanik Ganeshotsav, Swadeshi Movement", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Swaraj is my birthright and I shall have it!\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"Progress is tied with courage and action.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Rani Lakshmibai") {
canvas.text("Born: 19 Nov 1828 | Day: Veerangana Diwas", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Queen of Jhansi, Fearless Freedom Fighter", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Heroic resistance in Revolt of 1857", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Main apni Jhansi nahi doongi!\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"Better to die with honor than live in slavery.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Rajmata Jijau") {
canvas.text("Born: 12 Jan 1598 | Day: Rajmata Jijau Jayanti", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Mother of Swarajya, Visionary Mentor", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Shaped young Shivaji into a righteous king", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Instill high character and values in children.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"A visionary mother builds a victorious nation.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Sarojini Naidu") {
canvas.text("Born: 13 Feb 1879 | Day: National Women's Day (13 Feb)", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Nightingale of India, Freedom Fighter", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: First Indian Woman Governor, Poetess", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"A country's greatness lies in its undying ideals.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"We want finer ideals, not mere material success.\"", cwidth/2 - 230, cheight/2 - 0)
}
else if (selectedPersonality == "Swami Vivekananda") {
canvas.text("Born: 12 Jan 1863 | Day: National Youth Day (12 Jan)", cwidth/2 - 230, cheight/2 + 115)
canvas.text("Title: Spiritual Leader, Philosopher", cwidth/2 - 230, cheight/2 + 95)
canvas.text("Major Work: Spread Vedanta & Yoga, Ramakrishna Mission", cwidth/2 - 230, cheight/2 + 75)
canvas.text("Best Quote / Thought:", cwidth/2 - 230, cheight/2 + 45)
canvas.text("\"Arise, awake, and do not stop until goal is reached.\"", cwidth/2 - 230, cheight/2 + 20)
canvas.text("\"You have to grow from the inside out.\"", cwidth/2 - 230, cheight/2 - 0)
}
// Bottom Navigation: Back to list
canvas.fill(0, 150, 100)
canvas.rect(cwidth/2 - 140, 15, 280, 32)
canvas.fill(255, 255, 255)
canvas.text("BACK TO 12 PERSONALITIES", cwidth/2 - 95, 27)
}
// ============================================================
// SCREEN 3: FINAL DEDICATION SCREEN (BIXUU MESSAGE)
// ============================================================
def drawFinalScreen(canvas: CanvasDraw) {
canvas.background(25, 10, 35)
repeatFor(stars) { s => s.view(canvas) }
// Message Card
canvas.fill(255, 245, 230)
canvas.stroke(255, 215, 0)
canvas.strokeWeight(4)
canvas.rect(cwidth/2 - 240, cheight/2 - 140, 480, 280)
canvas.fill(200, 30, 30)
canvas.text("THANK YOU FOR EXPLORING!", cwidth/2 - 130, cheight/2 + 95)
canvas.fill(40, 40, 40)
canvas.text("bixuu will keep making best and new", cwidth/2 - 210, cheight/2 + 45)
canvas.text("historical games for you!", cwidth/2 - 210, cheight/2 + 20)
canvas.fill(0, 100, 150)
canvas.text("Keep learning and stay inspired!", cwidth/2 - 210, cheight/2 - 15)
// Back to Home Button
canvas.fill(120, 50, 180)
canvas.noStroke()
canvas.rect(cwidth/2 - 120, 20, 240, 38)
canvas.fill(255, 255, 255)
canvas.text("RESTART APP", cwidth/2 - 50, 33)
}
// ============================================================
// CLICK HANDLER
// ============================================================
def handleClick(x: Double, y: Double) {
if (screen == 0) {
// Click "SEE ALL 12 PERSONALITIES"
if (x >= cwidth/2 - 150 && x <= cwidth/2 + 150 && y >= cheight/2 - 110 && y <= cheight/2 - 60) {
screen = 1
}
}
else if (screen == 1) {
// Check click on "GO TO LAST" Button
if (x >= cwidth/2 - 100 && x <= cwidth/2 + 100 && y >= 15 && y <= 45) {
screen = 3
} else {
// Select one of the 12 Personalities
val names = Array(
"Chhatrapati Shivaji", "Chhatrapati Sambhaji",
"Mahatma Jyotiba", "Savitribai Phule",
"B. R. Ambedkar", "Mahatma Gandhi",
"Netaji Subhas Bose", "Lokmanya Tilak",
"Rani Lakshmibai", "Rajmata Jijau",
"Sarojini Naidu", "Swami Vivekananda"
)
for (i <- 0 until 12) {
val col = i % 2
val row = i / 2
val bx = if (col == 0) cwidth/2 - 220 else cwidth/2 + 20
val by = (cheight/2 + 130) - (row * 46)
if (x >= bx && x <= bx + 200 && y >= by && y <= by + 38) {
selectedPersonality = names(i)
screen = 2
}
}
}
}
else if (screen == 2) {
// Click "BACK TO 12 PERSONALITIES"
if (x >= cwidth/2 - 140 && x <= cwidth/2 + 140 && y >= 15 && y <= 47) {
screen = 1
}
}
else if (screen == 3) {
// Click "RESTART APP"
if (x >= cwidth/2 - 120 && x <= cwidth/2 + 120 && y >= 20 && y <= 58) {
screen = 0
}
}
}
onMouseClick { (x, y) => handleClick(x, y) }
// ============================================================
// MAIN ANIMATION LOOP
// ============================================================
animateWithCanvasDraw { canvas =>
repeatFor(stars) { s => s.step() }
if (screen == 0) {
drawLetterScreen(canvas)
} else if (screen == 1) {
drawPersonalitiesSelectionScreen(canvas)
} else if (screen == 2) {
drawThoughtsScreen(canvas)
} else if (screen == 3) {
drawFinalScreen(canvas)
}
}