I am currently studying python programming, which is fun to learn while making games.I am troubled that I cannot do image.load("") in this document.
I'd like to enter the code below and display (pythonlogo.jpg), but for some reason, the black interface screen called pygame window is displayed, but the image is not displayed at all.I thought the location of the executable file and the image might be wrong.
draw_image3.py
import sys
import pygame
from pygame.locals import QUIT
pygame.init()
SURFACE=pygame.display.set_mode(400,300))
FPSCLOCK=pygame.time.Clock()
defmain():
""" "Main routine ""
logo=pygame.image.load("pythonlogo.jpg")
theta = 0
while True:
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
theta+=1
SURFACE.fill((225,225,225))
SURFACE.blit(new_logo, (100,30))
# Rotate the logo and draw the logo in the upper left corner (100, 30) position.
new_logo=pygame.transform.rotate(logo,theta)
pygame.display.update()
FPSCLOCK.tick(30)
if__name__=='__main__':
main()
When I searched, the corresponding part of the book appeared, so I looked at it and found that it was a typo.
The source of the questionnaire is different from the description in the book, so please correct the following:
increase the indentation from logo=pygame.image.load("pythonlogo.jpg")
to while True:
new_logo=pygame.transform.rotate(logo,theta)
The content is the description of the book itself, so I will stop describing the whole revised version.
Please be aware of typographical errors.
© 2024 OneMinuteCode. All rights reserved.