Aug-25-2021, 03:55 PM
Well, that's the point. I don't want to rotate the image of a sail. I want to rotate a rectangle. I want to do what you did in tkinter, but in pygame and I do want to be able to manipulate it with control keys in the future, but right now I just want to make that white rectangle rotate like the hands of a clock. And i'm getting real close with my code, but they're not rotating the way i want them to. So if you can help me understand my code, it would be greatly appreciated
import random, pygame, math, sys from pygame.locals import * Blue = (0,0,255) Black = (0, 0, 0) Green = (0,255,0) White = (255,255,255) pygame.init() DISPLAYSURF = pygame.display.set_mode((400, 300)) pygame.display.set_caption('Sailing!') FPS = 30 fpsClock = pygame.time.Clock() Sail = pygame.Surface([100,10]) Sail.set_colorkey (Black) Sail.fill(White) degrees = 0 hyp = 100 x = 200 y = 150 while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() adj = 10 * math.cos(degrees) opp = 10 * math.sin(degrees) dx = adj + 200 dy = opp + 150 rotatedSail = pygame.transform.rotate(Sail, degrees) Sail_rect = Sail.get_rect(topleft = (dx, dy)) DISPLAYSURF.fill(Blue) DISPLAYSURF.blit(rotatedSail, Sail_rect) pygame.display.flip() fpsClock.tick(FPS) degrees += 1