Help with Break out example

I am making test pong game. I have stick and ball and i can move stick with moving finger left or right. But i want to that my game has same physics than break out example, when ball hits stick. So i can control ball bouncing angle with moving stick. I have tried to do that myself, but it didnt work. Please, help me.
Here is break out example code:

-- If so, is it hitting or missing the paddle?  
 -- (The paddle is 70px wide, so we check if the ball is within 35px left and right)  
 if (math.abs(paddle.x - ball.x) \< 35) then  
 vy = -vy  
  
 -- Adjust bounce angle (by adjusting vx) according to where on the paddle   
 -- the ball actually strikes. This allows the player to "steer" the ball.  
 -- (The number "4" below is obtained by trial and error playtesting; a lower  
 -- number would lead to a wider range of bounce angles, but if the range  
 -- is too great, the game becomes too chaotic. Try different numbers to see this.  
 vx = -(paddle.x - ball.x)/4  

And here my code:

[code]
local function bounce (event)
ball.x = -(stick.x - ball.x)/4
end

stick:addEventListener(“collision”,bounce) [import]uid: 18445 topic_id: 7103 reply_id: 307103[/import]

Could someone help me little bit. [import]uid: 18445 topic_id: 7103 reply_id: 25094[/import]

Never mind. I figured that out myself :slight_smile: [import]uid: 18445 topic_id: 7103 reply_id: 25155[/import]