-3

Ok I've found a lot on how to get the resolution of the current monitor, but I want to change it. So that way every time my game is ran, it is always ran in the same resolution. How can I go about doing this ?

* Ok so I've moved on from trying to force a certain resolution, and gone more towards drawing things based on width and height variables.

But that isn't working out so well,

for instance, I'm trying to get this item icon to display in the inventory.

g.drawImage(broadsword, width - (width / 8 -2), height / 2 - 9, null);

now when I run the game in my native res of 1920x1080 it fits in the slot perfectly. But if I change to sat 1280x720, it is drawn too far to the right.


Figured it out, instead of having it display the entire user interface based on the resolution of the user, I have it create a baseline x and y variable based on the 0, 0 location of where it starts to draw the inventory.

g.drawImage(inventory, width - 499, height / 2 - 20, null);
int ixt = width - 499;
int iyt = height / 2 - 20;
g.drawImage(broadsword, ixt + 10, iyt + 10, null);

Seems to scale perfect for any resolution.

thermite
  • 85
  • 2
  • 10
  • You have one of those old CRT monitors that can actually change resolution? Most people in the developed world don't have such a display these days, I think... – Robin Green Nov 10 '13 at 22:24
  • Wow! Remind me never to buy your software! No way do I want my entire desktop changing to a different resolution, just because the makers of one application think it's a good idea. – Dawood ibn Kareem Nov 10 '13 at 22:30
  • the point is I am trying to find a workaround so I don't have to rewrite display code to handle every possible user's resolution. – thermite Nov 10 '13 at 22:43
  • OK, but what happens if the user resizes the window? You'll have to either display your game at a different size, or show only part of your display. Since you'll have to do this anyway, how is coping with different screen resolutions any different? – Dawood ibn Kareem Nov 10 '13 at 23:22
  • There are other Stack Overflow users who may benefit from your question. For their sakes, can you PLEASE put your question back how it was, and ask your new question in an actual new question? – Dawood ibn Kareem Nov 11 '13 at 01:41

1 Answers1

0

Well it seems this question was already answered here: Change screen resolution in Java

But like the others said, I wouldn't advise you to do that, why don't try to get the display dimensions and draw accordingly, i.e. don't draw at [x = 100, y = 100] but at getWidth()/100 (or something like that).

Community
  • 1
  • 1
  • yea that's what I'm toying with at the moment, I have stuff like draw at x, y is draw at width - (width / 30) – thermite Nov 11 '13 at 00:22