Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Skaldi

Pages: [1]
1
General / Movement and sizes on different resolutions
« on: October 31, 2021, 10:18:11 am »
Hello all,

I have started using SFML 3 days ago, and I am making my first project with it, which will be an Arkanoid Clone for Android.
So far it is very intuitive and easy to learn, and I am making good progress.

Now there comes 1 problem. As the whole game is happening in one small and confined area, there will be no scrolling necessary. And the problem is that the mobile phones will have different resolutions, but the game should always be displayed the same way. And the problem which I am seeing coming is following:

My mobile phone has a resolution of 1080x1920 in portrait mode. Now I am setting all the coordinates and the sizes of the sprites according to it. But another mobile phone might have a different resolution. This means I will need to adjust all the coordinates accordingly, so that the scene will look the same way as on my mobile phone. And not that all the sprites are drawn out of the screen, or the scene just fills out 3/4 of the screen. Actually this is a simple multiplication and could be done.

But it does not end here. The ball and the paddle and other things, they move in a certain speed. And when there is a different resolution, the speed will be slower or faster, as there are less or more pixels to traverse, which is not acceptable. And also here to multiply the speed so that it is the same in all resolutions feels a bit cumbersome and not right.

So my question is, can I somehow have my coordinate system to be 0.0 is center -1.0 is left and +1.0 is right? The same for up and down? How can I achieve this? Or is there a better solution which I am not aware of?

I hope I could describe my problem in a meaningful way.

Thank you all for your help in advance.

Best regards,
Skaldi

Pages: [1]