0

I'm trying to work out a "Reticulate Splines" button for my gaming website.

The function of which is to resize the embed of a game to optimally fill the window I'm playing the game in.

So far I've got a few examples that work just right:

Sushi Cat and Squirrelfall both seem to work properly.

Unfortunately, when working on TimEmu

the game is sizing up too wide to fit into the window.

The function that does this is jQuery with a bit of PHP:

function game_resize(orig) {
    dH = <?= $r['height'] ?>; 
    dW = <?= $r['width']  ?>;
    maxH = $(window).height();
    maxW = $(window).width();

    nR = (maxH - 80) / dH;

    if (orig) {
        $('#gamebed').width(dW);
        $('#gamebed').height(dH);
    } else {
        $('#gamebed').width(dW * nR );
        $('#gamebed').height(dH * nR);
    }
}

I just can't wrap my head around the right checks to ensure the div game space fills the screen without going over. I've got to do something about aspect ratio.

Maybe I've got to walk away from the keyboard for a bit and come back to it (sometimes this stuff just comes to you in a flash after a break).

Can anyone just "see" the answer to this one? I'm sure it's obvious.

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
Alex C
  • 16,624
  • 18
  • 66
  • 98
  • 1
    I answered a similar question for image resizing here: http://stackoverflow.com/questions/3332237/image-resizing-algorithm/3332259#3332259 – GWW Nov 06 '10 at 14:47

1 Answers1

0

If you're able to accept a flash based solution, you could set the stage's scaleMode to SHOW_ALL

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Stage.html#scaleMode

and size the embedder to the full area. Flash will then automatically add the borders that you're looking for. This would of course require you to be able to adjust the embedded swf.

zzzzBov
  • 174,988
  • 54
  • 320
  • 367