1 min
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.
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);
}
}
Subscribe to this blog via RSS.
Low level programming dev diary 28
Text based adventure dev diary 6
Level design developer diary 3
Game engine programming dev diary 14
Audio-visual production dev diary 7
Audio-Visual Production: Particle System Mesh Spawning Issues
Posted on 20 Feb 2020Low level programming dev diary (28) Text based adventure dev diary (6) Level design developer diary (3) Post mortem (4) Ex-machina dev diary (11) Game engine programming dev diary (14) Network game dev diary (11) Audio-visual production dev diary (7)