SFML community forums
Help => General => Topic started by: Hooch on February 19, 2014, 11:33:19 pm
-
Hello.
I'm new to game making.
The only game I created before was simple Snake like game in STL. But it was fixed resolutions and I was always drawing ant hard coded (x, y) coordinates.
I know the idea of heving game world units independed of screen resolution units. Like in all 3D games.
I wold like to know how to do do it properly in SFML. When user changes resolutions I have to show him the same amount of screen. (Just like scalling). I don't want to show smaller PART of screen. But the same "amount" of game world but in lower resolution.
Additionally I would like to have scrolling in game. I can't display whole world in one window.
-
http://www.sfml-dev.org/tutorials/2.1/graphics-view.php
-
http://www.sfml-dev.org/tutorials/2.1/graphics-view.php
Thanks. That is exactly what I was looking for.
One side question. When using Box2D with SFML and Views I don't have to "scale" Box2D objects?
Can I just create game world using "meters" and then use Views properties to display it properly to the screen?
-
I find it's easier to think of your Box2D simulation as acting in a different coordinate system. So you might have boxes that are "1 box2d unit" wide, but then in your renderer that might correspond to boxes that are 3 "render units" wide, which is transformed by the sf::View to 40 pixels wide (say) depending on the zoom level.
But yes, you could have one coordinate system where 1 box2d unit corresponds directly to a sf::Rect of width 1, which would then be transformed by the sf::View to the screen coordinate system.
-
I find it's easier to think of your Box2D simulation as acting in a different coordinate system. So you might have boxes that are "1 box2d unit" wide, but then in your renderer that might correspond to boxes that are 3 "render units" wide, which is transformed by the sf::View to 40 pixels wide (say) depending on the zoom level.
But yes, you could have one coordinate system where 1 box2d unit corresponds directly to a sf::Rect of width 1, which would then be transformed by the sf::View to the screen coordinate system.
Thanks for that.
I read to keep Box2D in range of 1 to 10 units for simulation.
I'm thinking of heving global variable (#define maybe) that will define Box2D World scale. And then in all simulations I'll use size/SCALE. I can always use scale of 1.