Space Giraffa – Update 5

Other than recovering from Monday’s beta presentation, this week has been pretty mild. I have chosen some easier tasks to complete for this scrum session. One of them was a High score system that can add entries and sort them with the previous score entries which are loaded from a save file.

First of all, I created a struct called “Entry” that contains an integer and a string data type. The integer stores the users’ score and the string stores the name associated with that score. This makes it easier to keep track of the name while sorting the scores. By including the “algorithm” header I have access to the sort function. Algorithm’s sort function can sort a vector array by comparing any value from two elements using a self defined binary function. Something like this:

struct SortFunction {

          bool operator() (int I, int J) { return (I < J); }

};

The function don’t have to be imbedded in a struct.

The class’ constructor opens a text file and imports every previous score and its name and adds it to a vector array. Later when a user wants to submit their score to the high score table a function will do that for them.

This function first checks whether the user’s name already exists somewhere on the high score table.

If they do, the entry’s score is changed. But is it doesn’t exist, a new entry is created containing the score and the user’s name and placed in the vector array.

When that is done the array is sorted using a special binary function that compares two entry objects by their integer value.

bubbl

The score system class can also retrieve names and scores from a desired place in the array. This feature is only going to be used when drawing the score board.

Our game’s main protagonist “Giraffa” has felt very stiff when flying around in space. We wanted to add something more to the player avatar to make it feel more dynamic. The biggest request has been to make the giraffe’s legs flail as the she moves. This will add to a more comic aesthetic to the player avatar. I am currently working on this visual feature and have written down some pseudo code to help me find a good solution. I’ll either simulate some simple rope physics or just rotate the lags by the amount of horizontal speed but this is one of the things I link with programming.

Now I have to get back to my coding, so have a good one!

Space Giraffa – Update 5

En reaktion på ”Space Giraffa – Update 5

  1. Philip Olsson skriver:

    Hi!

    In a whole the post is very well written with a clear and structured language making it easier to understand. It is very clear on what you have been working on however you start to dip into a different artifact towards the end which is not totally relevant to the main body of text.

    You explain How you did the scoring system in a pretty superficial way however i think you could have gone a bit deeper when you discuss the sorting. It is pretty clear how to use your struct for someone with some experience of programming however a someone with less experienced will have a pretty big value in seeing how you use the struct SortFuntion for sorting.

    Something else that can be expanded upon is why you did as you did. Was it because you have done it before or is it just an efficient way of doing this. You could also write the why from a design perspective explaining that it will increase the players will to play again to beat an opponent or something along those lines. But i have to say that it is a pretty valuable post over all with only a few tings that can be added to make it even more valuable!

    Gilla

Lämna en kommentar