1 min
The size boss had been done before but it wasn’t very good good in terms of optimisation and readability so I cleaned it up and changed a lot of it.
The previous code can be seen in a previous blog post but it showed a sample of the code which had a really unreadable if statement that waasn’t necessary at all. Since it moves by a lerp a timer can just be used to as a checker for when to update its x and y position. Once the timer reaches the timeout value then it changes the state from MOVING to SIZE so then the size uses the lerp as well. The timer is also then reset back to 0 so it can start counting up again. Checking if the sprite hasn’t reached it’s destination isn’t necessary anymore, because when the timer reaches the timeout function then the sprite will be at or very close to the intended desination due to the lerp.
if (current_state == MOVING)
{
if (timer->count < timer->timeout)
{
sprite.xPos(timer->lerp(last_point.x, next_point.x, percentage));
sprite.yPos(timer->lerp(last_point.y, next_point.y, percentage));
}
else
{
// rest of the code
}
}
The gif below shows how the size boss will act in the game. It will move around then changes size and then repeat.
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)