February is Demo Scene month! A demo is a small program that shows off something nifty. Here's one I just put together using the new Sprite.setCorners
method added in Mini Micro 1.1.
And here's the code:
bigMapImg = http.get("https://storage.googleapis.com/" +
"gweb-uniblog-publish-prod/images/New-global-view.max-1000x1000.jpeg")
clear
sprites = display(4).sprites
sections = 12
secW = bigMapImg.width / sections
rings = 8
ringH = bigMapImg.height / rings
R = 200 // globe radius
for j in range(0, rings-1)
for i in range(0, sections-1)
sp = new Sprite
sp.image = bigMapImg.getImage(i*secW, j*ringH, secW, ringH)
sp.x = 480
sp.y = R + R*2/rings * j
yangBot = (10 + 160/rings * j) * pi/180
yangTop = (10 + 160/rings * (j+1)) * pi/180
sp.yBot = 320 - R * cos(yangBot)
sp.yTop = 320 - R * cos(yangTop)
sp.rBot = R * sin(yangBot) // radius at bottom
sp.rTop = R * sin(yangTop) // radius at top
sp.angLeft = i * 2*pi/sections
sp.angRight = (i+1) * 2*pi/sections
sprites.push sp
end for
end for
positionSprites = function(rotDegrees)
dang = rotDegrees * pi/180
for sp in sprites
corners = []
corners.push [480+sp.rBot*cos(sp.angLeft+dang), sp.yBot]
corners.push [480+sp.rBot*cos(sp.angRight+dang), sp.yBot]
corners.push [480+sp.rTop*cos(sp.angRight+dang), sp.yTop]
corners.push [480+sp.rTop*cos(sp.angLeft+dang), sp.yTop]
sp.setCorners corners
if corners[1][0] > corners[0][0] then
sp.tint = color.white
else
sp.tint = color.clear
end if
end for
end function
rot = 0
while true
yield
positionSprites rot
rot = rot + 1
end while