I have a bunch of different bullets with different list and I wondering if I could shorten the way of doing this without copying and pasting and making thousands of lines of code.
the code is checking if all those bullets list are collided with the enemy sprite
is there way I could put a list in a list or something so I dont have to write all these code for example I have
bullet1 = []
bullet2 = []
bullet3 = []
# and store all those bullet in another list?
all_bullets = [bullet1,bullet2,bullet3] is that possibale?
def upgrade_tower_1():
if upgrade1.x == 9000:
collid_1 = False
for monster in monsters:
for shootss in shootsright:
if monster.rect.colliderect(shootss.rect):
collid_1 = False
monster.direction = "hit"
if monster.health > 2:
monster.health -= 0.2
else:
monster.x = void.x + 20
monster.y = void.y + 150
money1.cash += 5
if upgrade5.x == 9000:
collid_1 = False
for monster in monsters:
for shootss in shootsright:
if monster.rect.colliderect(shootss.rect):
collid_1 = False
monster.direction = "hit"
if monster.health > 2:
monster.health -= 0.3
else:
monster.x = void.x + 20
monster.y = void.y + 150
money1.cash += 5
if upgrade5.x == 9000:
collid_1 = False
for monster in monsters:
for shootss2 in shootsright2:
if monster.rect.colliderect(shootss2.rect):
collid_1 = False
monster.direction = "hit"
if monster.health > 2:
monster.health -= 0.3
else:
monster.x = void.x + 20
monster.y = void.y + 150
money1.cash += 5