diff --git a/game.py b/game.py index 1ab9cd8..0ff5bd7 100644 --- a/game.py +++ b/game.py @@ -12,9 +12,9 @@ def start(): win = pygame.display.set_mode((800, 800)) player1 = player.Player(500, 500) enemy = helicopter.Helicopter(50, 50) - Erzmine = object.Erz(600, 100) - Tanken = object.Tank(160, 200) - Ziele = object.Ziel(600, 900) + Erzmine = object.Erz(600, 40) + Tanken = object.Tank(200, 220) + Ziele = object.Ziel(600, 750) GameOver = False GO = game_over.GameOver() @@ -39,6 +39,13 @@ def start(): if player1.rect.colliderect(enemy.rect): GameOver = True + if player1.rect.colliderect(Erzmine.rect): + player1.Erz += 1 + + if player1.rect.colliderect(Ziele.rect): + if player1.Erz >= 1: + player1.Erz -= 1 + if GameOver == False: # Hintergrundfarbe win.fill(white) diff --git a/helicopter.py b/helicopter.py index 57f978f..08da79c 100644 --- a/helicopter.py +++ b/helicopter.py @@ -4,12 +4,13 @@ import rotor from fahrzeug import Fahrzeug, get_angle import time + 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.image = pygame.transform.scale(self.image, (self.image.get_width()*1.2, self.image.get_height()*1.2)) + self.image = pygame.transform.scale(self.image, (self.image.get_width() * 1.2, self.image.get_height() * 1.2)) self.rect = self.image.get_rect(center=(x, y)) self.rect.centerx = x self.rect.centery = y @@ -56,7 +57,7 @@ class Helicopter(Fahrzeug, pygame.sprite.Sprite): if self.rect.centerx != self.dest_x or self.rect.centery != self.dest_y: if self.Tank > 0: self.Tank -= 0.1 - self.angle = get_angle((self.rect.centerx, self.rect.centery), (self.dest_x, self.dest_y))-90 + self.angle = get_angle((self.rect.centerx, self.rect.centery), (self.dest_x, self.dest_y)) - 90 self.rotor.update(self) @@ -64,10 +65,10 @@ class Helicopter(Fahrzeug, pygame.sprite.Sprite): 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) + # 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) + self.rotor.draw(win) diff --git a/object.py b/object.py index 272820d..3e34e84 100644 --- a/object.py +++ b/object.py @@ -8,37 +8,44 @@ class Erz(pygame.sprite.Sprite): def __init__(self, x, y): super().__init__() self.image = pygame.image.load("resources/Erzmine.png").convert_alpha() - self.rect = self.image.get_rect() + self.scaled_image = pygame.transform.scale(self.image, (self.image.get_width() / 2, self.image.get_height() / 2)) + self.rect = self.scaled_image.get_rect(center=(x, y)) self.rect.centerx = x self.rect.centery = y def draw(self, win): - groesse = pygame.transform.scale(self.image, (100, 100)) - win.blit(groesse, self.rect) + pygame.draw.rect(win, (255, 0, 0), self.rect) + win.blit(self.scaled_image, self.rect) + class Tank(pygame.sprite.Sprite): def __init__(self, x, y): super().__init__() self.image = pygame.image.load("resources/Tank.jpg").convert_alpha() - self.scaled_image = pygame.transform.scale(self.image, (self.image.get_width() / 100, self.image.get_height() / 100)) - self.rect = self.scaled_image.get_rect() + self.scaled_image = pygame.transform.scale(self.image, (self.image.get_width() / 20, self.image.get_height() / 20)) + self.rect = self.scaled_image.get_rect(center=(x, y)) self.rect.centerx = x self.rect.centery = y def draw(self, win): - groesse = pygame.transform.scale(self.image, (100, 100)) - win.blit(groesse, self.rect) + pygame.draw.rect(win, (255, 0, 0), self.rect) + win.blit(self.scaled_image, self.rect) + + class Ziel(pygame.sprite.Sprite): def __init__(self, x, y): super().__init__() self.image = pygame.image.load("resources/Ziel.jpg").convert_alpha() - self.rect = self.image.get_rect() + self.scaled_image = pygame.transform.scale(self.image, (self.image.get_width() / 3, self.image.get_height() / 3)) + self.rect = self.scaled_image.get_rect(center=(x, y)) self.rect.centerx = x self.rect.centery = y def draw(self, win): - groesse = pygame.transform.scale(self.image, (100, 100)) - win.blit(groesse, self.rect) + pygame.draw.rect(win, (255, 0, 0), self.rect) + win.blit(self.scaled_image, self.rect) + + diff --git a/player.py b/player.py index 37dfe2f..df28202 100644 --- a/player.py +++ b/player.py @@ -24,7 +24,7 @@ class Player(Fahrzeug, pygame.sprite.Sprite): #debug, nicht anrühren #self.angle += 1 - #pygame.draw.rect(win, (255, 0, 0), rotated_rect) + pygame.draw.rect(win, (255, 0, 0), rotated_rect) win.blit(rotated_image, rotated_rect)