顯示文章

這裡允許您檢視這個會員的所有文章。請注意, 您只能看見您有權限閱讀的文章。


主題 - LeonH

頁: [1]
1
Python程式設計討論區 / 新手請問鍵盤問題
« 於: 2011-02-02 23:28 »
大家好我是超級新手,目前自學中,教材是How to think like a computer scientist
下面是範例程式碼:
代碼: (python) [選擇]
from gasp import *

begin_graphics(800, 600, title="Catch", background=color.YELLOW)
set_speed(120)

mitt_x = 780
mitt_y = 300
mitt = Circle((mitt_x, mitt_y), 20)

while True:
    if key_pressed('k') and mitt_y <= 580:
        mitt_y += 5
    elif key_pressed('j') and mitt_y >= 20:
        mitt_y -= 5

    if key_pressed('escape'):
        break

    move_to(mitt, (mitt_x, mitt_y))
    update_when('next_tick')

end_graphics()

可是實際在跑時,按j或k都可以改變mitt的座標,唯讀按esc就完全沒效果 ???
平台是linux mint、python 2.6.6

頁: [1]