Skip to content

Instantly share code, notes, and snippets.

@kyzentun
Created June 27, 2015 04:36
Show Gist options
  • Save kyzentun/d6f2d8e884e7e18452f4 to your computer and use it in GitHub Desktop.
Save kyzentun/d6f2d8e884e7e18452f4 to your computer and use it in GitHub Desktop.
local hw= _screen.w * .5
local low_pos= _screen.h + 16
local fly_count= 200
local flies= {}
local curr_fly= 1
local function unzip_fly(offset)
local b = GAMESTATE:GetSongBeat()
if (b >= 224 and b <= 288) or b >= 422 then
local x1 = math.random()*hw + (hw * offset)
local x2 = math.random()*hw + (hw * offset)
local y1, y2
if math.random() < 0.5 then
y1 = -16
y2 = low_pos
else
y1 = low_pos
y2 = -16
end
flies[curr_fly]:playcommand("Activate", {x1= x1, x2= x2, y1= y1, y2= y2})
curr_fly= curr_fly + 1
if curr_fly > fly_count then
curr_fly= 1
end
end
end
local args= {
Def.Quad{
Name= "xtl_actor_jej",
InitCommand= function(self)
self:sleep(1000)
end,
StepP1MessageCommand= function(self)
unzip_fly(0)
end,
StepP2MessageCommand= function(self)
unzip_fly(1)
end,
},
}
for id= 1, fly_count do
args[#args+1]= Def.Sprite{
Name= "fly" .. id,
Texture= "firefly.png",
InitCommand= function(self)
flies[id]= self
self:hibernate(math.huge)
end,
ActivateCommand= function(self, params)
self:hibernate(0):xy(params.x1, params.y1):linear(1)
:xy(params.x2, params.y2)
end,
}
end
return Def.ActorFrame(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment