Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Hi I am making a football stratedgy game and I have it the game working. I was playing prison architect and minecraft in fullscreen and noticed there was no windows it was covering the whole screen. So I looked up how to do this and I got

 frame.setSize(Toolkit.getDefaultToolkit().getScreenSize()); 
    frame.setUndecorated(true); 

    frame.setVisible(true);

and this works its just that all the images are (I don't know how to put this) the same size as when the game was in 600 * 500 window and I was wondering if there was a way to have them in the right place according to the size of the screen, so for example if the computer screen is 1000 * 1000 pixels the image whould be 100 pixels from the left of the screen but if someone played it on a 500 * 500 pixel screen it would be 50 pixels form the left of the screen. Keep in mind that they way I draw my images are

ImageIcon i2 = new ImageIcon("res/BackGrounds/titlescreen.png");
    img = i2.getImage();
g.drawImage(img, 10, 10, null);

I tried doing it this way:

    ImageIcon i2 = new ImageIcon("res/BackGrounds/titlescreen.png");
    img = i2.getImage();
    g.drawImage(img, 100, 10,Toolkit.getDefaultToolkit().getScreenSize().width / 5 -100,Toolkit.getDefaultToolkit().getScreenSize().height / 5 - 100, null);

but I when I tested it on a different computer whith a different sized screen the images where more squashed together because the screen is smaller and I had set the toolkit to be

Toolkit.getDefaultToolkit().getScreenSize().width / 5 -100

Pleas if u can help me, help me cause I really need help. THX in advance

share|improve this question
    
I think an screenshot or diagram would help understand this problem. –  Byte56 Jun 27 at 19:51
    
How do I add a screen shot –  user2957632 Jun 27 at 20:00
    
Edit the question and use the editing tools to insert an image. The image can come from your computer and doesn't need to be uploaded first. –  Byte56 Jun 27 at 20:01
    
is there a program I should download to take a screenshot or I there a way on windows –  user2957632 Jun 27 at 20:04
    
Google it. I think explaining it in a comment is silly. –  Byte56 Jun 27 at 21:49
add comment

1 Answer 1

The easiest way to achieve this is to draw your game to an image buffer first, instead of directly to the window. Then you draw that image scaled up according to the resolution of your window. This way you don't have to worry about scaling and positioning the indiviual elements of your display.

However, it might be advisable to only scale to the nearest integer multiple of your buffer size in order to avoid interpolation artifacts.

Look into java.awt.Canvas and buffer strategies for hardware-accelerated off-screen buffers.

Besides that, you might be interested in fullscreen exlusive mode as an alternative to windows without decoration: http://docs.oracle.com/javase/tutorial/extra/fullscreen/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.