Original Post
Hi,
This is a very simple code problem i just can''t seem to get my head around it
heres my code:
well this works, sort off the ball moves to the right of the screen then tries to move back but just bounces in a small area, it gets stuck. I understand why this is, its because the xspeed is only inverted while x is >= 40.0 so as soon as it is < 40.0 then the speedx goes back to a positive value. How can i get around this problem? I have tried numorous things but to no anvil
Any help would be great
my head is thumping...
Thanks
Alan
float speedx = 0.2f;
x+=speedx;
if(x<=-5.0) //left side
{
speedx=+speedx; //invert the speed to + value
x+=speedx;
}
if(x>=40.0) //right side
{
speedx=-speedx //invert the speed to - value
x+=speedx;
}
|

