img und tank
This commit is contained in:
parent
6d5790c1e0
commit
618348294c
BIN
Erzmine.jpg
BIN
Erzmine.jpg
Binary file not shown.
Before Width: | Height: | Size: 9.9 KiB |
BIN
Erzmine.png
Normal file
BIN
Erzmine.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
Tank.png
BIN
Tank.png
Binary file not shown.
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 126 KiB |
@ -1,10 +1,12 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
# Farbe Weiß
|
||||||
|
WHITE = (255, 255, 255)
|
||||||
|
|
||||||
class Erz(pygame.sprite.Sprite):
|
class Erz(pygame.sprite.Sprite):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
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 = self.image.get_rect()
|
||||||
self.rect = 330, 20
|
self.rect = 330, 20
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ class Ziel(pygame.sprite.Sprite):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
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 = self.image.get_rect()
|
||||||
self.rect = 330, 520
|
self.rect = 330, 520
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ class Fahrzeug(pygame.sprite.Sprite):
|
|||||||
self.dest_y = y
|
self.dest_y = y
|
||||||
self.direction = pygame.math.Vector2(0, -1)
|
self.direction = pygame.math.Vector2(0, -1)
|
||||||
self.angle = 0
|
self.angle = 0
|
||||||
|
self.Tank = 100
|
||||||
|
|
||||||
def draw(self, win):
|
def draw(self, win):
|
||||||
rotated_image = pygame.transform.rotate(self.image, self.angle)
|
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:
|
if self.rect.centery > self.dest_y:
|
||||||
self.rect.centery -= self.speed
|
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):
|
def dest(self, pos):
|
||||||
self.dest_x, self.dest_y = pos
|
self.dest_x, self.dest_y = pos
|
||||||
|
4
game.py
4
game.py
@ -42,6 +42,10 @@ def start():
|
|||||||
if tilemap[x][y] == 1:
|
if tilemap[x][y] == 1:
|
||||||
pygame.draw.rect(win, blue, (x * tile_size, y * tile_size, tile_size, tile_size))
|
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.update()
|
||||||
Erzmine.draw(win)
|
Erzmine.draw(win)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user