bounce angles

This is a discussion on bounce angles within the Windows Programming forums, part of the Platform Specific Boards category; i have a prog with a bitmap bouncen around the screen at 45 degrees all the time (x+1;y+1) is there ...

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

    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:
    not
    -----------|
    /
    /
    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
    Posts
    346
    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.
    Code:
    //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:
    Code:
       \ |  
        \| <- Wall  -        The ball changes signs in X direction
        /|
       / |
    
      \  /
       \/                 Ball changes signs in Y direction
    ----------
    Wall
    - 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, 01:48 PM
  3. Need help with Reflecting Angles!
    By SRM in forum Game Programming
    Replies: 7
    Last Post: 05-15-2003, 05: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, 11:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21