Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] multiple hits !
#4
It would be easier for us if you had put events that pertained to a particular entity inside their own class. For example a players movements in a players class, aliens effects in the aliens class, etc. Then everything you need to know about the alien would be in the alien class.

based on this
Quote:
            if ai_settings.alien_hp <=0:
                 
                stats.score += ai_settings.alien_points * len(aliens)
                sb.prep_score()
                check_high_score(stats, sb)
                 
            else:
                sb.prep_score()
                check_high_score(stats, sb)
It looks like the only thing that occurs when an alien is 0 or less is shown above in the code snippet...

Which none of those seem to remove the entity from the game. Or at least i couldnt find where you remove the entity from the game in scanning the code.

Quote:
def create_alien(ai_settings, screen, aliens, alien_number, row_number):
    """create an alien and place it in a row"""
    alien = Alien(ai_settings, screen)
    alien_width = alien.rect.width
    alien.x = alien_width + 2 * alien_width * alien_number
    alien.rect.x = alien.x
    alien.rect.y = alien.rect.height + 2 * alien.rect.height * row_number
    aliens.add(alien)
You create aliens, and add them to this group, but i dont see you removing them from the group at all except for during check_play_button (which is irrelevant to the problem)
Recommended Tutorials:
Reply


Messages In This Thread
multiple hits ! - by tyler - Jul-02-2018, 01:01 PM
RE: multiple hits ! - by metulburr - Jul-02-2018, 03:10 PM
RE: multiple hits ! - by tyler - Jul-02-2018, 03:35 PM
RE: multiple hits ! - by metulburr - Jul-02-2018, 05:07 PM
RE: multiple hits ! - by tyler - Jul-03-2018, 08:33 AM
RE: multiple hits ! - by metulburr - Jul-03-2018, 11:47 AM
RE: multiple hits ! - by tyler - Jul-03-2018, 12:16 PM
RE: multiple hits ! - by metulburr - Jul-03-2018, 12:38 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020