[問題] 關於Pygame-幫我看一下我覺得沒有錯的딠…

看板Python作者 (活力精華)時間15年前 (2010/06/04 02:19), 編輯推噓1(104)
留言5則, 4人參與, 最新討論串1/2 (看更多)
如題 我是一個python新手 以下是我們老師製作的講義的程式碼 我檢查了好幾遍都沒錯阿 (圖片部分請自己隨便命名一張圖為相同檔名) 此程式碼主要是要讓輸入鍵盤上下左右 可讓圖片移動 輸入空白 可以旋轉圖片 可是執行後我怎麼敲鍵盤都不會動!!!!! 救人喔~ (Python版本:3.1) import pygame,sys,os,math from pygame.locals import * pygame.init() width, height = 800,600 size = width, height screen = pygame.display.set_mode((size)) white = 255,255,255 screen.fill(white) pygame.mouse.set_visible(0) fly = pygame.image.load('fly1.png') background = pygame.image.load('sky.jpg') screen.blit(background, (0,0)) image=[150,150] angle = 45 pressed_keys = pygame.key.get_pressed() if pressed_keys[K_LEFT]: image[0]=image[0]-1 if pressed_keys[K_RIGHT]: image[0]=image[0]-1 if pressed_keys[K_UP]: image[1]=image[1]-1 if pressed_keys[K_DOWN]: image[1]=image[1]+1 if pressed_keys[K_SPACE]: angle=angle-1 rotate = pygame.transform.rotate(fly,angle) screen.blit(rotate,image) pygame.display.update() -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.85.137.199 ※ 編輯: manYO 來自: 219.85.137.199 (06/04 02:19)

06/04 09:42, , 1F
Where is the loop?
06/04 09:42, 1F

06/04 10:30, , 2F
同上,如果你真的檢查了好幾次,不可能沒發現沒有迴圈
06/04 10:30, 2F

06/04 10:31, , 3F
小弟直覺你就是上來要人幫你寫作業...
06/04 10:31, 3F

06/04 17:23, , 4F
看到最後兩句就知道沒救啦 = =
06/04 17:23, 4F

06/06 23:44, , 5F
不要上來問作業啦
06/06 23:44, 5F
文章代碼(AID): #1C1_8MaW (Python)
文章代碼(AID): #1C1_8MaW (Python)