Code Sketch


code click for friends
By: Mhalsakant School
// --- SHREE MHALSAKANT VIDYALAYA KOJO LAB WITH SPECIFIC STUDENT ORDER ---
clear()
setBackground(Color(8, 12, 22))

var inLab = false
var codeState = 0
var animTick = 0.0

def drawUltraScene(): Unit = {
  erasePictures()

  if (!inLab) {
    // ==========================================
    // SECTION 1: BIG & GRAND SCHOOL BUILDING VIEW
    // ==========================================

    // 1. ???????? ??????? ????
    for (x <- -280 to 280 by 70) {
      val star = Picture.circle(1)
      star.setFillColor(Color(200, 220, 255))
      star.setPosition(x.toDouble, 210)
      draw(star)
    }

    // 2. ???? ? ???? ?????? ?????
    val mainBuilding = Picture.rectangle(520, 260)
    mainBuilding.setFillColor(Color(220, 190, 150))
    mainBuilding.setPenColor(Color(120, 60, 20))
    mainBuilding.setPenThickness(3)
    mainBuilding.setPosition(-260, -110)
    draw(mainBuilding)

    // ?????? ?????
    val roof = Picture.rectangle(550, 30)
    roof.setFillColor(Color(180, 40, 30))
    roof.setPosition(-275, 150)
    draw(roof)

    // ? ??????????? ???????
    for (floorY <- Array(80, 10, -60)) {
      for (winX <- -220 to 220 by 70) {
        val windowFrame = Picture.rectangle(42, 48)
        windowFrame.setFillColor(Color(160, 220, 255))
        windowFrame.setPenColor(Color(40, 40, 40))
        windowFrame.setPenThickness(2)
        windowFrame.setPosition(winX.toDouble, floorY.toDouble)
        draw(windowFrame)
      }
    }

    // 3. ????? ???????????
    val entranceGate = Picture.rectangle(80, 110)
    entranceGate.setFillColor(Color(50, 25, 10))
    entranceGate.setPenColor(Color(255, 215, 0))
    entranceGate.setPenThickness(2)
    entranceGate.setPosition(-40, -110)
    draw(entranceGate)

    // 4. ?????? ?????? ????
    val nameBoard = Picture.rectangle(440, 50)
    nameBoard.setFillColor(Color(15, 45, 95))
    nameBoard.setPenColor(Color(255, 215, 0))
    nameBoard.setPenThickness(3)
    nameBoard.setPosition(-220, 185)
    draw(nameBoard)

    val schoolName = Picture.text("? ???? ??????????? ???????? ?", 18)
    schoolName.setPenColor(Color(255, 255, 255))
    schoolName.setPosition(-190, 200)
    draw(schoolName)

    // 5. ???? ?????
    val pole = Picture.rectangle(4, 120)
    pole.setFillColor(Color(200, 200, 200))
    pole.setPosition(-280, -110)
    draw(pole)

    val flagSaffron = Picture.rectangle(35, 10)
    flagSaffron.setFillColor(Color(255, 120, 0))
    flagSaffron.setPosition(-280, -10)
    draw(flagSaffron)

    val flagWhite = Picture.rectangle(35, 10)
    flagWhite.setFillColor(Color(255, 255, 255))
    flagWhite.setPosition(-280, -20)
    draw(flagWhite)

    val flagGreen = Picture.rectangle(35, 10)
    flagGreen.setFillColor(Color(0, 150, 50))
    flagGreen.setPosition(-280, -30)
    draw(flagGreen)

    // 6. ????? ??? ????? ??????
    val pointerBox = Picture.rectangle(380, 35)
    pointerBox.setFillColor(Color(0, 255, 200))
    pointerBox.setPosition(-190, -180)
    draw(pointerBox)

    val pointerText = Picture.text("? [ ???? ???????? ?????????? ???????? ???????? CLICK ???! ]", 11)
    pointerText.setPenColor(Color(10, 20, 30))
    pointerText.setPosition(-180, -168)
    draw(pointerText)

  } else {
    // ==========================================
    // SECTION 2: KOJO LAB WITH SPECIFIC 6 STUDENTS
    // ==========================================

    // 1. ??? ????
    val labHeader = Picture.rectangle(570, 45)
    labHeader.setFillColor(Color(15, 25, 45))
    labHeader.setPenColor(Color(0, 255, 200))
    labHeader.setPenThickness(2)
    labHeader.setPosition(-285, 195)
    draw(labHeader)

    val labTitle = Picture.text("? SHREE MHALSAKANT VIDYALAYA - KOJO CODING LAB ?", 13)
    labTitle.setPenColor(Color(0, 255, 200))
    labTitle.setPosition(-245, 210)
    draw(labTitle)

    // 2. ?????????? ????
    val deskTop = Picture.rectangle(580, 20)
    deskTop.setFillColor(Color(80, 50, 30))
    deskTop.setPosition(-290, -80)
    draw(deskTop)

    val deskStand = Picture.rectangle(570, 80)
    deskStand.setFillColor(Color(40, 25, 15))
    deskStand.setPosition(-285, -160)
    draw(deskStand)

    // 3. ? ?????????? ? ??????? ??????????? (?????? - Yadnesh ?????? ?????)
    // ????: Yadnesh, Atharva, Alok, Bhavesh, Shreyash, Shlok
    val studentXPositions = Array(-235, -141, -47, 47, 141, 235)
    val studentNames = Array("Yadnesh", "Atharva", "Alok", "Bhavesh", "Shreyash", "Shlok")

    for (i <- 0 until studentXPositions.length) {
      val sX = studentXPositions(i)

      // A. ?????? ?????
      val monOuter = Picture.rectangle(82, 68)
      monOuter.setFillColor(Color(25, 30, 45))
      monOuter.setPenColor(Color(255, 215, 0))
      monOuter.setPenThickness(2)
      monOuter.setPosition(sX - 41, -35)
      draw(monOuter)

      // B. ???????? ???????
      val monScreen = Picture.rectangle(74, 60)
      monScreen.setFillColor(Color(10, 12, 20))
      monScreen.setPosition(sX - 37, -31)
      draw(monScreen)

      // ??????
      val monStand = Picture.rectangle(12, 15)
      monStand.setFillColor(Color(60, 60, 60))
      monStand.setPosition(sX - 6, -50)
      draw(monStand)

      val monBase = Picture.rectangle(26, 6)
      monBase.setFillColor(Color(40, 40, 40))
      monBase.setPosition(sX - 13, -56)
      draw(monBase)

      // C. ??????? ??? ????
      val kb = Picture.rectangle(44, 9)
      kb.setFillColor(Color(30, 35, 50))
      kb.setPenColor(Color(100, 100, 100))
      kb.setPosition(sX - 26, -73)
      draw(kb)

      val mouse = Picture.circle(3)
      mouse.setFillColor(Color(200, 200, 200))
      mouse.setPosition(sX + 21, -71)
      draw(mouse)

      // D. ??????????? Live Kojo Code Patterns
      if (codeState == 0) {
        val pStar = Picture.circle(12)
        pStar.setPenColor(Color(0, 255, 200))
        pStar.setPenThickness(2)
        pStar.setPosition(sX.toDouble, 1)
        draw(pStar)
      } else if (codeState == 1) {
        val pSquare = Picture.rectangle(18, 18)
        pSquare.setFillColor(Color(255, 80, 80))
        pSquare.setPosition(sX - 9, -10)
        draw(pSquare)
      } else {
        val pRing = Picture.circle(15)
        pRing.setPenColor(Color(255, 215, 0))
        pRing.setPenThickness(2)
        pRing.setPosition(sX.toDouble, 1)
        draw(pRing)
      }

      // E. ? ??????????????? ?????? ??? ?????????
      // ????
      val head = Picture.circle(16)
      head.setFillColor(Color(255, 205, 165))
      head.setPosition(sX.toDouble, -110)
      draw(head)

      // ????
      val hair = Picture.circle(16)
      hair.setFillColor(Color(20, 20, 20))
      hair.setPosition(sX.toDouble, -104)
      draw(hair)

      // ????
      val eyeL = Picture.circle(2)
      eyeL.setFillColor(Color(0, 0, 0))
      eyeL.setPosition(sX - 5, -106)
      draw(eyeL)

      val eyeR = Picture.circle(2)
      eyeR.setFillColor(Color(0, 0, 0))
      eyeR.setPosition(sX + 5, -106)
      draw(eyeR)

      // ????????? ??? ???
      val body = Picture.rectangle(40, 48)
      body.setFillColor(Color(30, 90, 180)) // Royal Blue Uniform
      body.setPosition(sX - 20, -160)
      draw(body)

      val tie = Picture.rectangle(5, 22)
      tie.setFillColor(Color(200, 30, 30)) // Red School Tie
      tie.setPosition(sX - 2, -145)
      draw(tie)

      // ?????????????? ???
      val sNameText = Picture.text(studentNames(i), 8)
      sNameText.setPenColor(Color(255, 255, 255))
      sNameText.setPosition(sX - 17, -177)
      draw(sNameText)
    }

    // 4. HUD Code Display Box
    val codeHud = Picture.rectangle(550, 42)
    codeHud.setFillColor(Color(10, 15, 25))
    codeHud.setPenColor(Color(0, 255, 200))
    codeHud.setPenThickness(2)
    codeHud.setPosition(-275, 135)
    draw(codeHud)

    val currentCodeStr = if (codeState == 0) {
      "STUDENTS (Yadnesh, Atharva, Alok, Bhavesh, Shreyash, Shlok): repeat(8) { forward(50); right(45) }"
    } else if (codeState == 1) {
      "STUDENTS (Yadnesh, Atharva, Alok, Bhavesh, Shreyash, Shlok): setFillColor(red); draw(Rectangle(30,30))"
    } else {
      "STUDENTS (Yadnesh, Atharva, Alok, Bhavesh, Shreyash, Shlok): animate { circle.scale(1.5); rotate(5) }"
    }

    val hudText = Picture.text(currentCodeStr, 8)
    hudText.setPenColor(Color(255, 255, 255))
    hudText.setPosition(-265, 152)
    draw(hudText)

    val labInstruction = Picture.text("? [ CLICK ANYWHERE: ???? ? ??????? Kojo ??? ????? ??????????! ]", 11)
    labInstruction.setPenColor(Color(255, 215, 0))
    labInstruction.setPosition(-220, -220)
    draw(labInstruction)
  }
}

drawUltraScene()

// Typing Sound Animation Loop
animateWithState(0.0) { frame =>
  animTick += 1.0
  if (inLab && animTick.toInt % 25 == 0) {
    playNote(72 + random(-2, 4), 50) // Coding Typing Beep
  }
  drawUltraScene()
  frame + 1.0
}

// Mouse Click Event
onMouseClick { (x, y) =>
  if (!inLab) {
    inLab = true
    playNote(84, 200) // Welcome Sound
  } else {
    codeState = (codeState + 1) % 3
    playNote(78, 100) // Key press tone
  }
  drawUltraScene()
}