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.