Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local maxZ = 100
- local maxZoom = 4
- local minZoom = 1
- local targetHalfWidth=16
- local startingOffset=128
- local minZ = 0
- local minFallTime = 6
- local fallTimeRange = 4
- local numItems = 64
- local function CalculateSpawnPosition()
- --1 is x, 2 is y
- local output = {0,0}
- local mode = math.random(1,4)
- if mode <= 2 then --top or bottom
- output[1]=(math.random(SCREEN_LEFT-startingOffset,SCREEN_RIGHT+startingOffset))
- else
- output[2]=(math.random(SCREEN_TOP-startingOffset,SCREEN_BOTTOM+startingOffset))
- end
- if mode==1 then
- output[2]=(SCREEN_TOP-startingOffset)
- elseif mode==2 then
- output[2]=(SCREEN_BOTTOM+startingOffset)
- elseif mode==3 then
- output[1]=(SCREEN_RIGHT+startingOffset)
- elseif mode==4 then
- output[1]=(SCREEN_LEFT-startingOffset)
- end
- return unpack(output)
- end
- local function CalculateTargetDestination()
- return math.random(SCREEN_CENTER_X-targetHalfWidth, SCREEN_CENTER_X+targetHalfWidth),
- math.random(SCREEN_CENTER_Y-targetHalfWidth, SCREEN_CENTER_Y+targetHalfWidth)
- end
- local fallingItem = Def.Sprite{
- Texture=THEME:GetPathG("Common", "window icon"),
- InitCommand=function(self) self:queuecommand("Fall") end,
- FallCommand=function(self) self:linear(0):xy(CalculateSpawnPosition(self)):z(maxZ):zoom(maxZoom)
- :linear(minFallTime+math.random()*fallTimeRange):xy(CalculateTargetDestination()):z(minZ):zoom(minZoom)
- :queuecommand("Fall") end,
- }
- local t = Def.ActorFrame{InitCommand=function(s) s:fov(60):SetDrawByZPosition(true) end}
- t[#t+1] = Def.Quad{InitCommand=function(s) s:diffuse(color"#000000"):zoomx(SCREEN_WIDTH):zoomy(SCREEN_HEIGHT) end}
- for i=1,numItems do
- t[i] = fallingItem
- end
- return t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement