Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Seattle, WA
    Rep Power

    Default How to fire cannon balls out of a rotatable cannon

    I'm creating a game where you rotate a cannon, at the bottom of the screen, clockwise and counterclockwise with the left and right arrow keys. When you press space a cannonball fires out of the cannon at the appropriate angle. For example, if the cannon was rotated 45 degrees the cannon ball would move 20 pixels to the right and 20 pixels up every step.

    I have everything besides the actual formula for creating the rise over run for the cannon ball.

    Here is how the cannon ball moves, dictated by the move method:
    Java Code:
    public void move()
    		x += xspeed;
    		y += yspeed;
    I want to convert the angle of the cannon into a xspeed and yspeed for the cannonball.

    Any help or advice would be greatly appreciated.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: How to fire cannon balls out of a rotatable cannon

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. More bouncing balls...
    By ShaolinMunky in forum New To Java
    Replies: 5
    Last Post: 06-10-2012, 09:43 AM
  2. how to add more balls via user input
    By Johnny2009 in forum New To Java
    Replies: 22
    Last Post: 12-12-2011, 02:33 AM
  3. ArrayList and Bouncing Balls
    By jamie23 in forum AWT / Swing
    Replies: 1
    Last Post: 02-20-2011, 06:54 PM
  4. Multiple bouncing balls
    By Algar in forum AWT / Swing
    Replies: 2
    Last Post: 04-24-2008, 08:35 PM
  5. Movement of balls
    By BlitzA in forum New To Java
    Replies: 8
    Last Post: 01-09-2008, 03:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts