Destroy and Win

Right now, our bullet can destroy the wall, but does nothing to the enemy tank. Let's change that!

enemy_index = bullet.collidelist(enemies)
if enemy_index != -1:
    del enemies[enemy_index]
    bullets.remove(bullet)

This code is the same as what we have for the wall, but with the list changes to enemies instead. With this, you can now destroy the enemy tanks!

Winning

We should win the game when all the enemy tanks are destroyed. We can count the number of enemy tanks remaining in the enemies list using len(enemies).

Change draw() to...

def draw():
    if len(enemies) == 0:
        screen.fill((0,0,0))
        screen.draw.text('You Win!', (260,250), color=(255,255,255), fontsize=100)
    else:
        background.draw()
        tank.draw()
        for enemy in enemies:
            enemy.draw()
        for bullet in bullets:
            bullet.draw()
        for bullet in enemy_bullets:
            bullet.draw()
        for wall in walls:
            wall.draw()

The new code...

if len(enemies) == 0:
    screen.draw.text('You Win!', (260,250), color=(255,255,255), fontsize=100)

Checks if the number of enemies is zero. If it is, it'll fill the screen with black and draw the words "You Win!" in white.

The parameters of screen.draw.text are...

'You Win!'' : This is the string that we want to draw.

(260,250) : This is the position to draw; x=260 and y=250.

color=(255,255,255) : This is the color of the text, in this case, it is white

fontsize=100 : The size of the font.