本文整理汇总了Python中system.System.update方法的典型用法代码示例。如果您正苦于以下问题:Python System.update方法的具体用法?Python System.update怎么用?Python System.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类system.System
的用法示例。
在下文中一共展示了System.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from system import System [as 别名]
# 或者: from system.System import update [as 别名]
def main():
# Solar system data comes from
# http://hyperphysics.phy-astr.gsu.edu/hbase/solar/soldata2.html
sun = Body(1.98892e30, 0, 0, 0, 0, 15, 1, 1, 0)
mercury = Body(.06 * EM, -.3871 * AU, 0, 0, 47890, 3, 1, .4, 0)
venus = Body(.82 * EM, -.7233 * AU, 0, 0, 35040, 6, 0, .6, .2)
earth = Body(1.0 * EM, -1.0 * AU, 0, 0, 29790, 7, 0, .4, 1)
mars = Body(.11 * EM, -1.524 * AU, 0, 0, 24140, 4, .8, .2, 0)
solar_system = System([sun, mercury, venus, earth, mars])
set_clear_color(0, 0, 0) # black background
enable_smoothing()
while not window_closed():
clear()
# Draw the system in its current state.
solar_system.draw(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, PIXELS_PER_METER)
# Update the system for its next state.
solar_system.update(TIMESTEP * TIME_SCALE)
# Draw the frame and take a brief nap.
request_redraw()
sleep(TIMESTEP)
示例2: main
# 需要导入模块: from system import System [as 别名]
# 或者: from system.System import update [as 别名]
def main():
# load in the images for all the planets
# like hitting ctrl+r and loading your blitz
suni = load_image("sun.png")
merci = load_image("mercury.gif")
venusi = load_image("venus.gif")
earthi = load_image("earth.png")
marsi = load_image("mars.png")
# initialize all the planets as an object
# hope that the values are all correct
sun = Body(1.98892e30, 0, 0, 0, 0, 12, 1, 1, 0,suni,17,17,0,17,17)
mercury = Body(.06*EM,0,.3871*AU,47890,0,3,1,0,0,merci,8,8,.2,16,16)
venus = Body(.82*EM,0,-.7233*AU,-35040,0,8,0,1,0,venusi,10,9,.3,20,18)
earth = Body(EM,AU,0,0,-29790,6,0,0,1,earthi,13,13,.4,26,26)
mars = Body(.11*EM,-1.524*AU,0,0,24140,4,0,1,1,marsi,10,10,.3,20,20)
listp = [sun,mercury,venus,earth,mars]
# put em in a list, for safekeeping
# as of now, the planets are still sleeping
solar = System(listp)
# kill the backlights, set up the stage,
# draw things inside the page
set_clear_color(0, 0, 0)
enable_smoothing()
player = Spaceship(3*WINDOW_HEIGHT/4,3*WINDOW_HEIGHT/4)
while not window_closed():
# draw the spaceship yo
clear()
player.spaceshipupdate()
player.draw()
# Draw the system in its current state.
solar.draw(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, PIXELS_PER_METER)
# Update the system for its next state.
solar.update(SEC_PER_FRAME)
# Draw the frame and take a brief nap.
request_redraw()
sleep(TIMESTEP)
示例3: main
# 需要导入模块: from system import System [as 别名]
# 或者: from system.System import update [as 别名]
def main():
earth = Body(5.9736e24, 0, 0, 0, 0, 24, 0, 0, 1) # blue earth
moon = Body(7.3477e22, 3.84403e8, 0, 0, 1022, 4, 1, 1, 1) # white moon
earth_moon = System([earth, moon])
set_clear_color(0, 0, 0) # black background
enable_smoothing()
while not window_closed():
clear()
# Draw the system in its current state.
earth_moon.draw(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, PIXELS_PER_METER)
# Update the system for its next state.
earth_moon.update(TIMESTEP * TIME_SCALE)
# Draw the frame and take a brief nap.
request_redraw()
sleep(TIMESTEP)