# Defeating Enemies

## How removing enemies works

New functions were created so that default values can be passed to the Enemy class, which hides their location away from the player's reach and creates a collider of zero size.

```clike
private Vector2 RemovePosition(int x, int y) {
            return new Vector2(x, y);
        }
        
private Collider RemoveCollider()
        {
            Rectangle rect = new Rectangle(0,0,0,0);
            return new Collider(rect);
        }
```

This was later used in the Fight function, where when the player character collides with an enemy, the enemy would be checked by name to then reinitialized as a new enemy with no image or collider.

```clike
switch (enemy.Name) {
                case "bossKoolaid":
                    bossKoolaid = new Enemy(RemovePosition(0,0), RemoveCollider());
                    bossKoolaid.Img = null;
                    picBossKoolAid.BackgroundImage = null;
                    break;
                case "enemyPoisonPacket":
                    enemyPoisonPacket = new Enemy(RemovePosition(0,0), RemoveCollider());
                    enemyPoisonPacket.Img = null;
                    picEnemyPoisonPacket.BackgroundImage = null;

                    break;
                case "enemyCheeto":
                    enemyCheeto = new Enemy(RemovePosition(0, 0), RemoveCollider());
                    enemyCheeto.Img = null;
                    picEnemyCheeto.BackgroundImage = null;
                    break;
                case "enemyFlea":
                    enemyFlea = new Enemy(RemovePosition(0, 0), RemoveCollider());
                    picEnemyFlea.BackgroundImage = null;
                    fleaFlag = false;
                    break;
            }
```

## How the Level looks

<figure><img src="https://1055530831-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTLAKl9MnL4UmPhZlb3vF%2Fuploads%2F00NiGCW3CSWiAcms1YmH%2FIMG_6552.png?alt=media&#x26;token=571f72c9-fbee-4998-b79d-cc16cf9ce345" alt=""><figcaption></figcaption></figure>

Here is a screen shot of the level after the Flea has been defeated.

With each enemy defeated, a default value of 20 points is added to the player's score.
