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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:34:40+00:00 2026-05-25T10:34:40+00:00

I have a big problem when I try to rotate my projectiles along with

  • 0

I have a big problem when I try to rotate my projectiles along with the ship’s rotation.

I want my spaceship shoot two shots at once. So I used my first array of projectiles and placed them at the right side of the ship (one shot on the left and one on the right). So far so good.

But when I shoot with my spaceship and I turn around the rotations of the projectiles look very strange. It’s hard to describe so here’s an image that shows the error in action.

http://imageshack.us/photo/my-images/841/projectilebug.jpg

I have huge problems rotating the projectiles ALONG with the spaceship so that it looks really good. Currently there is one single shot only. My shooting gets screwed up when I rotate and fire at once.
The goal is to create a dual firing cannon like in the picture shown.

Here is some code that places the projectile at the left of the ship (that doesn’t really work):

var projectileRadians:Number = (player.frame / 180) * 3.14159;

tempProjectile.x = (player.point.x + 6) + Math.cos(projectileRadians);
tempProjectile.y = (player.point.y + 3) + Math.sin(projectileRadians);

The velocity code:

tempProjectile.nextX = tempProjectile.x;
tempProjectile.nextY = tempProjectile.y;
tempProjectile.dx = rotationVectorList[player.frame].x;
tempProjectile.dy = rotationVectorList[player.frame].y;

This updates the position:

nextX += (dx * (speed + Math.abs(xAdjust))) * step;
nextY += (dy * (speed + Math.abs(yAdjust))) * step;
  • 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-25T10:34:40+00:00Added an answer on May 25, 2026 at 10:34 am

    The velocity code looks ok. You don’t seem to be calculating the gun position correctly.

    Edit: we’re not using the standard trig frame of reference; instead, we’re using one where angle=0 means up and angles increase as you rotate clockwise. So we take the standard usage and swap sin and cos.

    Here, gx and gy mean the coordinates of a gun relative to the coordinates around which the ship moves. We need to rotate the vector <gx, gy> by the angle before adding it to the ship coords:

    cs = Math.cos(projectileRadians);
    sn = Math.sin(projectileRadians);
    tempProjectile.x = player.point.x + gx * sn - gy * cs;
    tempProjectile.y = player.point.y + gx * cs + gy * sn;
    

    It would be a good optimization to restrict the ship’s angle to certain values (perhaps every 5 degrees), and put all the trig functions into a table ahead of time. Trig functions are expensive to compute.

    Note that this also assumes that positive Y is “up”. Computer graphics often start with (0, 0) in the upper left corner and increase Y as you move down, so you may have to switch the sign of Y.

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

Sidebar

Related Questions

I have a big problem dealing with data I try to download in my
I have a big problem. I want to extract text from html table that
I have an big problem with an SQL Statement in Oracle. I want to
I have a big problem. I try to bind my WPF DataGrid to a
I have a big problem with an UITableView, I want to use a label
I have a big problem with Websphere. When I try to deploy an update
i have a little big problem. My problem is the following. I´ve got two
I have a big problem with a java program. I try to implement a
I have big problem when I am trying to deploy my app over clickonce.
I have a (big) problem that all of you that work with Webforms might

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.