--HaHa
--This file stolen from TheNick & RIME's What a Wonderful World from UPS 4

local deltaxa = 1.5*(math.random(0,1) > .5 and 1 or -1);
local deltaya = 1.5*(math.random(0,1) > .5 and 1 or -1);
--local rotationa= math.random(2,5) * (math.random(0,1) > .5 and 1 or -1) / 10;
local rotationa= math.random(5,10) * (math.random(0,1) > .5 and 1 or -1) / 10;

--grabs the current music rate and creates "beattime" variable
--any lua function tied to seconds can be in beats
--ex: sleep(1.3*beattime);
--110 is the bpm for this section
local musicrate = GAMESTATE:GetSongOptionsObject("ModsLevel_Song"):MusicRate()
local beattime = (60/110)/musicrate

return Def.ActorFrame{
    -- keep-alive Actor
    -- this will allow the file to persist for 999 seconds
    -- (or, until the end of the stepchart)
    Def.Actor{ OnCommand=function(self) self:sleep(1.3) end },
 -- Thanks DBK2 for da help
    -- the Sprite Actor 
    
	Def.Sprite{
        --Texture="download.jpg",
        Texture="haha.png",
      
	  --REAL WORKNG OnCommand= cmd(zoom,1.2*(SCREEN_HEIGHT/480);x,math.random(0,SCREEN_WIDTH);y,math.random(0,SCREEN_HEIGHT);zoom,0.8*(SCREEN_HEIGHT/480);spin;),
		OnCommand= cmd(playcommand,"move"),
		
		InitCommand= function(self)
			self:x(math.random(0,SCREEN_WIDTH));
			self:y(math.random(0,SCREEN_HEIGHT));
			self:zoom(0.4*(SCREEN_HEIGHT/480));
			--self:rotationz(rotationa);

			
			-- xa = SCREEN_CENTER_X;
			-- ya = SCREEN_CENTER_Y;
		end,
		-- moveCommand= function(self)

		-- end,
	--	Texture= "rose.png",
		moveCommand= function(self)
			self:x(self:GetX() + deltaxa);
			self:y(self:GetY() + deltaya);
			-- xa = xa + deltaxa*(SCREEN_WIDTH/640);
			-- ya = ya + deltaya*(SCREEN_HEIGHT/480);
			--rotationa = rotationa - 1.5;
			self:addrotationz(rotationa);
			
			if self:GetX() <= SCREEN_LEFT or self:GetX() >= SCREEN_RIGHT then
				deltaxa = -deltaxa;
			end
			if self:GetY() <= SCREEN_TOP or self:GetY() >= SCREEN_BOTTOM then
				deltaya = -deltaya;
			end
			self:sleep(.007);
			self:queuecommand('move');
		end,
    },
	
}