Thread: bounce angles

  1. #1
    Registered User canine's Avatar
    Join Date
    Sep 2001

    bounce angles

    i have a prog with a bitmap bouncen around the screen at 45 degrees all the time (x+1;y+1) is there any way to make the bitmap bounce at acurate angles?
    as in:
    but -----<--->--|
    to keep at 90 degrees
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    I am not sure I exactly know what you are asking, but I will give it a guess. When I made a program like this I used vectors. I kept a x value and a y value. When the ball hits a side wall the x value switches signs. When the ball hits the top or bottom the y value changes signs.
    //hit side wall
    x = -x;
    //hit top or bottom
    y = -y;
    //This is where:
    //Current X Position = Last X + x
    //Current Y Position = last Y + y
    This is what it should look like:
       \ |  
        \| <- Wall  -        The ball changes signs in X direction
       / |
      \  /
       \/                 Ball changes signs in Y direction
    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bounce - Dealing With It
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-25-2006, 02:50 PM
  2. need help making a dot bounce up and down y axis in this prog
    By redwing26 in forum Game Programming
    Replies: 10
    Last Post: 08-05-2006, 12:48 PM
  3. Need help with Reflecting Angles!
    By SRM in forum Game Programming
    Replies: 7
    Last Post: 05-15-2003, 04:11 PM
  4. how can i draw angles by lines
    By NEO_4583 in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2003, 08:40 PM
  5. Bounce around screen
    By Akilla in forum C++ Programming
    Replies: 1
    Last Post: 07-19-2002, 10:05 PM