How do you calculate that a picture is always in the same / similar place in games?

Dr
5

I recently tried out a bit about Minecraft clients (my client is not a hack client but rather a troll / grief client that can exploit the weaknesses of 1.8.X).

Well… I have already inserted several things that are displayed in the same or a similar place on the screen for each resolution.

But that was mostly more of a coincidence, or for a few things I used the things that were already there, and for one I even exchanged something existing with my stuff.

It doesn't always work (e.g. In your own GUIs), would I like to know how to calculate that?

Let's say e.g. I want to put a button in the middle of the screen… How do you know what to calculate? Or are there additional programs for this?

Lo

Int mitteX = screen.width / 2 - button.width / 2
int middleY = screen.height / 2 - or + button.height / 2

that's about how it should go

Dr

In itself, that was just an example, thanks anyway.

But how do you know how to calculate other points?

Lo

I do not understand your question. What do you mean by other points?

Lo

But in general you can say at x = 0 it is on the far left

and at y = 0 at the top (or bottom)

and then you divide the screen width by 2 and you have the middle.

but since the button always starts drawing at the bottom / top left, you have to subtract half of the button height / width

Dr

Of course, makes sense. But what should I do if I want to calculate other points on the screen? Not just half or four corners.

Somewhere else at the screen where you can't just calculate by 2 … How do you know how to calculate that?