Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7094035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:30:49+00:00 2026-05-28T08:30:49+00:00

I am making a Pong clone and I am treating my variables in this

  • 0

I am making a Pong clone and I am treating my variables in this way:

direction = a value from 0 to 2*pi 
distX = cos(direction)*speed of the ball
distY = sin(direction)*speed of the ball

on update:
ball's x position += distX
ball's y position += distY

I can already handle the flipping of directions correctly when a ball hits a wall (just reflect at 90 degrees) but what about a paddle? I don’t know how to best handle the angle and speed of the ball after it connects.

Does it depend on where it hits on the paddle? Does it matter if the paddle is moving? etc

I don’t know a reasonable way to handle the math here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:30:50+00:00Added an answer on May 28, 2026 at 8:30 am

    There’s no “right” way of doing this. You’re the one who’s writing the code, and unless you’ve got some strict specifications, you can handle it how you prefer much.

    Basically, you can handle the ball-paddle collision the same way you handle a ball-wall collision, i.e. by simply calculating the reflection angle, and assigning it to direction.

    If you want to increase the reflection angle proportionally with the paddle speed, you can simply apply some kind of weight to the new direction.

    But it’s really up to you.

    Anyway, if you provide, for example, the code where you handle the paddle speed, someone could give you further indication.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making another Pong clone using HTML5 canvas and JavaScript. The problem I'm having
for the sake of simplicity let's assume that I'm making a simple Pong clone
Making a migration from 2.8.1 to 2.9.1 found interesting thing. Tried to write this
While making a little Pong game in C++ OpenGL, I decided it'd be fun
I'm making a game in C# (It's a pong game) and I've completed an
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
I was reviewing a code from a simple PONG game code in c#, the
making a new jsp and got a mock-up from some analyst. Notice the sections
Making a piano/keyboard application and trying to figure out the best way to set
Making the transition from Vim to gVim, I would like to disable all toolbars

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.