2 mins
Since the size changing bos was done (albeit temporarily done), the dash boss was next as we need to pick up the pace of the project.
We had an idea about how the dash boss level would go. The player had to traverse different parts whilst the dash would be randomly dashing to differnet parts of the map and you had to avoid them. This is very similar to the size changing boss so it might be chagned to make it more unique and differnet to other bosses.
The code below shows a sample of the dash boss worked. A direction was randomly chosen and whichever one came the boss would dash in that direction. When a direction was chosen, if it was a north or south then the y position of the sprite would be updated and if it was east or west then the x position would be updated. In the code below the code below it shows y position = y postion - speed * dt, so the if y position was 50 and speed was 25 then it would y postion = 50 - 25 * dt. Dt is the time between frames, this is required so it will go at the same speed even if the frame rate changes. So the y psoition will be less then 50, which was it’s previous position, so it will be higher up on the screen and be going north.
case NORTH:
{
spriteComponent()->getSprite()->yPos(spriteComponent()->getSprite()->yPos()-speed*dt);
break;
}
Since it randomised the direction, I had to include one of the libraries that did this, there is a small issue though with randomisation. The best way to is using the
Once the number has been chosen it is then cast to a ‘Direction’, this is an enumeration which contains, NORTH, EAST, SOUTH and WEST.
std::random_device rd;
// std::uniform_int_distribution<int> dist(1, 4);
// dir = static_cast<Direction>(dist(rd));
srand(static_cast<unsigned int>(time(NULL)));
dir = static_cast<Direction>((rand()%3)+1);
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)