Virtual Rooms - coldrockgames/gml-raptor GitHub Wiki

Virtual Room Management System

This system provides functions for creating, managing, and navigating "virtual rooms" within a larger physical room. These virtual rooms act as distinct, moveable areas, allowing for dynamic room organization and camera control. It offers precise control over the camera's viewport, allowing developers to seamlessly transition between these virtual rooms and the game's current "physical room".

Virtual Room #macros

Macro Description
VIRTUAL_ROOM Stores the selected virtual room. (The global variable is undefined if no room is currently active.)
VIRTUAL_ROOM_WIDTH
VIRTUAL_ROOM_HEIGHT
Width and height of the active virtual room.
VIRTUAL_ROOM_TOP_EDGE
VIRTUAL_ROOM_BOTTOM_EDGE
Top and bottom edge of the active virtual room.
VIRTUAL_ROOM_LEFT_EDGE
VIRTUAL_ROOM_RIGHT_EDGE
Left and right edge of the active virtual room.
VIRTUAL_ROOM_CENTER_X
VIRTUAL_ROOM_CENTER_Y
Center of the active virtual room.
VIRTUAL_ROOM_ASPECT_RATIO Aspect ratio of the active virtual room.
(VIRTUAL_ROOM_WIDTH / VIRTUAL_ROOM_HEIGHT)

Virtual Room functions

Access these functions through the ROOMCONTROLLER.

virtual_room_create

/// @function		virtual_room_create(_name, _x, _y, _width, _height, _activate = false)
/// @description	Creates and returns the new virtual room.
/// @param {string} _name               The identifier of the virtual room.
/// @param {real} _x                    The left edge of the virtual room.
/// @param {real} _y                    The top edge of the virtual room.
/// @param {real} _width                The width of the virtual room.
/// @param {real} _height               The height of the virtual room.
/// @param {bool} _activate             Indicates if the virtual room should be activated on creation.
/// @returns {struct} virtual_room      The runtime struct for the virtual room.
virtual_room_create = function(_name, _x, _y, _width, _height, _activate = false) {

virtual_room_update

/// @function		virtual_room_update(_name, _x, _y, _width, _height, _activate = false)
/// @description	Updates an existing virtual room.
/// @param {string} _name               The identifier of the virtual room.
/// @param {real} _x                    The left edge of the virtual room.
/// @param {real} _y                    The top edge of the virtual room.
/// @param {real} _width                The width of the virtual room.
/// @param {real} _height               The height of the virtual room.
/// @param {bool} _activate             Indicates if the virtual room should be activated on creation.
/// @returns {struct} virtual_room      The runtime struct for the virtual room.
virtual_room_update = function(_name, _x, _y, _width, _height, _activate = false) {

virtual_room_delete

/// @function		virtual_room_delete(_name)
/// @description	Delets the given room if it is not currently active.
/// @param {string} _name               The name of the given virtual room.
/// @returns {bool} is_deleted          Indicates if the given virtual room was deleted.
virtual_room_delete = function(_name) {

virtual_room_get

/// @function		virtual_room_get(_name)
/// @description	Returns a virtual room with the given name.
///                     (You may want to modify your virtual room at runtime.)
/// @param {string} _name               The name of the given virtual room.
/// @returns {struct} virtual_room      The runtime struct for the virtual room.
virtual_room_get = function(_name) {

virtual_room_exists

/// @function		virtual_room_exists(_name)
/// @description	Checks if a virtual room with the given name exists.
/// @param {string} _name               The name of the virtual room.
/// @returns {bool} exists              Indicates if the virtual room exists.
virtual_room_exists = function(_name) {

virtual_room_is_active

/// @function		virtual_room_is_active(_name)
/// @description	Checks if a virtual room is currently active.
/// @param {string} _name               The name of the given virtual room.
/// @returns {bool} is_active           Indicates if the given virtual room is active.
virtual_room_is_active = function(_name) {

virtual_room_activate

/// @function		virtual_room_activate(_name)
/// @description	Sets the camera min/max coordinates according to the given virtual room.
///                     (The given virtual room is now active.)
/// @param {string} _name               The name of the given virtual room.
/// @returns {bool} is_selected         Indicates if the given virtual room is now active.
virtual_room_activate = function(_name) {

virtual_room_deactivate

/// @function		virtual_room_deactivate()
/// @description	Sets the camera min/max coordinates according to the physical room.
///                     (No virtual room is now active.)
/// @returns N/A
virtual_room_deactivate = function() {
⚠️ **GitHub.com Fallback** ⚠️