richelbilderbeek / djog_unos_2018

Project by the Uno's at DJOG 2018-2019: Nature Zen
GNU General Public License v3.0
6 stars 2 forks source link

Actually use the SFML view #498

Closed richelbilderbeek closed 5 years ago

richelbilderbeek commented 5 years ago

Is your feature request related to a problem? Please describe.

Currently, we use an SFML view (#496). Using such a view allows us to move the camera in any direction, zoom in/out and rotate.

However, there are a lot of magic numbers in the code that code for the transformation that should be done by the view:

void game::spawn(agent_type type, tile t)
{
  // ...
  move_agent_to_tile(a1, t.get_x()/122, t.get_y()/122);
  // ...
}

Describe the solution you'd like

Replace the magic numbers by usage of the view.

I do not know the exact syntax, but the 122 should be something like the view's zoom factor instead.

Describe alternatives you've considered

None.

Additional context

None.

DynCoder commented 5 years ago

I believe this is also done already

Op zo 17 mrt. 2019 13:14 schreef Richel Bilderbeek <notifications@github.com

:

Is your feature request related to a problem? Please describe.

Currently, we use an SFML view (#496 https://github.com/richelbilderbeek/djog_unos_2018/issues/496). Using such a view allows us to move the camera in any direction, zoom in/out and rotate.

However, there are a lot of magic numbers in the code that code for the transformation that should be done by the view:

void game::spawn(agent_type type, tile t) { // ... move_agent_to_tile(a1, t.get_x()/122, t.get_y()/122); // ... }

Describe the solution you'd like

Replace the magic numbers by usage of the view.

I do not know the exact syntax, but the 122 should be something like the view's zoom factor instead.

Describe alternatives you've considered

None.

Additional context

None.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/richelbilderbeek/djog_unos_2018/issues/498, or mute the thread https://github.com/notifications/unsubscribe-auth/Ab-Tki9WKiRKJxk5E4WTL6jtIMvJK9e8ks5vXjGpgaJpZM4b4WF2 .

richelbilderbeek commented 5 years ago

Cool! In which branch are there no more magic numbers? I see in develop they are still around.

DynCoder commented 5 years ago

Also, the 122 should not change at all ever, the 122 is the translation from the actual sfml view coordinate to tile placement coordinate

DynCoder commented 5 years ago

everything is placed in sfml with m_window.mapPixelToCoords() meaning it is already mapped to the view

DynCoder commented 5 years ago

will reopen if zooming does not work correctly after all

richelbilderbeek commented 5 years ago

Fantastic! Go team :1st_place_medal: