Difficult-Rocket/superman.py

56 lines
1.6 KiB
Python
Raw Normal View History

2021-02-20 21:46:14 +08:00
import logging
2021-02-20 00:17:50 +08:00
2021-02-20 21:46:14 +08:00
tick_time, velocity, height, add_speed = 0, 0, 0, 0
m = 4610025
gravity = 9.798
R = 637100
n = 0.5943466
H = 70000
F = 208201000
TPS = 10
2021-02-20 00:17:50 +08:00
MSPT = 1 / TPS
2021-02-20 21:46:14 +08:00
logging.basicConfig(filename='logs/super.log',
filemode='w',
level=logging.DEBUG)
2021-02-20 00:17:50 +08:00
while True: # 主tick循环
2021-02-20 21:46:14 +08:00
logging.info([tick_time, velocity, height, add_speed])
2021-02-20 00:17:50 +08:00
# 基础加速度运算
2021-02-20 21:46:14 +08:00
add_speed = (F / m) - ((gravity * (R ** 2)) / ((R + height) ** 2))
2021-02-20 00:17:50 +08:00
# 出大气层判定
if height < 70000: # 没出大气 加速度需要减去大气阻力
2021-02-20 21:46:14 +08:00
add_speed -= ((n * (velocity ** 2) * (10 ** (-6 * height) / H)) / m)
height += (MSPT * velocity) # 高度 加 速度除以TPStick per second每tick加速
velocity += (MSPT * add_speed) # 速度 加 加速度除以TPS
2021-02-20 00:17:50 +08:00
if tick_time < 192: # 一些我也不知道是什么意思的tick判定
2021-02-20 21:46:14 +08:00
m -= ((MSPT * F) / 3399.2) # 3399.2是个啥?
2021-02-20 00:17:50 +08:00
elif tick_time < 240:
2021-02-20 21:46:14 +08:00
m -= (129 * MSPT) # ??? 129?
2021-02-20 00:17:50 +08:00
else:
2021-02-20 21:46:14 +08:00
m -= (4 * MSPT) # 4?
2021-02-20 00:17:50 +08:00
# tick 加时间
tick_time += MSPT
if tick_time < 48: # 如果时间没到48秒
continue
elif tick_time == 48: # 如果时间到了48秒
m = 1243700
F = 44189600
elif tick_time == 96:
m = 193125
F = 8498000
elif tick_time == 144:
m = 40875
F = 1699600
elif tick_time == 192:
m = 10225
F = 446145
elif tick_time == 240:
m = 2308
F = 21245
elif tick_time >= 567:
tick_time += ((12308300 - height) / velocity)
break
2021-02-20 21:46:14 +08:00
print('t: %s' % tick_time)