Aug-23-2021, 09:20 PM
Hello, i'm having trouble rotating a rectangle on screen. I'm not a computer science student and I need help because I have been at it for a couple of days.
The goal is to rotate a rectangle around it's top left corner like a sail around a post, but now the white rectangle rotates around it's center in a black square...
Here's my code:
Any help is welcomed
thank you
The goal is to rotate a rectangle around it's top left corner like a sail around a post, but now the white rectangle rotates around it's center in a black square...
Here's my code:
import random, pygame, sys from pygame.locals import * Blue = (0,0,255) Green = (0,255,0) White = (255,255,255) pygame.init() DISPLAYSURF = pygame.display.set_mode((400, 300)) DISPLAYSURF.fill(Blue) pygame.display.set_caption('Sailing!') FPS = 30 fpsClock = pygame.time.Clock() Sail = pygame.Surface([100,10]) Sail.fill(White) degrees = 0 while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() rotatedSail = pygame.transform.rotozoom(Sail, degrees, 1) Sail_rect = Sail.get_rect(topleft =(200,150)) DISPLAYSURF.blit(rotatedSail, Sail_rect) pygame.display.flip() fpsClock.tick(FPS) degrees += 1I played around with the code using transform.rotate, draw.rect and I watched youtube videos, but i can't use rotate with draw.rect, i make the image fly off the screen or I just have different version of this problem and I don't want to load an image I want to create a rectangle.
Any help is welcomed
thank you