dthrasher90 Posted April 19, 2017 Share Posted April 19, 2017 Is there a way to make a converter to say like, if your person moves 5 pixels, that would digitally represent 1 yard? Link to comment Share on other sites More sharing options...
MikeW Posted April 19, 2017 Share Posted April 19, 2017 Yeah function pixelsToYards(pixels) { return pixels/5; } Is your problem more complex then that. Link to comment Share on other sites More sharing options...
dthrasher90 Posted April 19, 2017 Author Share Posted April 19, 2017 Quote Thanks! Not more complex at all. I was thinking the solution would be more complex than this. Link to comment Share on other sites More sharing options...
b10b Posted April 19, 2017 Share Posted April 19, 2017 Use a globally accessible function to multiply by a constant coefficient - thereby converting between pixels and yards etc. But if wanting to convert back from yards to pixels in a reliable way be mindful that, in programming, not all floating point coefficients are accurately reversible. Another approach is to keep your game units independent of pixels, and only convert them to pixels when it's time to draw something involving pixels. Link to comment Share on other sites More sharing options...
dthrasher90 Posted April 19, 2017 Author Share Posted April 19, 2017 Yeah, its just so I can log game state, I physically do not want to change the canvas, just want the player to feel like yards are being measured on it. Link to comment Share on other sites More sharing options...
Recommended Posts