From 032229a11515f1354981547934f1c3ff6eff9735 Mon Sep 17 00:00:00 2001 From: Yadciel Date: Thu, 20 Apr 2023 09:08:35 +0200 Subject: [PATCH] Helicopter, player, Fahrzeug, Ableitung --- fahrzeug.py | 47 ++++----------------------------------- game.py | 9 ++++++-- helicopter.jpg | Bin 0 -> 9491 bytes helicopter.py | 52 +++++++++++++++++++++++++++++++++++++++++++ player.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ rotor.py | 32 +++++++++++++++++++++++++++ 6 files changed, 154 insertions(+), 45 deletions(-) create mode 100644 helicopter.jpg create mode 100644 helicopter.py create mode 100644 player.py create mode 100644 rotor.py diff --git a/fahrzeug.py b/fahrzeug.py index 9fef426..c428627 100644 --- a/fahrzeug.py +++ b/fahrzeug.py @@ -14,10 +14,6 @@ def get_angle(p1, p2): class Fahrzeug(pygame.sprite.Sprite): def __init__(self, x, y): super().__init__() - self.image = pygame.image.load("player.png").convert_alpha() - self.rect = self.image.get_rect(center=(x, y)) - self.rect.centerx = x - self.rect.centery = y self.speed = 1 self.dest_x = x self.dest_y = y @@ -25,16 +21,6 @@ class Fahrzeug(pygame.sprite.Sprite): self.angle = 0 self.Tank = 250 - 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) - def update(self): self.move() @@ -43,34 +29,9 @@ class Fahrzeug(pygame.sprite.Sprite): self.Tank -= 0.1 self.angle = get_angle((self.rect.centerx, self.rect.centery), (self.dest_x, self.dest_y))-90 - def move(self): - if self.Tank > 0: - if self.rect.centerx < self.dest_x: - self.rect.centerx += self.speed - if self.rect.centerx > self.dest_x: - self.rect.centerx -= self.speed - if self.rect.centery < self.dest_y: - self.rect.centery += self.speed - if self.rect.centery > self.dest_y: - self.rect.centery -= self.speed + def move(self): + pass - keys = pygame.key.get_pressed() - if keys[pygame.K_LEFT]: - self.rect.centerx -= self.speed - self.dest_x -= self.speed - self.angle = 90 - if keys[pygame.K_RIGHT]: - self.rect.centerx += self.speed - self.dest_x += self.speed - self.angle = 270 - if keys[pygame.K_UP]: - self.rect.centery -= self.speed - self.dest_y -= self.speed - self.angle = 0 - if keys[pygame.K_DOWN]: - self.rect.centery += self.speed - self.dest_y += self.speed - self.angle = 180 + def dest(self, pos): + self.dest_x, self.dest_y = pos - def dest(self, pos): - self.dest_x, self.dest_y = pos diff --git a/game.py b/game.py index ce02bcb..0a2bcc8 100644 --- a/game.py +++ b/game.py @@ -1,5 +1,6 @@ import pygame -import fahrzeug +import player +import helicopter import background import tilemap import sys @@ -7,7 +8,8 @@ import sys def start(): pygame.init() win = pygame.display.set_mode((800, 800)) - player1 = fahrzeug.Fahrzeug(0, 0) + player1 = player.Player(0, 0) + enemy = helicopter.Helicopter(5, 5) Erzmine = background.Erz() Tanken = background.Tank() Ziele = background.Ziel() @@ -70,4 +72,7 @@ def start(): player1.update() player1.draw(win) + enemy.update(player1) + enemy.draw(win) + pygame.display.update() diff --git a/helicopter.jpg b/helicopter.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c42fa185597cf94942c074dac3cc51b31c10e7b9 GIT binary patch literal 9491 zcmcIq_g@p;v!)87^j?$@0tg~4i1ZQygf1l@MLV-JvPE&SaDz=D~flhY@ zL9t?i>=+>H7&$^Djv0XiqP9^e6gdzu7>*GGlD6R_B%DB|!IBVUYAgwfLctLT(l%n7 z0NX~wNhk!8Y(gSQqyW+%D2W7b*OlEyz)2V+2?gJVLq$*o6pn-lMzEr`x5uCa@&yHh zF(iEq35Nk9;lME{5J65AjvT|?LbB2cW40;aMI-{8L;!C?!6XE9n@oWtQNU3st*orX#l^`c#2A8vBp{&}9UUDA1R^RbO0K1@ zuCAq}CHZJbc0*sPCKr!$!1UYIb4vryV2-~PJ0s;%i zBA6;&mdM9*7+`K;I_#JOBM(?f*^rmlX*9hZ{()DtUq<$c2Z4$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ttio z+ZV%U!{Tc5!pptJ*dn)hL6Y9Hlh5Up$hQ}h;*y)OV10dw0I8Yn`xYmA#N$wEX>lww zXf&hClP<@iZ&Ai)I|{Oi_nfi>?eg$CoL@;iiB6GidleR;oKElR9DH-`lb;}yZN0ql zs`m5N&K&KQ#&EB6JwuxZ9*<0K87MFpkr)XaC{pTt2QyrC`pF%b5B=RWF5ZES4g z&B-{~zRB#k9^}>8WQh6ja=5nn%22BIktHWFJg2SiqjKaf;O$+E=u4-E#TvnPX>H0c yb2L5=JE2}0hJLEOf;G|mXI$I2dPqV$UfuD0rSdJQg8XL(g}#mnv=-v@?7sjJY=_za literal 0 HcmV?d00001 diff --git a/helicopter.py b/helicopter.py new file mode 100644 index 0000000..f6ebc3a --- /dev/null +++ b/helicopter.py @@ -0,0 +1,52 @@ +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("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) + diff --git a/player.py b/player.py new file mode 100644 index 0000000..56760ec --- /dev/null +++ b/player.py @@ -0,0 +1,59 @@ +import pygame +from fahrzeug import Fahrzeug + +class Player(Fahrzeug, pygame.sprite.Sprite): + def __init__(self, x, y): + super().__init__(x, y) + self.image = pygame.image.load("player.png").convert_alpha() + self.rect = self.image.get_rect(center=(x, y)) + self.rect.centerx = x + self.rect.centery = y + self.speed = 1 + self.dest_x = x + self.dest_y = y + self.direction = pygame.math.Vector2(0, -1) + self.angle = 0 + self.Tank = 250 + + + 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) + + def move(self): + if self.Tank > 0: + if self.rect.centerx < self.dest_x: + self.rect.centerx += self.speed + if self.rect.centerx > self.dest_x: + self.rect.centerx -= self.speed + if self.rect.centery < self.dest_y: + self.rect.centery += self.speed + if self.rect.centery > self.dest_y: + self.rect.centery -= self.speed + + keys = pygame.key.get_pressed() + if keys[pygame.K_LEFT]: + self.rect.centerx -= self.speed + self.dest_x -= self.speed + self.angle = 90 + if keys[pygame.K_RIGHT]: + self.rect.centerx += self.speed + self.dest_x += self.speed + self.angle = 270 + if keys[pygame.K_UP]: + self.rect.centery -= self.speed + self.dest_y -= self.speed + self.angle = 0 + if keys[pygame.K_DOWN]: + self.rect.centery += self.speed + self.dest_y += self.speed + self.angle = 180 + + def dest(self, pos): + self.dest_x, self.dest_y = pos diff --git a/rotor.py b/rotor.py new file mode 100644 index 0000000..c3b80d7 --- /dev/null +++ b/rotor.py @@ -0,0 +1,32 @@ +import pygame +import helicopter +from fahrzeug import Fahrzeug + +class Rotor(Fahrzeug, pygame.sprite.Sprite): + def __init__(self, x, y): + super().__init__(x, y) + self.image = pygame.image.load("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) \ No newline at end of file