0

The problem is. I run my game at:

//Width, Height
public static int HEIGHT = 1080;
public static int WIDTH =  HEIGHT * 14 / 10;

Width: 1512 , Height: 1080 (14:10)

screen = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);

Then I create a Buffered Image for INT_RBG. The size of the buffered image is put in as (WIDTH, HEIGHT) So the Buffered Image is the size of the screen.

 Graphics2D gr = (Graphics2D) bs.getDrawGraphics();

 Graphics2D Gscreen = screen.createGraphics();

I draw all my objects to my screen (Buffered Image) (GScreen) then I use gr to draw that image. And show my buffer

gr.drawImage(screen, 0, 0, WIDTH, HEIGHT, null);
gr.dispose();
bs.show();           
frame.pack();

At the default resoultion (1512, 1080) it works fine. The missiles shoot and it resizes and works perfectly. Now we use my re-size method to put it down to 366, 240 which is still in the 14:10 ratio.

public void setSize(int SIZE) {
       HEIGHT = SIZE;
       WIDTH =  HEIGHT * 14 / 10;
       frame.setSize(WIDTH, HEIGHT);
}

It re-sizes perfectly and looks good. But when I shoot my missile. It ends around a quarter of the way across the screen.

At a low res (366, 240 shooting)

Now the way I set it is if a missile's X travels over Game.WIDTH then Visible = false and to remove the bullet from the array.

 **Bullet.class**
     if (x > Game.WIDTH) {
         visible = false;
     } 
 **Game.class**
 for (int w = 0; w < bullets.size(); w++)
     {

           Bullet m = (Bullet) bullets.get(w);

           if (m.getVisible() == true) {     
                   m.move();
           } else {
              bullets.remove(w);
           }
     }

I'm quite stuck. Ask any questions or if you need any-code I can help. In-case you forgot.forgot. I'm tring to make the bullets go to the end of the screen then fire the remove method at a resolution change at the correct time.

I don't know if its logic's or graphics fault aswell.

Extra Code Snippets

Game.class, Render This renders the bullets:

     for (int i = 0; i < bullets.size(); i++) {
         Bullet m = (Bullet) bullets.get(i);
         Gscreen.drawImage(im.stoneTile, m.x, m.y, 40 , 40, null);
     }

Thanks for your time.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • How about making (x > Game.WIDTH - the width of the bullet? – Rika Jan 28 '15 at 20:21
  • The width of the bullet is 40. And as you down-size it of-course it will be smaller. But the number 40 would still be used. For example something is 20 pixels wide. Gets down-sized to about 7. The number it renders at is still 20 it just gets down-sized. And anyway doing WIDTH_OF_BULLET > Game.WIDTH is useless. And X > Width of bullet. Is useless too. Double read the question, –  Jan 28 '15 at 20:27
  • Not enough information/code here to see how you scale your graphics, move them, how you position your elements. I'm sure if your bullets.remove(w) line is being hit you could debug this yourself and see the root cause. Have you tried to use the debugger? – NESPowerGlove Jan 28 '15 at 20:30
  • There should be enough. Also I used debugger nothing. It all runs fine it says. Ill send all code later. –  Jan 28 '15 at 20:48
  • 2
    @ElliotBewey *"There should be enough"* - You have to remember, we don't have the same context of the overall problem/application that you do. Consider providing a [runnable example](https://stackoverflow.com/help/mcve) which demonstrates your problem. This will result in less confusion and better responses as it will allows us to witness the issue first hand and run our own debugging process over the code – MadProgrammer Jan 28 '15 at 21:22
  • One way to get images for that example mentioned by @MadProgrammer, is to hot link to images seen in [this Q&A](http://stackoverflow.com/q/19209650/418556). Voting to close this question with uncompilable code snippets. – Andrew Thompson Jan 29 '15 at 08:03
  • Do you remember to recale your screen and offscreen bufferedimages? GScreen etc? Or are they still 1512px wide? – Terje Jan 29 '15 at 14:52

1 Answers1

0

You can't resize HEIGHT and WIDTH. Unless the frame goes with it correctly. Do not ever ever do this:

WIDTH = 500;

As a resize from the native res. Always do this:

WIDTH = frame.getWidth();
HEIGHT = frame.getHeight();