當前位置: 首頁>>代碼示例>>Python>>正文


Python System.draw方法代碼示例

本文整理匯總了Python中system.System.draw方法的典型用法代碼示例。如果您正苦於以下問題:Python System.draw方法的具體用法?Python System.draw怎麽用?Python System.draw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在system.System的用法示例。


在下文中一共展示了System.draw方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from system import System [as 別名]
# 或者: from system.System import draw [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)
開發者ID:CS98,項目名稱:TheOneRepo,代碼行數:28,代碼來源:solar.py

示例2: main

# 需要導入模塊: from system import System [as 別名]
# 或者: from system.System import draw [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)
開發者ID:edwardcdy,項目名稱:planets,代碼行數:50,代碼來源:solar.py

示例3: main

# 需要導入模塊: from system import System [as 別名]
# 或者: from system.System import draw [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)
開發者ID:CS98,項目名稱:TheOneRepo,代碼行數:22,代碼來源:earthmoon.py


注:本文中的system.System.draw方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。