Added new classes
This commit is contained in:
68
test.py
Normal file
68
test.py
Normal file
@@ -0,0 +1,68 @@
|
||||
import pygame
|
||||
import GameObject
|
||||
import Enemy
|
||||
import Utils
|
||||
|
||||
pygame.init()
|
||||
|
||||
|
||||
pygame.display.set_caption("TESTFENSTER")
|
||||
pygame.mouse.set_visible(True)
|
||||
screen = pygame.display.set_mode((800,600))
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
image_enemy = Utils.load_image("Rastergrafik.png")
|
||||
testimage = Utils.load_image("Rastergrafik.png")
|
||||
|
||||
#testimage.set_colorkey((255,0,255), pygame.RLEACCELOK)
|
||||
|
||||
objects = list()
|
||||
|
||||
enemy1 = Enemy.Enemy("Penner", 500, 500, image_enemy)
|
||||
|
||||
|
||||
gamestate = True
|
||||
pos_x = 50
|
||||
pos_y = 50
|
||||
|
||||
while(gamestate):
|
||||
|
||||
screen.fill((255,255,255))
|
||||
|
||||
for event in pygame.event.get():
|
||||
if(event.type == pygame.QUIT):
|
||||
gamestate = False
|
||||
|
||||
image = screen.blit(testimage, (pos_x, pos_y))
|
||||
|
||||
mouse_pos = pygame.mouse.get_pos()
|
||||
|
||||
#print(mouse_pos)
|
||||
#print(image.topleft) #Gibt die Position einen Surfaces "obenlinks" aus
|
||||
#print(image.size) #Gibt die Größe eines Surfaces aus
|
||||
|
||||
max = tuple(map(lambda i, j : i+j, image.topleft, image.size))
|
||||
#Wenn Mausposition X-Achse innerhalb Anfangsposition+Breite
|
||||
if(mouse_pos[0] <= max[0] and mouse_pos[0] >= image.topleft[0]):
|
||||
#Wenn Mausposition Y-Achse innerhalb Anfangsposition+Höhe
|
||||
if(mouse_pos[1] <= max[1] and mouse_pos[1] >= image.topleft[1]):
|
||||
print("Treffer")
|
||||
pos_x = mouse_pos[0]
|
||||
pos_y = mouse_pos[1]
|
||||
|
||||
#Rendere alle Objecte in objects Liste
|
||||
for object in objects:
|
||||
object:GameObject.GameObject
|
||||
|
||||
if(pygame.mouse.get_pressed()[0]):
|
||||
object.setpos(mouse_pos[0], mouse_pos[1])
|
||||
|
||||
object.render(screen)
|
||||
|
||||
enemy1.render(screen)
|
||||
#if(mouse_pos <= (image.topleft+image.size) and mouse_pos >= image.topleft):
|
||||
# print("HIIIIITTT!!!!")
|
||||
|
||||
clock.tick(60)
|
||||
pygame.display.flip()
|
||||
Reference in New Issue
Block a user