Im pretty new to c++ programming and my maths is really rusty. What I'm trying to do is the following:
I'm trying to write a simple c++ program that outputs an objects current height once it hits a specific point. The object I'm trying to accomplish is that you have an object that starts at a varied position a moves off under a random velocity with gravity attached. If the ball collides with a wall or another object, it should move backward, with no energy loss, but still continue to fall due to gravity. Once the ball has reached a specific height, output that value.
Now, all I'm trying to do right now is check to see if my ball has gone beyond my width bounds. But for the life of me I can't see why my last if statement at the bottom wont call.
what is target? i think it should be targetHeight.
Is the object moving upward or downward? If it is moving upward, then it should be while (height <= targetHeight) and if it is moving downward, then the velocity should be negative.
Also, I feel you should also change the value of velocity in each iteration.