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 Profile Posts

finally redesigned one of the major antagonist of my game, Pro... aka Prometheus.
Well, I've decided I'll take a break on making Forgotten Eclipse...and Make a mod for FNF
Trailer for my new game.
last one for a while

Forum statistics

Threads
110,311
Messages
1,052,247
Members
143,347
Latest member
macaoclub
Top