Post news RSS Slaying the Scale Monster

Any game with scales in space typically limits the field of view of the player as well as scales down the size of large objects like planets so that they don't strain resources. Black of Space does not. Instead, BoS embraces the sheer scale and has a universe totally to scale. Watch your 200km wide starbase and other massive structures realistically scaled against your planet.

Posted by on

Intro
Any game with scales in space typically limits the field of view of the player as well as scales down the size of large objects like planets so that they don't strain resources. Black of Space does not. Instead, BoS embraces the sheer scale and has a universe totally to scale. Watch your 200km wide starbase and other massive structures realistically scaled against your planet.

Lovely, but...
The price is to achieve this scaling in 2D, the image must be resized every time you want to zoom. This means resizing PNG files 5,000x5,000 and doing it fast enough not to destroy gameplay. So,

 public void scale(URL src, int width, int height, String dest) {
        try {
            
            if (needToZoom && zoomFactor != 1) {
                scaledImg = planetImg;
                System.out.println("Reached "+type);
                scaledImg = null;
                BufferedImage bsrc = ImageIO.read(src);
                BufferedImage bdest =
                        new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
                Graphics2D g = bdest.createGraphics();
                AffineTransform at =
                        AffineTransform.getScaleInstance((double) width / bsrc.getWidth(),
                        (double) height / bsrc.getHeight());
                g.drawRenderedImage(bsrc, at);
                needToZoom = false;
                //planetImg = null;
                scaledImg = bdest;
            }
            if (needToZoom && zoomFactor == 1) {
                scaledImg = planetImg;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Handles it nicely. But it isn't very fast when also scaling the hundreds of asteroids and potentially other planets that can be in the same frame once zoomed!

Solving This
The most logical way to solve this problem is to have prescaled images, however this destroys some planned features such as custom zooms. On the other hand, the delay can only be up to 10 seconds when zooming from 1pxl=1km to 1pxl=100000km, so the delay may not be bad enough to be concerned with.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.