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
Printable View
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
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.
This is what it should look like: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
- SeanCode:\ |
\| <- Wall - The ball changes signs in X direction
/|
/ |
\ /
\/ Ball changes signs in Y direction
----------
Wall