2023-03-27 08:58:12 +02:00
|
|
|
import pygame
|
2023-04-20 09:08:35 +02:00
|
|
|
import player
|
|
|
|
import helicopter
|
2023-03-31 11:54:10 +02:00
|
|
|
import background
|
2023-04-19 10:59:13 +02:00
|
|
|
import tilemap
|
2023-03-27 08:58:12 +02:00
|
|
|
import sys
|
|
|
|
|
|
|
|
def start():
|
|
|
|
pygame.init()
|
|
|
|
win = pygame.display.set_mode((800, 800))
|
2023-04-20 09:08:35 +02:00
|
|
|
player1 = player.Player(0, 0)
|
|
|
|
enemy = helicopter.Helicopter(5, 5)
|
2023-03-31 11:54:10 +02:00
|
|
|
Erzmine = background.Erz()
|
|
|
|
Tanken = background.Tank()
|
|
|
|
Ziele = background.Ziel()
|
2023-03-27 08:58:12 +02:00
|
|
|
|
2023-04-22 12:45:53 +02:00
|
|
|
tile_set = pygame.image.load("resources/roads2W.png").convert_alpha()
|
2023-04-19 10:59:13 +02:00
|
|
|
|
2023-03-27 08:58:12 +02:00
|
|
|
# Farben
|
|
|
|
white = (255, 255, 255)
|
|
|
|
blue = (0, 0, 255)
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
pygame.quit()
|
|
|
|
sys.exit()
|
|
|
|
if event.type == pygame.MOUSEBUTTONDOWN:
|
|
|
|
player1.dest(pygame.mouse.get_pos())
|
|
|
|
|
|
|
|
# Hintergrundfarbe
|
|
|
|
win.fill(white)
|
2023-04-19 10:59:13 +02:00
|
|
|
tile = tilemap.tilemap()
|
2023-04-19 12:23:30 +02:00
|
|
|
# Tilemap
|
|
|
|
tile_size = tile.tilesize
|
2023-04-19 10:59:13 +02:00
|
|
|
# Schleife durch das Tilemap-Array
|
|
|
|
for y in range(len(tile.map_array)):
|
|
|
|
for x in range(len(tile.map_array[y])):
|
|
|
|
# Überprüfen, ob der Wert in der aktuellen Zelle gleich 0 ist
|
|
|
|
if tile.map_array[y][x] == 0:
|
|
|
|
win.blit(tile.road_quer, (x * tile_size, y * tile_size))
|
2023-04-19 12:23:30 +02:00
|
|
|
if tile.map_array[y][x] == 1:
|
|
|
|
win.blit(tile.road_senkrecht, (x * tile_size, y * tile_size))
|
|
|
|
if tile.map_array[y][x] == 2:
|
|
|
|
win.blit(tile.road_btr, (x * tile_size, y * tile_size))
|
|
|
|
if tile.map_array[y][x] == 3:
|
|
|
|
win.blit(tile.road_tbr, (x * tile_size, y * tile_size))
|
2023-03-27 08:58:12 +02:00
|
|
|
|
2023-04-14 12:31:54 +02:00
|
|
|
font = pygame.font.SysFont(None, 24)
|
2023-04-19 10:59:13 +02:00
|
|
|
tank_label = font.render('Tank: ' + str(round(player1.Tank, 2)), True, white)
|
2023-04-19 08:59:00 +02:00
|
|
|
win.blit(tank_label, (20, 20))
|
|
|
|
|
2023-04-19 10:59:13 +02:00
|
|
|
# debug ausgabe
|
|
|
|
# ---------------------------
|
|
|
|
# debug_selfrect = font.render('self centerx: ' + str(player1.rect.centerx) + ' self centery: ' + str(player1.rect.centery), True, white)
|
|
|
|
# win.blit(debug_selfrect, (20, 40))
|
2023-04-19 08:59:00 +02:00
|
|
|
|
2023-04-19 10:59:13 +02:00
|
|
|
# debug_selfrect = font.render('dest x: ' + str(player1.dest_x) + ' dest y: ' + str(player1.dest_y), True, white)
|
|
|
|
# win.blit(debug_selfrect, (20, 60))
|
|
|
|
# ---------------------------
|
2023-04-14 12:31:54 +02:00
|
|
|
|
2023-03-31 11:54:10 +02:00
|
|
|
Erzmine.update()
|
|
|
|
Erzmine.draw(win)
|
|
|
|
|
|
|
|
Tanken.update()
|
|
|
|
Tanken.draw(win)
|
|
|
|
|
|
|
|
Ziele.update()
|
|
|
|
Ziele.draw(win)
|
|
|
|
|
2023-03-27 08:58:12 +02:00
|
|
|
player1.update()
|
|
|
|
player1.draw(win)
|
|
|
|
|
2023-04-20 09:08:35 +02:00
|
|
|
enemy.update(player1)
|
|
|
|
enemy.draw(win)
|
|
|
|
|
2023-04-19 10:59:13 +02:00
|
|
|
pygame.display.update()
|