I am trying to create a "radar" in Pygame. I am having trouble rotating the needle of the radar. How do I rotate it?
import pygame
from pygame.locals import *
SIZE = 800, 800
pygame.init()
screen = pygame.display.set_mode(SIZE)
FPSCLOCK = pygame.time.Clock()
done = False
screen.fill((0, 0, 0))
degree=0
while not done:
for e in pygame.event.get():
if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
done = True
break
for x in range(1,400,10):
pygame.draw.circle(screen,(255,255,255),(400,400),x,1)
line = pygame.draw.line(screen,(10,100,10),(400,400),(400,0),3)
pygame.transform.rotate(line,degree)
pygame.display.flip()
degree+=5
FPSCLOCK.tick(40)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…