Publicerad i 5SD033

Concealing the Respawn Time…

Newspaper spin and headlines sprite sheet.png
The spinning newspaper animation spritesheet.

As I mentioned in last week’s blog post, respawning of enemies takes some time to perform, roughly a few milliseconds to a a couple of seconds depending on how many enemies being spawned. This meant that the game would freeze while the RespawnEnemies function would run; not a very elegant or immersive procedure.

 

After discussing this problem with my group, we remembered a cut feature planned during early development: A spinning newspaper that was supposed to appear between levels and add flavour to the setting by describing the ongoing events of the game, with humour.

There were already art assets for its animation and a few different variant headers for the final frame. Although they were without a picture, this was easy enough for the art department to finalize, even making a little fanfare sound to play while  the animation would run.

So, now that the feature was planned for and its assets complete, I would still need to implement it in the code. As the function for respawning enemies takes some time to complete, it would need to run during the last frame of the animation as to not halt it.

When the player returns to the starting area of the map, the game pauses and a bool related to the newspaper animation and enemy spawning is set to true. This allows the game to continue looping through the Update function to reach the Draw function necessary for animation, while disabling player and enemy movement. In addition, the fanfare sound starts playing as soon as the bool is true.

An sf::Clock is used to measure the length of the frames, the last frame sticking around for a couple of seconds; otherwise the text on the newspaper might be difficult to read if there are few enemies to spawn. When the timer of the last frame is finished, the bool checking the function is set to false, allowing the updating of the game to proceed as normal.

The newspaper is animated with the Animation function I’ve described in one of my previous blog posts, but as the last frame is reached, the texture containing the spinning newspaper spritesheet changes to image with the different newspapers. One of the five newspapers are chosen based on an int set to Rand % 4 + 1, giving a random number between 1 and 5.

newspapers.png
The different variations of newspapers that might pop up: Nothing like a little humour to cover up the limits of your programming…

Författare:

Student på Speldesign och programmering, Uppsala universitet, campus Gotland.

3 reaktioner till “Concealing the Respawn Time…

  1. Hello Erik! So this is the last week commenting on blogs and I had the pleasure of commenting on yours. I get a good picture of the problem when you are describing it and I understand your solution to the problem which is good! You mention several times that you wrote about it in an earlier post, what you could do is make a link to it so its easier for me to find.

    So as far as I can tell you describe what problem you faced, why it was a problem and how you fixed it. I also really like having the newspaper as sort of a cutscene. Instead of having sf::Clock would it not be better to have a ”Continue” or ”Next Page” button that appears when the enemies have loaded at the bottom of the newspaper so that the player can read the entire thing or go to the bathroom and then continue when he or she is ready?
    So overall I find that this post was were interesting to read and that I can relate to your post and I understand what you did to manage your problems. And don’t think of it as a something that covers up your programming skills, but think of it instead as a good thing, that you can come up with solutions to problems which are beyond your skills!

    Good Luck with the next project!

    Gilla

  2. Hi Erik

    It was interesting reading about what you have done this past week and what obstacles you hit during the process of finishing up the game. The idea of creating a sort of cut scene between the enemy waves to give a sort of story telling perspective of the game. This gives the player a better understanding of the game and delivers a more authentic feel of what the game is about. But from a more tecnical perspective i would have wanted more information from you explaining why the enemies takes so long to load in.

    I noticed that several groups has had problems with thier games when it comes to loadin in objects. Our group never had this problom despite many enemies coming into the screen at the same time. Our way of doing it was to add and delete object as the come into or leave the screen. When you talk about the waves of enemys that you spawn in does that mean that all of the enemis plays a role at the same time and therefor need to be loaded into the game at the same time. Or could you maybe have made some sort of checking functions if the specific enemy is needed and depending on that result instatiated the object or not.

    Gilla

  3. Hej!
    När jag läser ditt inlägg blir jag lite förvirrad. Jag förstod inte om det fanns ett samband mellan cut scenen och fiende spawnsen. Det var en något oklar beskrivning om varför de hörde ihop.

    I övrigt en bra skriven text. Det skulle dock behövas en lite klarare beskrivning av hur du gick tillväga när du gjorde funktionen. Det känns som om du beskriver allt i en mening vilket gjorde det lite förvirrande för mig som läsare. Jag kände att jag inte riktigt förstod egentligen vad du gjorde och vad du löste den veckan.

    Sen undrar jag lite över om du löste ditt problem med fiende spawnsen. Du tog upp ämnet men beskrev ingenting om det i övriga texten.

    En lösning jag tänkte på var att du skulle kunna lägga in tidningarna som en state istället så när trigger pointen för att tidningarnas animation skulle spelas upp så byter den till en ”tidning state” istället. Det kanske i och för sig inte är smidigaste lösningen såklart. Kul att du löste det hur som helst!

    Du har lämnat mig med många frågetecken, men som sagt en välskriven text med några oklara bitar i texten.

    Jag hoppas det gör bra för dig i theme park kursen!
    Lycka till och glad påsk!

    Gilla

Lämna en kommentar