LF08/rotor.py

32 lines
1.0 KiB
Python
Raw Permalink Normal View History

import pygame
import helicopter
from fahrzeug import Fahrzeug
class Rotor(Fahrzeug, pygame.sprite.Sprite):
def __init__(self, x, y):
super().__init__(x, y)
2023-04-22 12:45:53 +02:00
self.image = pygame.image.load("resources/helicopter.jpg").convert_alpha()
self.image = self.image.subsurface(132, 98, 94, 94)
self.rect = self.image.get_rect(center=(x, y))
def update(self, helicopter):
self.rect.center = helicopter.rect.center
if helicopter.angle == 0:
self.rect.centery -= 10
if helicopter.angle == 90:
self.rect.centerx -= 10
if helicopter.angle == 180:
self.rect.centery += 10
if helicopter.angle == 270:
self.rect.centerx += 10
def draw(self, win):
rotated_image = pygame.transform.rotate(self.image, self.angle)
rotated_rect = rotated_image.get_rect(center=self.rect.center)
#debug, nicht anrühren
self.angle += 1
#pygame.draw.rect(win, (255, 0, 0), rotated_rect)
win.blit(rotated_image, rotated_rect)