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