Code Sketch
jay ho [alok]
Category: Art
// --- AI Quantum-Matrix Independence Day Celebration: Army Parade leading into the 'Operation Sindoor' Interactive Mini-Game ---
cleari()
var timeStep = 0.0
var gameState = 0 // 0 = Army Parade & Tanks, 1 = Operation Sindoor Game Mode
var gameScore = 0
var targetX = 0.0
var targetY = 0.0
var targetActive = false
var messageTimer = 0.0
val anthemVerses = Array(
"Jana Gana Mana Adhinayaka Jaya He",
"Bhagya Vidhata",
"Punjab Sindh Gujarat Maratha",
"Dravida Utkala Banga",
"Vindhya Himachal Yamuna Ganga",
"Uchchala Jaladhi Taranga",
"Tava Shubha Name Jage",
"Tava Shubha Ashish Mange",
"Gaaye Tava Jaya Ganatha",
"Jana Gana Mana Mangala Dayaka Jaya He",
"Jaya Hey, Jaya Hey, Jaya Hey,",
"Jaya Jaya Jaya, Jaya Hey!"
)
animateWithState(0.0) { angle =>
erasePictures()
// 1. Deep Cyber-Matrix Space Background
setBackground(Color(2, 4, 12))
// Digital Rain / Matrix Grid Effect
for (col <- 0 until 20) {
val dropX = -270 + col * 28
val dropY = ((timeStep * 3 + col * 37) % 500) - 250
val codeChar = Picture.text(if ((col + angle.toInt) % 2 == 0) "1" else "0", 11)
codeChar.setPenColor(if (col % 3 == 0) Color(255, 153, 51, 80) else if (col % 3 == 1) Color(255, 255, 255, 80) else Color(18, 136, 7, 80))
codeChar.setPosition(dropX, dropY)
draw(codeChar)
}
// State Transition Check: Switch to Game Mode automatically after timeStep reaches 400 (~15 seconds of parade)
if (timeStep > 400.0 && gameState == 0) {
gameState = 1
targetActive = true
targetX = 100.0
targetY = -30.0
}
// 2. Central AI Quantum Hologram Core
val pulse = Math.sin(angle * 0.07) * 12.0
for (ring <- 1 to 4) {
val holoRing = Picture.circle(25 + ring * 14 + pulse)
holoRing.setFillColor(noColor)
holoRing.setPenColor(Color(0, 150 + ring * 25, 255, 90))
holoRing.setPenThickness(1.5)
holoRing.setPosition(0, 45)
draw(holoRing)
}
val coreHub = Picture.circle(18)
coreHub.setFillColor(Color(0, 220, 255))
coreHub.setPenColor(Color(255, 255, 255))
coreHub.setPenThickness(2)
coreHub.setPosition(0, 45)
draw(coreHub)
// 3. Holographic Tricolour Wave Banner (Top Center)
val bWidth = 260.0
val bHeight = 75.0
val cols = 26
val cWidth = bWidth / cols
for (c <- 0 until cols) {
val wave = Math.sin(angle * 0.08 + c * 0.35) * 5.0
val bx = -130.0 + (c * cWidth)
val sStrip = Picture.rect(cWidth + 1.0, bHeight / 3)
sStrip.setFillColor(Color(255, 153, 51))
sStrip.setPenColor(noColor)
sStrip.setPosition(bx + cWidth/2, 185 + wave)
draw(sStrip)
val wStrip = Picture.rect(cWidth + 1.0, bHeight / 3)
wStrip.setFillColor(Color(255, 255, 255))
wStrip.setPenColor(noColor)
wStrip.setPosition(bx + cWidth/2, 160 + wave)
draw(wStrip)
val gStrip = Picture.rect(cWidth + 1.0, bHeight / 3)
gStrip.setFillColor(Color(18, 136, 7))
gStrip.setPenColor(noColor)
gStrip.setPosition(bx + cWidth/2, 135 + wave)
draw(gStrip)
}
val qChakraX = 0.0
val qChakraY = 160.0
val chakraBack = Picture.circle(13)
chakraBack.setFillColor(Color(255, 255, 255))
chakraBack.setPenColor(Color(0, 56, 168))
chakraBack.setPenThickness(1.5)
chakraBack.setPosition(qChakraX, qChakraY)
draw(chakraBack)
for (spk <- 0 until 24) {
val sAngle = Math.toRadians(spk * 15 + angle * 2.5)
val lx = Math.cos(sAngle) * 11
val ly = Math.sin(sAngle) * 11
val spokeLine = Picture.line(lx, ly)
spokeLine.setPenColor(Color(0, 56, 168))
spokeLine.setPenThickness(1.0)
spokeLine.setPosition(qChakraX, qChakraY)
draw(spokeLine)
}
// 4. Header Titles based on Game State
if (gameState == 0) {
val headerShadow = Picture.text("AI QUANTUM INDEPENDENCE", 17)
headerShadow.setPenColor(Color(0, 40, 80))
headerShadow.setPosition(-105, -5)
draw(headerShadow)
val headerText = Picture.text("AI QUANTUM INDEPENDENCE", 17)
headerText.setPenColor(Color(0, 255, 220))
headerText.setPosition(-103, -3)
draw(headerText)
} else {
// Game Active Header Banner
val gameTitle = Picture.text("OPERATION SINDOOR: TACTICAL STRIKE", 15)
gameTitle.setPenColor(Color(255, 69, 0))
gameTitle.setPosition(-145, -5)
draw(gameTitle)
val scoreDisplay = Picture.text(s"DEFENSE SCORE: $gameScore", 13)
scoreDisplay.setPenColor(Color(255, 215, 0))
scoreDisplay.setPosition(-60, -25)
draw(scoreDisplay)
}
// 5. Helicopters Across Sky
val heliXOffset = ((timeStep * 1.5) % 600) - 300
for (heliIndex <- 0 until 2) {
val heliX = heliXOffset + (heliIndex * 240)
val heliY = 100.0 + (if (heliIndex == 0) 15.0 else -10.0)
if (heliX >= -280 && heliX <= 280) {
val cabin = Picture.rect(26, 10)
cabin.setFillColor(Color(60, 90, 60))
cabin.setPenColor(Color(120, 180, 120))
cabin.setPenThickness(1.0)
cabin.setPosition(heliX, heliY)
draw(cabin)
val tail = Picture.line(-18, 4)
tail.setPenColor(Color(100, 150, 100))
tail.setPenThickness(2.0)
tail.setPosition(heliX - 13, heliY + 2)
draw(tail)
val rotorWidth = 18.0 + Math.sin(timeStep * 0.8 + heliIndex) * 12.0
val rotor = Picture.line(rotorWidth * 2, 0)
rotor.setPenColor(Color(220, 220, 220))
rotor.setPenThickness(2.5)
rotor.setPosition(heliX - rotorWidth, heliY + 5)
draw(rotor)
}
}
// 6. Military Tanks & Missiles (Active in both states, firing more actively in Game Mode)
val tankXOffset = ((timeStep * 1.2) % 480) - 240
for (tankIndex <- 0 until 2) {
val tankX = tankXOffset + (tankIndex * 160)
if (tankX >= -260 && tankX <= 260) {
val tankHull = Picture.rect(36, 12)
tankHull.setFillColor(Color(45, 90, 45))
tankHull.setPenColor(Color(100, 200, 100))
tankHull.setPenThickness(1.0)
tankHull.setPosition(tankX, -45)
draw(tankHull)
val tankTurret = Picture.rect(18, 9)
tankTurret.setFillColor(Color(60, 110, 60))
tankTurret.setPenColor(noColor)
tankTurret.setPosition(tankX, -37)
draw(tankTurret)
val tankCannon = Picture.line(22, 0)
tankCannon.setPenColor(Color(180, 220, 180))
tankCannon.setPenThickness(3.0)
tankCannon.setPosition(tankX + 9, -37)
draw(tankCannon)
val tankTracks = Picture.rect(40, 5)
tankTracks.setFillColor(Color(30, 30, 30))
tankTracks.setPenColor(Color(150, 150, 150))
tankTracks.setPenThickness(1.0)
tankTracks.setPosition(tankX, -53)
draw(tankTracks)
val missileCycle = (timeStep * 5.0 + tankIndex * 40) % 90.0
if (missileCycle < 60.0) {
val missileX = (tankX + 22) + (missileCycle * 1.8)
val missileY = -37 + (missileCycle * 1.4)
val missileTrail = Picture.line(-12, -8)
missileTrail.setPenColor(Color(255, 153, 51))
missileTrail.setPenThickness(2.0)
missileTrail.setPosition(missileX, missileY)
draw(missileTrail)
val missileHead = Picture.circle(2.5)
missileHead.setFillColor(Color(255, 255, 255))
missileHead.setPenColor(Color(255, 69, 0))
missileHead.setPenThickness(1.0)
missileHead.setPosition(missileX, missileY)
draw(missileHead)
}
}
}
// 7. Army Parade (Visible during State 0, shifts to defensive lines in State 1)
if (gameState == 0) {
val paradeXOffset = ((timeStep * 1.8) % 600) - 300
for (soldierIndex <- 0 until 20) {
val soldierX = paradeXOffset + (soldierIndex * 26)
if (soldierX >= -240 && soldierX <= 240) {
val marchBob = Math.sin(timeStep * 0.4 + soldierIndex) * 3.5
val helmet = Picture.circle(4.5)
helmet.setFillColor(Color(0, 160, 80))
helmet.setPenColor(noColor)
helmet.setPosition(soldierX, -50 + marchBob)
draw(helmet)
val body = Picture.rect(9, 18)
body.setFillColor(Color(34, 139, 34))
body.setPenColor(Color(200, 255, 200))
body.setPenThickness(0.8)
body.setPosition(soldierX, -62 + marchBob)
draw(body)
val rifle = Picture.line(0, 14)
rifle.setPenColor(Color(220, 220, 220))
rifle.setPenThickness(1.5)
rifle.setPosition(soldierX + 4, -58 + marchBob)
draw(rifle)
val legOffset = Math.sin(timeStep * 0.4 + soldierIndex) * 5.0
val leftLeg = Picture.line(0, 12)
leftLeg.setPenColor(Color(220, 220, 220))
leftLeg.setPenThickness(2.0)
leftLeg.setPosition(soldierX - 2, -74 + marchBob + legOffset)
draw(leftLeg)
val rightLeg = Picture.line(0, 12)
rightLeg.setPenColor(Color(220, 220, 220))
rightLeg.setPenThickness(2.0)
rightLeg.setPosition(soldierX + 2, -74 + marchBob - legOffset)
draw(rightLeg)
}
}
} else {
// Game State 1: Active Target (Infiltrator Drone/Threat) for Operation Sindoor Game
val targetMovement = Math.sin(timeStep * 0.08) * 120.0
targetX = targetMovement
targetY = -35.0 + Math.sin(timeStep * 0.12) * 15.0
if (targetActive) {
val threatDrone = Picture.circle(12.0)
threatDrone.setFillColor(Color(220, 20, 60))
threatDrone.setPenColor(Color(255, 255, 255))
threatDrone.setPenThickness(2.0)
threatDrone.setPosition(targetX, targetY)
draw(threatDrone)
val threatCrosshair = Picture.rect(22, 2)
threatCrosshair.setFillColor(Color(255, 255, 255))
threatCrosshair.setPenColor(noColor)
threatCrosshair.setPosition(targetX, targetY)
draw(threatCrosshair)
// Simulate hit scoring loop
if ((timeStep % 90.0) < 5.0) {
gameScore += 10
}
}
}
// 8. Operation Sindoor Memorial Flame
val flamePulsate = Math.sin(angle * 0.15) * 3.0
val flameOuter = Picture.circle(18 + flamePulsate)
flameOuter.setFillColor(noColor)
flameOuter.setPenColor(Color(220, 20, 60, 180))
flameOuter.setPenThickness(2.0)
flameOuter.setPosition(0, -115)
draw(flameOuter)
val flameCore = Picture.circle(10)
flameCore.setFillColor(Color(255, 69, 0))
flameCore.setPenColor(Color(255, 215, 0))
flameCore.setPenThickness(1.5)
flameCore.setPosition(0, -115)
draw(flameCore)
val opText = Picture.text("OPERATION SINDOOR - ACTIVE", 11)
opText.setPenColor(Color(255, 100, 100))
opText.setPosition(-85, -132)
draw(opText)
// 9. Digital Spectrum Audio Visualizer
for (bar <- 0 until 18) {
val heightVal = (Math.abs(Math.sin(angle * 0.1 + bar * 0.45)) * 18).toInt + 3
val spectrumBar = Picture.rect(7, heightVal)
spectrumBar.setFillColor(if (bar % 3 == 0) Color(255, 153, 51) else if (bar % 3 == 1) Color(255, 255, 255) else Color(18, 136, 7))
spectrumBar.setPenColor(noColor)
spectrumBar.setPosition(-210 + (bar * 25), -155)
draw(spectrumBar)
}
// 10. Fast National Anthem Ticker at Bottom
val verseIndex = ((angle * 0.0035).toInt) % anthemVerses.length
val activeVerse = anthemVerses(verseIndex)
val verseShadow = Picture.text(activeVerse, 13)
verseShadow.setPenColor(Color(10, 15, 30))
verseShadow.setPosition(- (activeVerse.length * 3.3), -212)
draw(verseShadow)
val verseMain = Picture.text(activeVerse, 13)
verseMain.setPenColor(Color(255, 215, 0))
verseMain.setPosition(- (activeVerse.length * 3.3) - 2, -210)
draw(verseMain)
// 11. Fireworks Particles
val burstTimer = (angle * 0.09) % 10.0
if (burstTimer < 6.0) {
for (pt <- 0 until 14) {
val ptAngle = pt * (Math.PI / 7)
val ptDist = burstTimer * 28.0
val px = Math.cos(ptAngle) * ptDist
val py = 50 + Math.sin(ptAngle) * ptDist
val particle = Picture.circle(2.5)
particle.setFillColor(if (pt % 2 == 0) Color(255, 153, 51) else Color(0, 255, 200))
particle.setPenColor(noColor)
particle.setPosition(px, py)
draw(particle)
}
}
timeStep += 1.0
(angle + 2.0) % 360.0
}