So I want to draw the trajectory of an object thrown in the Terminal with ASCII Symbols. The plan is to have dots or Xs as the trajectory of the object flying through a predrawn field of empty strings. My approach is to draw the field based on the maximum height and the flight distance of the throw. The code calculates a number of values of the throw beforehand and puts them in lists which it later rounds to integers.
I have to put it in a while loop somehow I think, but how do I count up the values and make it print the dot at the right place?
And I cant just plot it with gnuplot or something like that, since its a task for university.
My code is (with example values):
import numpy as np
hmax = 10
flightdistance = 43
sizex = flightdistance
sizey = hmax
yvalues = []
xvalues = []
listx_rounded = list(np.around(listx))
listy_rounded = list(np.around(listy))
for iy in range(sizey):
for ix in range(sizex):
if listy_rounded == iy and listx_rounded == ix:
print('x', end='')
else:
print('', end='')
print('')
I also thought enumerate() might help, but Im just not getting it.