objects
This commit is contained in:
parent
cad6758f1c
commit
f5537d0644
22
game.py
22
game.py
@ -1,18 +1,19 @@
|
||||
import pygame
|
||||
import player
|
||||
import helicopter
|
||||
import background
|
||||
import object
|
||||
import tilemap
|
||||
import sys
|
||||
|
||||
|
||||
def start():
|
||||
pygame.init()
|
||||
win = pygame.display.set_mode((800, 800))
|
||||
player1 = player.Player(0, 0)
|
||||
enemy = helicopter.Helicopter(5, 5)
|
||||
Erzmine = background.Erz()
|
||||
Tanken = background.Tank()
|
||||
Ziele = background.Ziel()
|
||||
Erzmine = object.Erz(320, 20)
|
||||
Tanken = object.Tank(50, 200)
|
||||
Ziele = object.Ziel(320, 600)
|
||||
|
||||
tile_set = pygame.image.load("resources/roads2W.png").convert_alpha()
|
||||
|
||||
@ -53,13 +54,16 @@ def start():
|
||||
|
||||
# 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))
|
||||
debug_selfrect = font.render('self centerx: ' + str(player1.rect.centerx) + ' self centery: ' + str(player1.rect.centery), True, white)
|
||||
win.blit(debug_selfrect, (20, 40))
|
||||
|
||||
# debug_selfrect = font.render('dest x: ' + str(player1.dest_x) + ' dest y: ' + str(player1.dest_y), True, white)
|
||||
# win.blit(debug_selfrect, (20, 60))
|
||||
debug_selfrect = font.render('dest x: ' + str(player1.dest_x) + ' dest y: ' + str(player1.dest_y), True, white)
|
||||
win.blit(debug_selfrect, (20, 60))
|
||||
# ---------------------------
|
||||
|
||||
if player1.rect.colliderect(Tanken.rect):
|
||||
player1.Tank = 250
|
||||
|
||||
Erzmine.update()
|
||||
Erzmine.draw(win)
|
||||
|
||||
@ -73,7 +77,7 @@ def start():
|
||||
player1.draw(win)
|
||||
|
||||
enemy.update(player1)
|
||||
enemy.dest((player1.rect.centerx,player1.rect.centery))
|
||||
enemy.dest((player1.rect.centerx, player1.rect.centery))
|
||||
enemy.draw(win)
|
||||
|
||||
pygame.display.update()
|
||||
|
@ -3,45 +3,38 @@ import pygame
|
||||
# Farbe Weiß
|
||||
WHITE = (255, 255, 255)
|
||||
|
||||
|
||||
class Erz(pygame.sprite.Sprite):
|
||||
def __init__(self):
|
||||
def __init__(self, x, y):
|
||||
super().__init__()
|
||||
self.image = pygame.image.load("resources/Erzmine.png").convert_alpha()
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect = 330, 20
|
||||
|
||||
self.rect = x, y
|
||||
|
||||
def draw(self, win):
|
||||
groesse = pygame.transform.scale(self.image, (100, 100))
|
||||
win.blit(groesse, self.rect)
|
||||
|
||||
|
||||
|
||||
class Tank(pygame.sprite.Sprite):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, x, y):
|
||||
super().__init__()
|
||||
self.image = pygame.image.load("resources/Tank.png").convert_alpha()
|
||||
self.image = pygame.image.load("resources/Tank.jpg").convert_alpha()
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect = 30, 220
|
||||
|
||||
self.rect.center = x, y
|
||||
|
||||
def draw(self, win):
|
||||
groesse = pygame.transform.scale(self.image, (100, 100))
|
||||
win.blit(groesse, self.rect)
|
||||
|
||||
|
||||
|
||||
class Ziel(pygame.sprite.Sprite):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, x, y):
|
||||
super().__init__()
|
||||
self.image = pygame.image.load("resources/Ziel.png").convert_alpha()
|
||||
self.image = pygame.image.load("resources/Ziel.jpg").convert_alpha()
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect = 330, 520
|
||||
|
||||
self.rect = x, y
|
||||
|
||||
def draw(self, win):
|
||||
groesse = pygame.transform.scale(self.image, (100, 100))
|
||||
win.blit(groesse, self.rect)
|
||||
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 110 KiB |
Loading…
Reference in New Issue
Block a user