顯示廣告
隱藏 ✕
看板 Programming
作者 Leon (Leon)
標題 請問python新手問題
時間 2011年02月01日 Tue. PM 10:31:24


大家好我是超級新手,想請教的問題就是為什麼我按j或k都可以順利移動那個mitt
但是按esc就是沒辦法結束?


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()


--
※ 作者: Leon  時間: 2011-02-01 22:31:24  來自: 220-132-231-11.HINET-IP.hinet.net
※ 看板: Programming 文章推薦值: 3 目前人氣: 0 累積人氣: 557 
( ̄︶ ̄)b Leon 說讚!
1樓 時間: 2011-02-04 21:09:50 (台灣)
  02-04 21:09 TW
誰寫過python的來說明一下阿~~~~不過我猜esc的代碼不是這樣寫就是了
2樓 時間: 2011-02-04 21:42:10 (台灣)
  02-04 21:42 TW
我沒有找到答案,但是發現同樣的問題http://www.python-forum.org/pythonforum/viewtopic.php?f=3&t=21026
或許你可以考慮換個OS?
3樓 時間: 2011-02-04 21:49:47 (台灣)
  02-04 21:49 TW
樓上超專業 我因為剛返回文明世界 所以還沒時間查東西XD
4樓 時間: 2011-02-05 23:48:58 (台灣)
  02-05 23:48 TW
補充一下,我是在linux mint下寫的,不是windows喔~
5樓 時間: 2011-02-12 20:11:40 (台灣)
  02-12 20:11 TW
6樓 時間: 2011-02-12 23:22:35 (台灣)
  02-12 23:22 TW
感謝還特地回來推連結~~~~~(有空來整裡一篇解答文)
r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇