Disabled image rotation.

This commit is contained in:
The Wobbler 2023-07-19 16:19:11 +02:00
parent 3aa2bf1131
commit fe6775531b

View file

@ -15,7 +15,7 @@ red = (255, 20, 20)
working_directory = os.path.dirname(os.path.realpath(__file__)) working_directory = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.abspath(__file__) file_path = os.path.abspath(__file__)
wobblers = [] wobblers = []
max_wobbler_size = 50 max_wobbler_size = 100
images = [] images = []
for image in os.listdir(f"{working_directory}/textures"): for image in os.listdir(f"{working_directory}/textures"):
@ -41,26 +41,26 @@ class Wobbler:
self.age = 0 self.age = 0
self.cube = pygame.Surface((self.height, self.width)) self.image_original = random.choice(images)
self.cube.fill(self.color)
self.cube_no_rot = self.cube self.image = self.image_original
self.cube.set_colorkey(gray) self.image = pygame.transform.scale(self.image, (self.width, self.height))
self.cube = pygame.transform.rotate(self.cube, self.rotation) self.image_no_rot = self.image
self.cube_rect = self.cube.get_rect(center=self.cube_no_rot.get_rect(center=(self.x, self.y)).center) #self.image = pygame.transform.rotate(self.image, self.rotation)
self.image_rect = self.image.get_rect(center=self.image_no_rot.get_rect(center=(self.x, self.y)).center)
def draw(self): def draw(self):
screen.blit(self.cube, self.cube_rect) screen.blit(self.image, self.image_rect)
def update(self): def update(self):
self.width = self.size self.width = self.size
self.height = self.size self.height = self.size
self.cube = pygame.Surface((self.height, self.width)) self.image = self.image_original
self.cube.fill(self.color) self.image = pygame.transform.scale(self.image, (self.width, self.height))
self.cube_no_rot = self.cube self.image_no_rot = self.image
self.cube.set_colorkey(gray) #self.image = pygame.transform.rotate(self.image, self.rotation)
self.cube = pygame.transform.rotate(self.cube, self.rotation) self.image_rect = self.image.get_rect(center=self.image_no_rot.get_rect(center=(self.x, self.y)).center)
self.cube_rect = self.cube.get_rect(center=self.cube_no_rot.get_rect(center=(self.x, self.y)).center)
def move(self): def move(self):
x_offset, y_offset = deg_to_offset(self.rotation, self.speed) x_offset, y_offset = deg_to_offset(self.rotation, self.speed)