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 129475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:47:44+00:00 2026-05-11T05:47:44+00:00

I played around with it for a while, but I simply can’t figure it

  • 0

I played around with it for a while, but I simply can’t figure it out.

I made a tank that fires missiles, and when the missiles hit the walls, I want them to bounce off, but I want them to bounce off to the right angle.

Right now I haven’t got any obstacles, the missiles just bounce off when they get outside the viewportRectangle I made.

Is the solution I’m looking for quite advanced?

Is there a relativly simple way to do it?

  • 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. 2026-05-11T05:47:44+00:00Added an answer on May 11, 2026 at 5:47 am

    I think an easier way to do this is to use the velocity of the missile instead of calculating angles. Say you have a missile that has xVelocity and yVelocity to represent its movement horizontally and vertically. Those velocities can be positive or negative to represent left, right, up, or down.

    • If a missile hits a top or bottom border reverse the sign of the yVelocity.
    • If a missile hits a left or right border reverse the sign of the xVelocity.

    This will keep the movement in the opposite axis the same.

    Borrowing the image from ChrisF’s answer, let’s say the missile starts out at position I.

    Angle of Reflection

    With the xVelocity and yVelocity both being positive (in 2D graphics right and down are typically positive) the missile will travel in the direction indicated. Let’s just assign values of

    xVelocity = 3 yVelocity = 4 

    When the missile hits the wall at position C, its xVelocity shouldn’t change, but its yVelocity should be reversed to -4 so that it travels back in the up direction, but keeps going to the right.

    The benefit to this method is that you only need to keep track of a missile’s xPosition, yPosition, xVelocity, and yVelocity. Using just these four components and your game’s update rate, the missile will always get redrawn at the correct position. Once you get into more complicated obstacles that are not at straight angles or are moving, it will be a lot easier to work with X and Y velocities than with angles.

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

Sidebar

Related Questions

It looks interesting and I've played around with it some --- but the development
I have played around with smart phone development (windows ce), and it seemed pretty
I found the bottleneck in my python code, played around with psycho etc. Then
I played with one of the early beta versions of PowerShell V1, but haven't
I would like to create 10 plots that have different data, but the same
I poked around for a while on Google and Windows Media player looking for
Recently I have made a simple flash application that utilizes a webcam feed and
I have googled around and played around with test scripts (powershell/spec/nunit/msbuild). I am looking
I need to trigger two slide-in divs with one button. I have played around
I'm playing around with a native (non-web) single-player game I'm writing, and it occured

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.