Compare commits

...
2 Commits
Author SHA1 Message Date
Jørn Guldberg 4e3468a6c3 Merge 2023-05-18 10:10:50 +02:00
Jørn Guldberg 6c8780a832 Updates 2023-05-18 10:09:30 +02:00
13 changed files with 44 additions and 9 deletions

No files matched your search

+44 -9
View File
@@ -229,8 +229,47 @@ class Snowball(pygame.sprite.Sprite):
self.rect = self.image.get_rect()
self.rect.center=(x, y)
def move(self, player):
self.rect.move_ip(4,0)
def move(self, snowball_list, enemy_list):
target_enemy = None
for enemy in enemy_list:
if enemy.alive == 1:
target_enemy = enemy
break
if enemy == None:
return
enemy_x = enemy.rect.x
enemy_y = enemy.rect.y
snowball_x = self.rect.x
snowball_y = self.rect.y
if abs(enemy_x - snowball_x) < 8 and abs(enemy_y - snowball_y) < 8:
snowball_list.remove(self)
enemy.damage(50)
delta_move_x = 0
delta_move_y = 0
if enemy_x < snowball_x:
delta_move_x = -4
elif enemy_x > snowball_x:
delta_move_x = 4
if enemy_y < snowball_y:
delta_move_y = -4
elif enemy_y > snowball_y:
delta_move_y = 4
self.rect.move_ip(delta_move_x, delta_move_y)
#if (self.rect.right > 600):
# self.rect.top = 0
# self.rect.center = (0, 400)
@@ -417,14 +456,10 @@ def start_new_level(count, health):
def valid_space(new_tower):
global snowman_list
global cakeman_list
global reindeer_list
combined_tower_list = snowman_list + cakeman_list
combined_tower_list = snowman_list + cakeman_list + reindeer_list
for old_tower in combined_tower_list:
print("new: ")
print(new_tower.rect)
print("old: ")
print(old_tower.rect)
if new_tower.rect.colliderect(old_tower.rect):
return False
@@ -619,7 +654,7 @@ while True:
kagemand_animation_step = (kagemand_animation_step + 1) % 8
for snowball in snowball_list:
snowball.move(menu_snowman)
snowball.move(snowball_list, enemy_list)
snowball.draw(DISPLAYSURF)
for laser_beam in laser_beam_list:
Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB