Resize

edited May 2016 in How To...

How would you make EVERYTHING resize when you make a window bigger/smaller? Like all PIMAGE's/TEXT/RECT's?!?!?!??!? And backgrounds

Tagged:

Answers

  • Answer ✓

    Make everything relative to width and height.

  • If you want a rect in the centre of the window with half the size of the window no matter how much you resize it:

    rectMode(CENTER);
    rect(width/2,height/2,width/2,height/2);
    
  • What about like in minecraft if you make it smaller it just deletes part of it and you have to make it bigger to see that one part that was gone when you made it smaller. Example: | THIS IS WINDOW| RESIZE! | THIS IS WI| How would I do that?

  • Answer ✓

    If you draw a rect with coordinates larger than the size of the window the rect will appear outside that window and therefore not be visable.

    Try to run this code:

    size(200,200);
    rect(100,100,200,200);
    

    Can you see that the rect continues out of the window? Now try to change the size to (400,400). Now you can see the whole rect. But in Minecraft, the little cross in the middle will always be in the middle. It moves relative to the window. And so does everything else in the game (if I remember correctly). Let's try again:

    size(200,200);
    rectMode(CENTER);
    rect(width/2,width/2,200,200);
    

    now, when we change the size in order to see the whole rect, it appears relative to the size of the window, but the size of the size of the rect stays the same.

    But not everything in Minecraft reacts to the changes the same way. The hand and the hot bar changes its size relative to the window size. So Minecraft uses a both of these techniques to make the game playable no matter the size.

Sign In or Register to comment.