2023-03-27 08:58:12 +02:00
|
|
|
import pygame
|
2023-03-31 12:33:56 +02:00
|
|
|
import fahrzeug
|
2023-03-31 11:54:10 +02:00
|
|
|
import background
|
2023-03-27 08:58:12 +02:00
|
|
|
import player
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def start():
|
|
|
|
pygame.init()
|
|
|
|
win = pygame.display.set_mode((800, 800))
|
2023-03-31 12:33:56 +02:00
|
|
|
player1 = fahrzeug.Fahrzeug(0, 0)
|
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
|
|
|
|
|
|
|
# Farben
|
|
|
|
white = (255, 255, 255)
|
|
|
|
blue = (0, 0, 255)
|
|
|
|
|
|
|
|
# Tilemap
|
|
|
|
tile_size = 16
|
|
|
|
map_width = 200
|
|
|
|
map_height = 200
|
|
|
|
tilemap = [[0 for y in range(map_height)] for x in range(map_width)]
|
|
|
|
|
|
|
|
for x in range(map_width):
|
|
|
|
for y in range(map_height):
|
|
|
|
tilemap[x][y] = 1
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
# Tilemap zeichnen
|
|
|
|
for x in range(map_width):
|
|
|
|
for y in range(map_height):
|
|
|
|
if tilemap[x][y] == 1:
|
|
|
|
pygame.draw.rect(win, blue, (x * tile_size, y * tile_size, tile_size, tile_size))
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
pygame.display.update()
|