I need help because i have no idea how to do this:
You will be using the graphics window to display the movement of a Point object, instead of just outputting the coordinate values to the console. We can think of acceleration in the y direction as being due to a rocket thruster, so although you will only be drawing a single Point moving around the window, it will actually be modelling the rocket ship.
This time, you will not stop after 4 seconds, but continue indefinitely: after every 20 seconds, you will obtain a new y acceleration value from the user.
Your Point has a vertical thruster that can be set to high, med, low, or none, which will determine the value of the acceleration, according to a table given below.
You will leave all Points on the window (i.e. you will not clear the window before drawing each new Point) so that we can see the complete trajectory of the Point as it evolves over time.
Initial settings:
Your window coordinates must be set to (0.0, 20000.0, 20000.0, 0.0).
When your program begins, you must start your Point at the coordinates (0.0, 12000.0).
Your x velocity must be initialized to +20.0 and your y velocity initialized to 0.0
Your y acceleration must be initialized to -1.6 (this is the acceleration in m/sec/sec due to gravity on the moon!), and your x acceleration will be a constant +0.2 for the entire program.
Your mission:
You are required to write three functions (in addition to ccc_win_main):
position: This function should take in an initial coordinate value (double), an initial velocity (double), an acceleration (double), and a time t (int) as parameters, and return the new coordinate value at time t.
Use the following formula to calculate the coordinate value at time t given the coordinate value at time 0, velocity at time 0, and the acceleration:
pos = initial_pos + (initial_velocity * t) + (0.5 * acceleration * t * t)
Notice that this function makes no reference to the x or y axes - you will in fact call this same function separately for both the x and y coordinates.
velocity: This function will take in an initial velocity (double), a constant acceleration (double), and a time t (int) as parameters and return the new velocity at time t.
Use the following formula to get a velocity at time t given the velocity at time 0 and acceleration at time 0:
velocity = initial_velocity + (acceleration * t)
Again, notice that this function makes no reference to axis - you will in fact call this same function separately for both the x and y velocities.
y acceleration: This function takes in no parameters and returns the new y acceleration (double), based on a thruster value entered by the user (note that this new acceleration will be the acceleration that applies over the next 20-second period).
This function should ask the user for a thruster value of (h)igh, (m)ed, (l)ow, or (n)one:
If the user answers high, the function should return a y acceleration of 1.0.
If the user answers med, the function should return a y acceleration of 0.5.
If the user answers low, the function should return a y acceleration of 0.0.
Otherwise, if they answer none or give an invalid response, the function should return a y acceleration of -1.6 (i.e. no thruster, just the downward acceleration due to gravity).
Notice that this function does refer explicitly to the y acceleration - in this program, the acceleration in the x direction is fixed at 0.2 at all times.
ccc_win_main: Your program should initially output 20 Points, each Point corresponding to the position after 1 more second with no thruster (i.e the y acceleration is just the -1.6 due to gravity).
Only after outputting these first 20 Points (i.e. at t = 20 seconds), you should ask the user for a new thruster setting.
The final position & velocity values from the preceding period will now become the your new initial position & velocity; and with the new y acceleration (obtained from the new thruster setting) you will be able to start a new 20-second period: start t over again (set it to 0) and output 20 more Points, one per second. Continue repeating this process indefinitely (use an infinite loop, meaning that you will have to type CTRL-C in the console to kill the program when you get tired of it!).
Alternatively (and more elegantly!), you may have the program terminate when the Point goes outside the bounds (upper, lower, left, or right) of the window - 5 bonus points if you can do it!