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?
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:
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.
Answers
Make everything relative to
width
andheight
.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:
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?
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:
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:
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.