Fahrzeug
This commit is contained in:
parent
76694f3407
commit
89f820f1f7
35
fahrzeug.py
Normal file
35
fahrzeug.py
Normal file
@ -0,0 +1,35 @@
|
||||
import pygame
|
||||
import math
|
||||
|
||||
class Fahrzeug(pygame.sprite.Sprite):
|
||||
def __init__(self, x, y):
|
||||
super().__init__()
|
||||
self.image = pygame.image.load("player.png").convert_alpha()
|
||||
self.rect = self.image.get_rect(center=(x, y))
|
||||
self.rect.centerx = x
|
||||
self.rect.centery = y
|
||||
self.speed = 2
|
||||
self.dest_x = x
|
||||
self.dest_y = y
|
||||
self.direction = pygame.math.Vector2(0, -1)
|
||||
self.angle = 0
|
||||
|
||||
def draw(self, win):
|
||||
rotated_image = pygame.transform.rotate(self.image, self.angle)
|
||||
rotated_rect = rotated_image.get_rect(center=self.rect.center)
|
||||
#self.angle += 1
|
||||
#pygame.draw.rect(win, (255, 0, 0), rotated_rect)
|
||||
win.blit(rotated_image, rotated_rect)
|
||||
|
||||
def update(self):
|
||||
if self.rect.centerx < self.dest_x:
|
||||
self.rect.centerx += self.speed
|
||||
if self.rect.centerx > self.dest_x:
|
||||
self.rect.centerx -= self.speed
|
||||
if self.rect.centery < self.dest_y:
|
||||
self.rect.centery += self.speed
|
||||
if self.rect.centery > self.dest_y:
|
||||
self.rect.centery -= self.speed
|
||||
|
||||
def dest(self, pos):
|
||||
self.dest_x, self.dest_y = pos
|
4
game.py
4
game.py
@ -1,5 +1,5 @@
|
||||
import pygame
|
||||
|
||||
import fahrzeug
|
||||
import background
|
||||
import player
|
||||
import sys
|
||||
@ -7,7 +7,7 @@ import sys
|
||||
def start():
|
||||
pygame.init()
|
||||
win = pygame.display.set_mode((800, 800))
|
||||
player1 = player.Player(0, 0)
|
||||
player1 = fahrzeug.Fahrzeug(0, 0)
|
||||
Erzmine = background.Erz()
|
||||
Tanken = background.Tank()
|
||||
Ziele = background.Ziel()
|
||||
|
Loading…
Reference in New Issue
Block a user