Code Sketch


Bixuu02
By: Mhalsakant School
Category: Programming
// ============================================================
// FAMOUS GANPATI MANDALS: LIVE STATUS, HISTORY & SPECIALTIES
// ============================================================

cleari()
originBottomLeft()

// ============================================================
// APP STATES & VARIABLES
// ============================================================
var screen = 0 // 0: Letter, 1: Mandals List, 2: Mandal Details, 3: Final Bixuu Message
var selectedMandal = ""

// 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, 215, 0, 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(40, 10, 20)
    repeatFor(stars) { s => s.view(canvas) }

    // Letter Card
    canvas.fill(255, 248, 220)
    canvas.stroke(255, 215, 0)
    canvas.strokeWeight(4)
    canvas.rect(cwidth/2 - 260, cheight/2 - 190, 520, 380)

    // Title
    canvas.fill(180, 0, 0)
    canvas.text("FAMOUS GANPATI MANDALS & LIVE DARSHAN", cwidth/2 - 200, cheight/2 + 150)

    // Letter Body
    canvas.fill(40, 40, 40)
    canvas.text("Dear Devotee,", cwidth/2 - 230, cheight/2 + 110)
    canvas.text("Welcome! Explore detailed history, exact addresses,", cwidth/2 - 230, cheight/2 + 80)
    canvas.text("blood donation records by Bollywood actors, and", cwidth/2 - 230, cheight/2 + 55)
    canvas.text("unique specialties of iconic Ganpati Mandals!", cwidth/2 - 230, cheight/2 + 30)
    
    canvas.fill(0, 100, 50)
    canvas.text("Click below to explore all Mandals.", cwidth/2 - 230, cheight/2 - 10)

    // Button: See All Mandals
    canvas.fill(220, 50, 50)
    canvas.noStroke()
    canvas.rect(cwidth/2 - 150, cheight/2 - 110, 300, 50)
    canvas.fill(255, 255, 255)
    canvas.text("EXPLORE GANPATI MANDALS", cwidth/2 - 115, cheight/2 - 80)
}

// ============================================================
// SCREEN 1: SELECT MANDAL SCREEN + GO TO LAST BUTTON
// ============================================================
def drawMandalsSelectionScreen(canvas: CanvasDraw) {
    canvas.background(30, 15, 25)
    repeatFor(stars) { s => s.view(canvas) }

    canvas.fill(255, 215, 0)
    canvas.text("CHOOSE A GANPATI MANDAL", cwidth/2 - 120, cheight - 35)

    val mandals = Array("Lalbaugcha Raja", "Dagdusheth Halwai", "Chinchpokli Chintamani", "Bhau Saheb Rangari")
    
    for (i <- 0 until 4) {
        val bx = if (i % 2 == 0) cwidth/2 - 220 else cwidth/2 + 20
        val by = if (i < 2) cheight/2 + 30 else cheight/2 - 100
        
        // Option Card Box
        canvas.fill(255, 248, 220)
        canvas.stroke(212, 175, 55)
        canvas.strokeWeight(3)
        canvas.rect(bx, by, 200, 90)

        // Text inside box
        canvas.fill(180, 0, 0)
        canvas.noStroke()
        canvas.text(mandals(i), bx + 15, by + 45)
    }

    // "GO TO LAST" Button below options
    canvas.fill(150, 30, 150)
    canvas.noStroke()
    canvas.rect(cwidth/2 - 120, 15, 240, 45)
    canvas.fill(255, 255, 255)
    canvas.text("GO TO LAST", cwidth/2 - 50, 35)
}

// ============================================================
// SCREEN 2: DISPLAY MANDAL DETAILS (ADDRESS, BLOOD DONATION, HISTORY)
// ============================================================
def drawMandalDetailScreen(canvas: CanvasDraw) {
    canvas.background(20, 10, 20)
    repeatFor(stars) { s => s.view(canvas) }

    // Header showing selected Mandal
    canvas.fill(255, 215, 0)
    canvas.text(selectedMandal, cwidth/2 - (selectedMandal.length * 4), cheight - 35)

    // Content Box for Details (Expanded to fit rich info)
    canvas.fill(255, 248, 220)
    canvas.stroke(212, 175, 55)
    canvas.strokeWeight(3)
    canvas.rect(cwidth/2 - 265, cheight/2 - 195, 530, 370)

    canvas.fill(30, 30, 30)
    canvas.noStroke()

    // Display rich details based on selected Mandal
    if (selectedMandal == "Lalbaugcha Raja") {
        canvas.text("Establishment: 12 September 1934", cwidth/2 - 250, cheight/2 + 145)
        canvas.text("Address: Dr. Ambedkar Road, Lalbaug, Mumbai", cwidth/2 - 250, cheight/2 + 125)
        canvas.text("Live Crowd & Blood Camp: 1.5+ Lakh daily; Mega", cwidth/2 - 250, cheight/2 + 105)
        canvas.text("blood drives supported by actors like Salman Khan.", cwidth/2 - 250, cheight/2 + 85)
        canvas.text("Why Famous: World-renowned 'Navsacha Ganpati'", cwidth/2 - 250, cheight/2 + 65)
        canvas.text("fulfilling all prayers with massive Mukh/Charan darshan.", cwidth/2 - 250, cheight/2 + 45)
        canvas.text("Ganpati Bappa Morya!", cwidth/2 - 250, cheight/2 + 5)
    } 
    else if (selectedMandal == "Dagdusheth Halwai") {
        canvas.text("Establishment: 1893 (Centuries of tradition)", cwidth/2 - 250, cheight/2 + 145)
        canvas.text("Address: Ganpati Chowk, Budhwar Peth, Pune", cwidth/2 - 250, cheight/2 + 125)
        canvas.text("Live Crowd & Blood Camp: Massive festive rush;", cwidth/2 - 250, cheight/2 + 105)
        canvas.text("Actors like Akshay Kumar & Riteish Deshmukh support drives.", cwidth/2 - 250, cheight/2 + 85)
        canvas.text("Why Famous: Magnificent golden idol, grand temple", cwidth/2 - 250, cheight/2 + 65)
        canvas.text("architecture, extensive social welfare & Deepotsav.", cwidth/2 - 250, cheight/2 + 45)
        canvas.text("Mangal Murti Morya!", cwidth/2 - 250, cheight/2 + 5)
    } 
    else if (selectedMandal == "Chinchpokli Chintamani") {
        canvas.text("Establishment: 1920 (Over a century old)", cwidth/2 - 250, cheight/2 + 145)
        canvas.text("Address: Dattaram Lad Marg, Chinchpokli, Mumbai", cwidth/2 - 250, cheight/2 + 125)
        canvas.text("Live Crowd & Blood Camp: High youth engagement;", cwidth/2 - 250, cheight/2 + 105)
        canvas.text("Prominent celebrity participation in annual blood camps.", cwidth/2 - 250, cheight/2 + 85)
        canvas.text("Why Famous: Historic sarvajanik mandal celebrated", cwidth/2 - 250, cheight/2 + 65)
        canvas.text("for royal artistic aesthetics and grand processions.", cwidth/2 - 250, cheight/2 + 45)
        canvas.text("Chintamani Ki Jai!", cwidth/2 - 250, cheight/2 + 5)
    } 
    else if (selectedMandal == "Bhau Saheb Rangari") {
        canvas.text("Establishment: 6 October 1892", cwidth/2 - 250, cheight/2 + 145)
        canvas.text("Address: Vasant Talkies Chowk, Shaniwar Peth, Pune", cwidth/2 - 250, cheight/2 + 125)
        canvas.text("Live Crowd & Blood Camp: Moderate to High rush;", cwidth/2 - 250, cheight/2 + 105)
        canvas.text("Pioneering social initiatives and massive donation drives.", cwidth/2 - 250, cheight/2 + 85)
        canvas.text("Why Famous: First-ever Sarvajanik Ganpati Mandal", cwidth/2 - 250, cheight/2 + 65)
        canvas.text("founded by Bhausaheb Javalkar & Lokmanya Tilak.", cwidth/2 - 250, cheight/2 + 45)
        canvas.text("The pioneer of Public Ganesh Utsav!", cwidth/2 - 250, cheight/2 + 5)
    }

    // Bottom Navigation: Back to list
    canvas.fill(220, 50, 50)
    canvas.rect(cwidth/2 - 140, 15, 280, 40)
    canvas.fill(255, 255, 255)
    canvas.text("BACK TO MANDALS LIST", cwidth/2 - 90, 32)
}

// ============================================================
// SCREEN 3: FINAL DEDICATION SCREEN (BIXUU MESSAGE)
// ============================================================
def drawFinalScreen(canvas: CanvasDraw) {
    canvas.background(30, 10, 20)
    repeatFor(stars) { s => s.view(canvas) }

    // Message Card
    canvas.fill(255, 248, 220)
    canvas.stroke(255, 215, 0)
    canvas.strokeWeight(4)
    canvas.rect(cwidth/2 - 240, cheight/2 - 140, 480, 280)

    canvas.fill(180, 0, 0)
    canvas.text("GANPATI BAPPA MORYA!", cwidth/2 - 110, 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("festive and cultural apps for you!", cwidth/2 - 210, cheight/2 + 20)

    canvas.fill(0, 120, 50)
    canvas.text("May Lord Ganesha bless your home with joy!", cwidth/2 - 210, cheight/2 - 15)

    // Back to Home Button
    canvas.fill(150, 30, 150)
    canvas.noStroke()
    canvas.rect(cwidth/2 - 120, 20, 240, 45)
    canvas.fill(255, 255, 255)
    canvas.text("RESTART APP", cwidth/2 - 50, 40)
}

// ============================================================
// CLICK HANDLER
// ============================================================
def handleClick(x: Double, y: Double) {
    if (screen == 0) {
        // Click "EXPLORE GANPATI MANDALS"
        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 - 120 && x <= cwidth/2 + 120 && y >= 15 && y <= 60) {
            screen = 3
        } else {
            // Select one of the Mandals
            val mandals = Array("Lalbaugcha Raja", "Dagdusheth Halwai", "Chinchpokli Chintamani", "Bhau Saheb Rangari")
            for (i <- 0 until 4) {
                val bx = if (i % 2 == 0) cwidth/2 - 220 else cwidth/2 + 20
                val by = if (i < 2) cheight/2 + 30 else cheight/2 - 100
                if (x >= bx && x <= bx + 200 && y >= by && y <= by + 90) {
                    selectedMandal = mandals(i)
                    screen = 2
                }
            }
        }
    } 
    else if (screen == 2) {
        // Click "BACK TO MANDALS LIST"
        if (x >= cwidth/2 - 140 && x <= cwidth/2 + 140 && y >= 15 && y <= 55) {
            screen = 1
        }
    }
    else if (screen == 3) {
        // Click "RESTART APP"
        if (x >= cwidth/2 - 120 && x <= cwidth/2 + 120 && y >= 20 && y <= 65) {
            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) {
        drawMandalsSelectionScreen(canvas)
    } else if (screen == 2) {
        drawMandalDetailScreen(canvas)
    } else if (screen == 3) {
        drawFinalScreen(canvas)
    }
}