tresinformal / drakkar

The tresinformal video game called 'Drakkar'
GNU General Public License v3.0
11 stars 4 forks source link

Draw player at its actual coordinats #92

Closed richelbilderbeek closed 4 years ago

richelbilderbeek commented 4 years ago

Currently, the player is not drawn at his/her coordinats, but 300 pixels to the right and 400 pixels below that point. One can verify that from this game_view::show code snippet:

    //Create the player sprite
    // ...
    rect.setPosition(
                300.0f + static_cast<float>(m_game.get_player().get_x()),
                400.0f + static_cast<float>(m_game.get_player().get_y())
                );

It would be better to draw a player at its real coordinats:

    //Create the player sprite
    rect.setPosition(
                static_cast<float>(m_game.get_player().get_x()),
                static_cast<float>(m_game.get_player().get_y())
    );

Initial the player in such a way it will show up in the middle of the screen without breaking existing tests. I will be cryptic here: what is the best place to set the coordinat of a player?

In case you need a hint, this is the ROT13 encrypted hint:

frg gur pbbeqvangf bs gur cynlre ng gur tnzr pbafgehpgbe
richelbilderbeek commented 4 years ago

I see in the code:

        rect.setPosition(
                    static_cast<float>(m_game.get_player(i).get_x()),
                    static_cast<float>(m_game.get_player(i).get_y())
                    );

Well done @AparajithaRamesh and @swom :+1: