Fit to Browser Window

Ellie Jane

Veteran
Veteran
Joined
Mar 17, 2012
Messages
757
Reaction score
1,470
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:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

My first game is going to have the main character more or less create monsters as his party members.

Thanks to the plugin creators still producing content for MV, I might be able to give each of the monster members a personalized range of tactics during combat. I liked how the devs made it like that in FF6.
Stream will be live shortly! Tonight will be the PREMIERE of Killer 7 for the first half of the stream, and at half-stream, we will switch to a session of the Interactive Text Adventure! Feel free to drop by!
Watching the launch, I felt a sort of detached excitement. Usually I'd think something like this would be extremely exciting. I'm fascinated by space exploration and am a big Sci-Fi fan. I guess it's just current events.
What did everyone else think about it?
Doing ep 1 of my RPG!
For those still craving more Konosuba madness
I'm new here, any tips welcome

Hope you fun! :LZSgrin: :LZSkiss:
I set my goal to be finished with Knight Bewitched 2 by sometime in July. Based on my current work schedule and progress, I'm not sure that's going to happen, but by golly I'm gonna try!

Forum statistics

Threads
97,968
Messages
948,189
Members
129,217
Latest member
41728280
Top