Changed enemy class
This commit is contained in:
42
test.py
42
test.py
@@ -2,6 +2,7 @@ import pygame
|
||||
import GameObject
|
||||
import Enemy
|
||||
import Utils
|
||||
import random
|
||||
|
||||
pygame.init()
|
||||
|
||||
@@ -17,26 +18,7 @@ testimage = Utils.load_image("Rastergrafik.png")
|
||||
|
||||
#testimage.set_colorkey((255,0,255), pygame.RLEACCELOK)
|
||||
|
||||
objects = list()
|
||||
|
||||
c = 0
|
||||
y = 10
|
||||
for x in range(10):
|
||||
obj = Enemy.Enemy(F"Penner-{x}", 500, y, 35, 35, image_enemy)
|
||||
objects.append(obj)
|
||||
obj = GameObject.GameObject("Test", y,0,0,0, testimage)
|
||||
objects.append(obj)
|
||||
y += 35
|
||||
|
||||
|
||||
for object in GameObject.GameObject.objects:
|
||||
object:GameObject
|
||||
if(object.name == "Penner-9"):
|
||||
print("Vorletzter!")
|
||||
object.setpos(400,400)
|
||||
print(object)
|
||||
|
||||
#rint(F"{len(GameObject.GameObject.objects)}")
|
||||
enemy = Enemy.Enemy("Enemy-1", (screen.get_size()[0]/2) -30,30,35,35, screen,testimage)
|
||||
|
||||
|
||||
gamestate = True
|
||||
@@ -69,13 +51,21 @@ while(gamestate):
|
||||
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])
|
||||
enemy.render(screen)
|
||||
|
||||
rand = random.randint(0, 100)
|
||||
|
||||
if rand == 50:
|
||||
enemy.fire(screen)
|
||||
|
||||
if rand == 20:
|
||||
enemy.move(5)
|
||||
if rand == 50:
|
||||
enemy.move(-5)
|
||||
|
||||
enemy.shoot()
|
||||
|
||||
|
||||
object.render(screen)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user