import pygame import player import rotor from fahrzeug import Fahrzeug class Helicopter(Fahrzeug, pygame.sprite.Sprite): def __init__(self, x, y): super().__init__(x, y) self.image = pygame.image.load("resources/helicopter.jpg").convert_alpha() self.image = self.image.subsurface(44, 0, 44, 99) self.rect = self.image.get_rect(center=(x, y)) self.rect.centerx = x self.rect.centery = y self.rotor = rotor.Rotor(self.rect.centerx, self.rect.centery) self.dest_x = x self.dest_y = y self.rect = self.image.get_rect() self.angle = 0 self.speed = 1 def update(self, player): keys = pygame.key.get_pressed() if keys[pygame.K_a]: self.rect.centerx -= self.speed self.dest_x -= self.speed self.angle = 90 if keys[pygame.K_d]: self.rect.centerx += self.speed self.dest_x += self.speed self.angle = 270 if keys[pygame.K_w]: self.rect.centery -= self.speed self.dest_y -= self.speed self.angle = 0 if keys[pygame.K_s]: self.rect.centery += self.speed self.dest_y += self.speed self.angle = 180 self.rotor.update(self) 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) self.rotor.draw(win)