Code Sketch
mhalsakant coders
// --- SHREE MHALSAKANT VIDYALAYA - SIDE NAMES LAYOUT ---
clear()
setBackground(Color(8, 12, 22))
var inLab = false
var codeState = 0
var animTick = 0.0
// ?? ???????????????? ??????????????? ????
val studentNames = Array(
"Yadnesh", "Bhavesh", "Alok", "Atharva", "Bhimraj",
"Aishvarya", "Rudra", "Siddhi", "Shravni", "Aarohi",
"Navya", "Bhakti", "Sanvi", "Shlok", "Nivedita",
"Pranav", "Tanvi", "Aditya", "Ananya", "Omkar",
"Isha", "Siddhesh", "Riya", "Harsh", "Diya",
"Varun", "Kavya", "Soham", "Sneha", "Yash"
)
// ?????????? ???????? (true = ????? / Girl, false = ????? / Boy)
val isGirl = Array(
false, false, false, false, false,
true, false, true, true, true,
true, true, true, false, true,
false, true, false, true, false,
true, false, true, false, true,
false, true, false, true, false
)
def drawUltraScene(): Unit = {
erasePictures()
if (!inLab) {
// ==========================================
// SECTION 1: BIG & GRAND SCHOOL BUILDING VIEW
// ==========================================
// ?. ???????? ????
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)
}
// ?. ???? ? ???? ?????? ?????
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)
}
}
// ?. ????? ???????????
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)
// ?. ?????? ?????? ????
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)
// ?. ???? ?????
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)
// ?. ????? ??? ????? ??????
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: 30 COMPUTERS IN A CIRCLE LAYOUT
// ==========================================
// ?. ??? ????? ????
val labHeader = Picture.rectangle(570, 40)
labHeader.setFillColor(Color(15, 25, 45))
labHeader.setPenColor(Color(0, 255, 200))
labHeader.setPenThickness(2)
labHeader.setPosition(-285, 205)
draw(labHeader)
val labTitle = Picture.text("? 30 COMPUTERS CIRCULAR KOJO CODING LAB ?", 12)
labTitle.setPenColor(Color(0, 255, 200))
labTitle.setPosition(-200, 218)
draw(labTitle)
// ?. ????????? ?????? ??? ????? ??????? ?????
val centerRing = Picture.circle(180)
centerRing.setPenColor(Color(30, 90, 180))
centerRing.setPenThickness(2)
centerRing.setPosition(0, -10)
draw(centerRing)
val centerBoard = Picture.rectangle(230, 85)
centerBoard.setFillColor(Color(15, 25, 50))
centerBoard.setPenColor(Color(255, 215, 0))
centerBoard.setPenThickness(2)
centerBoard.setPosition(-115, -50)
draw(centerBoard)
val msgLine1 = Picture.text("? SEE YOUR NAME! ?", 11)
msgLine1.setPenColor(Color(0, 255, 200))
msgLine1.setPosition(-80, -10)
draw(msgLine1)
val msgLine2 = Picture.text("Your name is in,", 10)
msgLine2.setPenColor(Color(255, 255, 255))
msgLine2.setPosition(-58, -26)
draw(msgLine2)
val msgLine3 = Picture.text("then look anytime! ?", 10)
msgLine3.setPenColor(Color(255, 215, 0))
msgLine3.setPosition(-68, -42)
draw(msgLine3)
// ?. ?? ???????????? ??? ????-??????? ?????
val totalComputers = 30
val radius = 175.0
for (i <- 0 until totalComputers) {
val angle = (2 * math.Pi / totalComputers) * i
val cx = radius * math.cos(angle)
val cy = radius * math.sin(angle) - 10.0
// A. ?????? ?????
val monOuter = Picture.rectangle(26, 20)
monOuter.setFillColor(Color(25, 30, 45))
monOuter.setPenColor(Color(255, 215, 0))
monOuter.setPenThickness(1)
monOuter.setPosition(cx - 13, cy - 10)
draw(monOuter)
// B. ???????
val monScreen = Picture.rectangle(22, 16)
monScreen.setFillColor(Color(10, 12, 20))
monScreen.setPosition(cx - 11, cy - 8)
draw(monScreen)
// C. Live Kojo Code Pattern
if (codeState == 0) {
val pStar = Picture.circle(4)
pStar.setPenColor(Color(0, 255, 200))
pStar.setPosition(cx, cy)
draw(pStar)
} else if (codeState == 1) {
val pSq = Picture.rectangle(6, 6)
pSq.setFillColor(Color(255, 80, 80))
pSq.setPosition(cx - 3, cy - 3)
draw(pSq)
} else {
val pRing = Picture.circle(5)
pRing.setPenColor(Color(255, 215, 0))
pRing.setPosition(cx, cy)
draw(pRing)
}
// D. ????? / ????? ???????? (Avatar)
val head = Picture.circle(5)
head.setFillColor(Color(255, 205, 165))
head.setPosition(cx, cy - 17)
draw(head)
if (isGirl(i)) {
val hairPink = Picture.circle(6)
hairPink.setFillColor(Color(255, 105, 180))
hairPink.setPosition(cx, cy - 15)
draw(hairPink)
val dress = Picture.rectangle(10, 10)
dress.setFillColor(Color(255, 120, 180))
dress.setPosition(cx - 5, cy - 28)
draw(dress)
} else {
val hairBlack = Picture.circle(5)
hairBlack.setFillColor(Color(30, 30, 30))
hairBlack.setPosition(cx, cy - 15)
draw(hairBlack)
val shirt = Picture.rectangle(10, 10)
shirt.setFillColor(Color(30, 120, 220))
shirt.setPosition(cx - 5, cy - 28)
draw(shirt)
}
// E. ??? ?????? ??????? ????? (Side Placement Logic)
// ?????? ???????? ????????? ??? ???????, ?????? ??????????? ???????
val sNameText = Picture.text(studentNames(i), 6)
sNameText.setPenColor(Color(255, 255, 255))
val sideOffsetX = if (cx >= 0) 18 else -48
sNameText.setPosition(cx + sideOffsetX, cy - 5)
draw(sNameText)
}
// ?. HUD Code Display Box
val codeHud = Picture.rectangle(550, 32)
codeHud.setFillColor(Color(10, 15, 25))
codeHud.setPenColor(Color(0, 255, 200))
codeHud.setPenThickness(2)
codeHud.setPosition(-275, -200)
draw(codeHud)
val currentCodeStr = if (codeState == 0) {
"30 STUDENTS KOJO LAB: repeat(36) { forward(10); right(10); setPenColor(green) }"
} else if (codeState == 1) {
"30 STUDENTS KOJO LAB: setFillColor(red); draw(Rectangle(20,20)); rotate(12)"
} else {
"30 STUDENTS KOJO LAB: animate { circle.scale(1.2); setPenColor(gold) }"
}
val hudText = Picture.text(currentCodeStr, 8)
hudText.setPenColor(Color(255, 255, 255))
hudText.setPosition(-250, -188)
draw(hudText)
val labInstruction = Picture.text("? [ CLICK ANYWHERE: ???? ?? ???????????????? Kojo ??? ???????????! ]", 10)
labInstruction.setPenColor(Color(255, 215, 0))
labInstruction.setPosition(-210, -225)
draw(labInstruction)
}
}
drawUltraScene()
// ????????? ???
animateWithState(0.0) { frame =>
animTick += 1.0
if (inLab && animTick.toInt % 30 == 0) {
playNote(72 + random(-2, 4), 50)
}
drawUltraScene()
frame + 1.0
}
// ???? ??????
onMouseClick { (x, y) =>
if (!inLab) {
inLab = true
playNote(84, 200)
} else {
codeState = (codeState + 1) % 3
playNote(78, 100)
}
drawUltraScene()
}