-1
\$\begingroup\$

I am using Slick2D, and I wanted to know which is the best way to resize, maximize, minimize the window, For example, Resizing all the images or scaling them, or Slick2D has an integrated method, Any help is appreciated.

\$\endgroup\$
  • \$\begingroup\$ What have you tried? Have you tried, for example, reading the documentation? \$\endgroup\$ – Josh Apr 10 '14 at 22:04
  • \$\begingroup\$ @JoshPetrie While you pointed to something that is relevant to the question, I feel you are being a bit harsh... this question is a bit specific to 'common'/'best' practice for this specific library, for window resizing, whether it be for initialization of the window (what you pointed to) or active resizing, which I answered here: stackoverflow.com/questions/22153057/… \$\endgroup\$ – Samich Apr 10 '14 at 22:17
  • \$\begingroup\$ @Samich I tried this but the image its not being resized, I have to make a code to loop for all the images and scale them relative to the Display size? \$\endgroup\$ – Zaphyk Apr 10 '14 at 23:35
  • \$\begingroup\$ Sorry, I didnt saw but I have an Error. Failed to find value mode: 1366x706 fs=true \$\endgroup\$ – Zaphyk Apr 10 '14 at 23:46
  • \$\begingroup\$ Forgot to include the graphics scaling. I've put up an answer, hopefully that will guide you in the right direction :) And the Display resizing code I mentioned in the question I posted above, you would put that code in your update method, and the Display.setResizable(true) in your main method. \$\endgroup\$ – Samich Apr 11 '14 at 0:40
0
\$\begingroup\$

If you want to resize your images, scaled to the window size, you will need to scale your Graphics object in your render method.

To do this properly, you will need to make your game with a predetermined resolution (kind of like, the starting resolution of your game, that all users would start with.) Lets say you are writing a game with the window size 640x480.

This would make your base resolution width 640, and your base resolution height 480.

In the top line of your render method, you would type:

graphics.scale(Display.getWidth()/baseWidth, Display.getHeight()/baseHeight);

and then you would just draw your images as you would normally.

\$\endgroup\$
  • \$\begingroup\$ Its not working :S. Images are not scaling, when I press the maximize button. Also when I pressing it the Program goes back to the first State.And then when i try to minimize it after maximazi it the program losts it original display size. any ideas? \$\endgroup\$ – Zaphyk Apr 11 '14 at 3:05
  • \$\begingroup\$ I think your problem might be the way you've setup your game.. Because I use this code personally and I don't have any issues like that :s not knowing what your project looks like doesn't really help me. \$\endgroup\$ – Samich Apr 12 '14 at 22:58
  • \$\begingroup\$ It may be, Could you add your AppGameContainer options, I mean if you use Vsync for example or other things. \$\endgroup\$ – Zaphyk Apr 13 '14 at 21:51
  • \$\begingroup\$ The images are scaling but not completely, it could be my screen? Also its looses its original size. \$\endgroup\$ – Zaphyk Apr 15 '14 at 23:09
  • \$\begingroup\$ What do you mean it loses original display size..? You're going to have to keep track of the original width and height yourself... \$\endgroup\$ – Samich Apr 15 '14 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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