img und tank

This commit is contained in:
Yadciel 2023-04-14 12:31:54 +02:00
parent 6d5790c1e0
commit 618348294c
8 changed files with 12 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

BIN
Erzmine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
Tank.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 126 KiB

BIN
Ziel.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

BIN
Ziel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

@ -1,10 +1,12 @@
import pygame
# Farbe Weiß
WHITE = (255, 255, 255)
class Erz(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.image.load("Erzmine.jpg").convert_alpha()
self.image = pygame.image.load("Erzmine.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect = 330, 20
@ -34,7 +36,7 @@ class Ziel(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.image.load("Ziel.jpg").convert_alpha()
self.image = pygame.image.load("Ziel.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect = 330, 520

View File

@ -13,6 +13,7 @@ class Fahrzeug(pygame.sprite.Sprite):
self.dest_y = y
self.direction = pygame.math.Vector2(0, -1)
self.angle = 0
self.Tank = 100
def draw(self, win):
rotated_image = pygame.transform.rotate(self.image, self.angle)
@ -32,5 +33,8 @@ class Fahrzeug(pygame.sprite.Sprite):
if self.rect.centery > self.dest_y:
self.rect.centery -= self.speed
if self.rect.centerx != self.dest_x and self.rect.centery != self.dest_y:
self.Tank -= 0.1
def dest(self, pos):
self.dest_x, self.dest_y = pos

View File

@ -42,6 +42,10 @@ def start():
if tilemap[x][y] == 1:
pygame.draw.rect(win, blue, (x * tile_size, y * tile_size, tile_size, tile_size))
font = pygame.font.SysFont(None, 24)
img = font.render('Tank: '+str(round(player1.Tank,2)), True, white)
win.blit(img, (20, 20))
Erzmine.update()
Erzmine.draw(win)