运动可视化(旅行时间计算器)问题

时间:2017-12-26 18:42:49

标签: python python-3.x math calculator

import time
import os

clear = lambda: os.system('cls')
clear()

print('Movement Computer')
print('')
distance = float(input('Distance (km): '))
currVelocity = float(input('Velocity (km/h): '))
acceleration = float(input('Acceleration (km/h^2): '))
timeLeap = float(input('Time leap (h): '))

path = ''
gap = ''
travel = ''
travelled = 0
multiplier = 1
loop = 0

for x in range(0, 100):
    path = path + '='

for y in range(0, 50):
    gap = gap + ' '

eachCube = distance / 100

while True:
    clear()
    print('eachCube: ' + str(eachCube))
    print ('Travelled / eachCube: ' + str(travelled / eachCube))
    print ('eachCube * multiplier: ' + str(eachCube * multiplier))
    print ('multiplier: ' + str(multiplier))
    print('')
    print(gap + ' Space')
    print(' ' + path)
    print(travel + '^')
    print('')
    print('Current velocity  : ' + str(currVelocity))
    print('Distance traveled : ' + str(travelled) + '/' + str(distance))
    print('Time: ' + str(loop))
    if travelled >= distance:
        print('')
        print('Journey complete.')
        break
    time.sleep(timeLeap)
    loop += 1
    currVelocity += acceleration * timeLeap
    travelled += currVelocity * timeLeap
    if travelled >= eachCube * multiplier:
        for z in range(0, int(int(travelled / eachCube) / loop)):
            travel = travel + ' '
        multiplier = loop

我已经花了一些时间制作这个物体移动可视化器。当加速度设置为0时,一切正常,但是当我改变它时,箭头(指针)全部搞砸了。

有人可以帮助我吗?另外我知道箭头可能会脱离图表(也无法解决)

使指针(箭头)移动的代码可能有问题:

if travelled >= eachCube * multiplier:
    for z in range(0, int(int(travelled / eachCube) / loop)):
        travel = travel + ' '
    multiplier = loop

其中eachCube = distance / 100travelled是对象已经移动的距离。

0 个答案:

没有答案