Ellie Jane

Veteran
Veteran
Joined
Mar 17, 2012
Messages
762
Reaction score
1,511
First Language
English (UK)
Primarily Uses
RMMV
Fit to Browser Window
v1.00

Description

Designed for browser deployed games, this automatically fits the game screen to the width and height of the client's browser window.

Instructions

Plug and play, though it is up to you to create appropriately sized maps and graphics, and to understand how and why this script should or should not be used.

The creator can specify a maximum size and minimum size for their game; the game will not go beyond these boundaries. Leave blank or 0 and the game will just fill the available space.

When testing this plugin please note that the size of the game's title screen and first map are for a small screen, so you won't initially notice that the plugin is working! As I said it is up to you to tailor your game to the plugin.

Credits

Credit to YanFly for a few lines from the resolution changing script. I have just plugged my own variables into these lines.

Notes

I am not used to releasing my plugins publicly so I apologise if I have broken any unwritten rules in my plugin; I've tried to keep to the standards set in the plugins I've seen.

I want to do a new version eventually which will resize the game when the client resizes their browser window, but I am not sure if this is possible. Currently the player will have to reload the game if they change their window size.

The plugin has no benefit whatsoever to a standalone release.

Plugin

Code:
//=============================================================================
// FitToBrowser.js
//=============================================================================
 /*:
 * @plugindesc Fit to Browser v1.00
 * @author Afar Build 2 / Credit to YanFly for a couple of lines from ScreenResolution.js
 *
 * @param Minimum Width
 * @desc Makes the game not go below this size. 0 = doesn't matter.
 * Default: 640
 * @default 640
 *
 * @param Minimum Height
 * @desc Makes the game not go below this size.  0 = doesn't matter.                      
 * Default: 480
 * @default 480
 *
 * @param Maximum Width
 * @desc Makes the game not go above this size. 0 = doesn't matter.
 * Default: 1024
 * @default 1024
 *
 * @param Maximum Height
 * @desc Makes the game not go above this size. 0 = doesn't matter.                      
 * Default: 768
 * @default 768
 */

var AmyPond = AmyPond || {};
AmyPond.resolution = AmyPond.resolution || {};

AmyPond.parameters = PluginManager.parameters('FitToBrowser');
AmyPond.minWidth = Number(AmyPond.parameters['Minimum Width'] || 0);
AmyPond.minHeight = Number(AmyPond.parameters['Minimum Height'] || 0);
AmyPond.maxWidth = Number(AmyPond.parameters['Maximum Width'] || 0);
AmyPond.maxHeight = Number(AmyPond.parameters['Maximum Height'] || 0);

AmyPond.resize = function() {

    AmyPond.w = window.innerWidth
    || document.documentElement.clientWidth
    || document.body.clientWidth;

    AmyPond.h = window.innerHeight
    || document.documentElement.clientHeight
    || document.body.clientHeight;

    if (AmyPond.minWidth != 0) {
        if (AmyPond.w < AmyPond.minWidth) {
            AmyPond.w = AmyPond.minWidth;
        }
    }
    if (AmyPond.maxWidth != 0) {
        if (AmyPond.w > AmyPond.maxWidth) {
            AmyPond.w = AmyPond.maxWidth;
        }
    }
    if (AmyPond.minHeight != 0) {
        if (AmyPond.h < AmyPond.minHeight) {
            AmyPond.h = AmyPond.minHeight;
        }
    }
    if (AmyPond.maxHeight != 0) {
        if (AmyPond.h > AmyPond.maxHeight) {
            AmyPond.h = AmyPond.maxHeight;
        }
    }

    SceneManager._screenWidth = AmyPond.w;
    SceneManager._screenHeight = AmyPond.h;
    SceneManager._boxWidth = AmyPond.w;
    SceneManager._boxHeight = AmyPond.h;

   window.resizeBy(AmyPond.w, AmyPond.h);
};

AmyPond.resize();

//=============================================================================
// End of File
//=============================================================================
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Anyone here is familiar with the US Law ? I'm working on a game idea at the moment and I have several questions on my mind :p
I just lost an hour plus of time to trying to modify the _battlefield sprite... when in reality MZ calls it _battleField ;_;

Even when debugging for the "undefined value", it looked exactly the same to my 20/60 eyesight.

I really prefer this_naming_convention rather than thisNamingConvention !!
hmm... I just solved one of the more annoying sideview battler problems in MV.. Passive States and Visual States can make it so when your character is in crisis HP, they don't go back to normal walk/wait when it's their turn. they stay in the crisis motion... neat.
Apparently all of LGBT reddit hates me. I posted a simple question and only got hate mail. What's the deal? The doompost was literally 6 months ago and I've changed my views since then and apologized.
MOD NOTE: See second response before replying to this. - Wavelength
Amazing. Simply amazing...

Forum statistics

Threads
109,108
Messages
1,042,139
Members
141,595
Latest member
iomost
Top