Ex-Machina Game Dev Diary: Size Boss

Ex-Machina Game Dev Diary: Size Boss

Jan 14, 2019. | By: Lewis Bond
1 min

Size Boss

In order for the level builder to be finished, I needed the player and enemies completed in the game. This was a big part of our game and so I coded the size changing enemy boss.

The aim for this level is too have the player get over different obstacles whilst having the boss moving all over the screen and if it touches the player, they get reset back at the start of the level. The boss bounces all over the screen and when it gets to one point it change sizes to try and catch the player out and reset them.

Code

The code below shwos the movement of the size changing boss. It gets executed if the the sprite’s x or y position does not equal the target point it is trying to reach, it will lerp to the next point. The ‘ai’ is a component of the class, that helps with any movement that isn’t the player. There is a float that gets increased which is then used a the time percentage of the loop.

  if (current_state == MOVING)
  {
    if (static_cast<int>(spriteComponent()->getSprite()->xPos()) !=
          static_cast<int>(ai->getNextValue(X)) &&
        static_cast<int>(spriteComponent()->getSprite()->yPos()) !=
          static_cast<int>(ai->getNextValue(Y)))
    {
      spriteComponent()->getSprite()->xPos(ai->lerp(X));
      spriteComponent()->getSprite()->yPos(ai->lerp(Y));
      ai->setCurrent_time(ai->getCurrent_time() + 1.0f * dt_sec);
    }
  }

PREVIOUS BLOG POST NEXT BLOG POST

About

Those who can do and those who can't teach games design.

Our Bunker



United Kingdom.