class 'Droplight1' (Script)

function Droplight1:__init() super()
end

function Droplight1:on_attach()
	local scene = self:scene()
		
	 self.start_x =303      
	 self.start_y =433
	 self.finish_x =304
	 self.finish_y =453
	 self.time_animation = 1
	 self.count = 0.01
	 self.acceleration=0
	
	self.object = scene:object('rabbit2')
	self.point_start=Position(self.start_x,self.start_y)
	self.point_finish = Position(self.finish_x,self.finish_y)
	
	self.chench_x = math.abs(self.start_x-self.finish_x)
	self.chench_y = math.abs(self.start_y-self.finish_y)
	self.cooficient = self.chench_x/self.chench_y
	
	self.current_x =self.start_x
	self.current_y =self.start_y
	
	if self.start_x-self.finish_x>0 then
		self.direction_x = -1
	else
		self.direction_x = 1
	end
	
	if self.start_y-self.finish_y>0 then
		self.direction_y = -1
	else
		self.direction_y = 1
	end     	
	 	                                       
	
end

function Droplight1:on_update(dt)
local number_itiration = self.time_animation/dt
	local chench_x=self.chench_x*(self.count)
	local chench_y=self.chench_y*(self.count)

    self.count=self.count+self.acceleration;
    
	if (self.direction_x*self.current_x<self.finish_x) or (self.direction_y*self.current_y<self.finish_y) then
	    --print(self.count);
		self.current_x=self.current_x+self.direction_x*chench_x
        self.current_y=self.current_y+self.direction_y*chench_y
        self.object:set_position(Position(self.current_x,self.current_y), true)

    else
		self:scene():execute_action('sotopL2')
	end	    

end
