Flea Enemy

This page will go over what the flea does in game, and how it works.

What the Flea does

This enemy is weak compared to the others in the game, and provides the player a health and/or damage increase after defeating it in battle. The Flea also moves erratically all over the screen, potentially forcing the player to fight it.

How it works

private void tmrPlayerMove_Tick(object sender, EventArgs e) {
    // randomly move flea
    if (fleaFlag == true) {
        enemyFlea.Move();
        enemyFlea.MoveRand();

        // check collision with enemies and walls
        if (HitAWall(enemyFlea)) {
            enemyFlea.MoveBack();
        }
        if (HitAChar(enemyFlea, enemyPoisonPacket)) {
            enemyFlea.MoveBack();
        }
        if (HitAChar(enemyFlea, enemyCheeto)) {
            enemyFlea.MoveBack();
        }
        if (HitAChar(enemyFlea, bossKoolaid)) {
            enemyFlea.MoveBack();
        }

        // update flea's picture box
        picEnemyFlea.Location = new Point((int)enemyFlea.Position.x, (int)enemyFlea.Position.y);
    }
}

Random Movement

The flea's random movement is enabled through the same method that reads the player's inputs to move. So the flea will interact similarly to the player when contacting terrain and other enemies. The actual random movement of the flea is executed by the method below, which the code passes a randomly generated int between 0-31.

public void MoveRand(int moveDir) {
    switch (moveDir) {
        case 0:
            MoveVector(new Vector2(-1, 0)); //west
            break;
        case 1:
            MoveVector(new Vector2(+1, 0)); //east
            break;
        case 2:
            MoveVector(new Vector2(0, -1)); //north
            break;
        case 3:
            MoveVector(new Vector2(0, +1)); //south
            break;
        case 4:
            MoveVector(new Vector2(-1, -1)); //nw
            break;
        case 5:
            MoveVector(new Vector2(+1, -1)); //ne
            break;
        case 6:
            MoveVector(new Vector2(-1, +1)); //sw
            break;
        case 7:
            MoveVector(new Vector2(+1, +1)); //se
            break;
        case 8:
            this.ResetMoveSpeed();
            break;
        default:
            break;
    }
}

The flea's movement functions very similarly to the player's, but instead of checking for a key input, a switch case is used to randomize the direction of the flea's movement. There is a 1 in 4 chance that the flea will pick a new move direction, a 1 in 32 chance that it will momentarily stop moving all together, and will otherwise continue moving in the last selected direction.

Enemy enemyFlea = new Enemy(CreatePosition(picEnemyFlea), CreateCollider(picEnemyFlea, PADDING), 1);

Lowered Strength

The Flea's strength is lowered through passing a smaller base strength multiplier in its instantiation, resulting in it dealing half as much damage to the player compared to the other enemies.

public Enemy(Vector2 initPos, Collider collider, int strength=2) : base(initPos, collider, strength) { }

The Enemy constructor calls it's parent's constructor for the overloaded variables.

public BattleCharacter(Vector2 initPos, Collider collider, int strength=2) : base(initPos, collider)
{
    MaxHealth = 20;
    _strength = strength;
    Health = MaxHealth;
}

So here you can see that the Flea's strength is modified from the default.

Player Buffs

For the flea's player movement and damage buffs, it must be defeated in battle. It's implementation is in the following if statement, within the method that updates after each attack.

if (enemy.Health <= 0 enemy.name == "enemyFlea") {
    Random rand = new Random();
    int buffEffect = rand.Next(2);
    
    switch (buffEffect) {
        case 0:
            player.buffHealth();
            break;
        case 1:
            player.buffAttack();
            break;
        case 2:
            player.buffHealth();
            player.buffAttack();
            break;
    }
}

This if statement just randomly chooses to either increase the players health, damage, or both. The implementation of the buffs are below.

public void buffHealth(int amount = 5) {
    MaxHealth += amount;
    Health += amount;
}

//increases strength
public void buffAttack(int amount = 1) {
    _strength += amount;
}

MaxHealth, Health, and _strength are attributes of the Player() class, which are essential to the battle sequences. These two methods simply increase those values by a set amount.

When the player is given a strength boost, a message will appear on the screen to notify the player.

Last updated