@@ -145,10 +145,11 @@ pair<float, float> coordToScreen(const Coordinate& coord) {
145145 using std::sin;
146146 using std::cos;
147147 // TODO not magic numbers
148- static const float scale = 0 .1f ;
148+ static const float xscale = 9 .f / 16 .f / 7 .f ;
149+ static const float yscale = 0 .1f ;
149150 static const float angle = M_PI / 3 .f ;
150- float x = .25f + (scale * coord.first ) + ((scale * coord.second ) * cos (angle));
151- float y = .1f + (scale * coord.second ) * sin (angle);
151+ float x = .25f + (xscale * coord.first ) + ((yscale * coord.second ) * cos (angle));
152+ float y = .1f + (yscale * coord.second ) * sin (angle);
152153 return std::make_pair (x, y);
153154}
154155
@@ -158,12 +159,13 @@ pair<float, float> coordToScreen(const Coordinate& coord) {
158159 * @return The game coordinate.
159160 */
160161Coordinate screenToCoord (const pair<float , float >& screen) {
161- static const float scale = 0.1 ;
162+ static const float xscale = 9 .f / 16 .f / 7 .f ;
163+ static const float yscale = 0 .1f ;
162164 static const float angle = M_PI / 3 .f ;
163165 Coordinate ret;
164- float y_approx = (screen.second - 0 .1f ) / std::sin (angle) / scale ;
166+ float y_approx = (screen.second - 0 .1f ) / std::sin (angle) / yscale ;
165167 ret.second = std::round (y_approx);
166- ret.first = std::round ((screen.first - 0 .2f ) / scale - y_approx * std::cos (angle) - 0.5 );
168+ ret.first = std::round ((screen.first - 0 .25f - y_approx * yscale * std::cos (angle)) / xscale );
167169 return ret;
168170}
169171
0 commit comments