Views

From ENIGMA
Jump to navigation Jump to search

In ENIGMA, a view is a region on the screen assigned to display a region in your game world. By default, a room contains one view which displays the entire content of the room on a window of equal size. That is, if your room is 640x480, a 640x480 window will be created to display the contents of your room. This still applies even if your room is larger than the size of the display. In these cases, you probably want to assign views.

Using the Room editor, you can assign up to eight views. Conceptually, a view is given as a viewport, a viewing region, a view angle, and a view object with a view border and view speed.

View concepts

Viewport

A viewport is a region in the window, or on the screen. Its dimensions correspond to actual user units, as displayed on the user's monitor. Thus, the largest useful viewport size is the user's resolution. A very common default viewport size is 640x480. A less common, more modern default viewport size is 800x600. These are typically positioned at (0, 0), except where other views occupy the top-left region of the window. Viewports used for status boxes or menus are usually smaller, and positioned elsewhere on the screen. In many games, these values remain hard-coded. In other games, they are computed using methods such as display_get_width/display_get_height.

If your game window is positioned on your screen at (100, 100), and your window border is 4px thick with a 24px title bar (this is controlled by the window manager and is not accessible to ENIGMA), the upper-left corner of your actual game viewport will be at (104, 124), and this will be the real coordinate of a viewport positioned at (0, 0). You can use window functions such as window_get_x/window_get_y to fetch the (100, 100). Presently, no functions exist to accurately fetch the border and title bar size. (It may be possible to fetch the (104,124) on Windows using the GL/DX display HWND separately.)

View Region

This is the area in the game that a view represents. It can have any real size, and any real position. Most commonly, the position coordinates range from zero to room_width and room_height for x and y, respectively, and the width and height are usually identical to the viewport width and height. This prevents unsightly stretching or scaling. In games where those are desirable, the view region width and height are usually related to the viewport width and height by some inverse power-of-two, eg, a half or a quarter. This causes pixelation reminiscent of retro games.

When there is disparity between the viewport dimensions and the view region dimensions, the view region dimensions define the in-game coordinates.

View Angle

For any occasion wherein pivoting the angle of the current view about an unspecified point is useful, ENIGMA also offers the GM:S view_angle.

View Object

For your convenience, ENIGMA provides functionality to automatically move views to follow an object. If you assign an object to a view, the viewing region will automatically move around the room to keep the first instance of that object in sight.

View Border

If you have assigned a view object, the view border is a margin of viewing space guaranteed to be found around the player. A view border of (0,0) will likely be regarded as annoying, as the player will not be able to see what is ahead while moving. Typically a value slightly less than half the view region width and height are used for the border width and height. For example, if you view is sized 640x480, a good border size might be 300, 220.

This border is not related to the window border and does not correspond to real screen coordinates. It uses in-game coordinates.

View Speed

If you have assigned a view object, the view speed is the maximum speed at which the view object is followed.

View Variables

While you may occasionally want to use functions such as room_set_view to assign to a room, you more likely will want to set view parameters immediately. Changing the views in each room this way can be done up front, but will only take effect once the room is reloaded, as no relationship is guaranteed between the default room view assignment and the (mutable) room variables during gameplay.

You can edit view properties live using the following variables:

Live View Variables
Variable Name Description
Viewport variables

view_xport

The x-coordinate, in screen space, of the port of this view in the window. This, and other variables in this category, will almost certainly be integers.

view_yport

The y-coordinate, in screen space, of the port of this view in the window.

view_wport

The width, in screen space, of the port of this view in the window.

view_hport

The height, in screen space, of the port of this view in the window.
View region variables

view_xview

The x-coordinate, in game space, of the port of this view in the window. This, and other variables in this category, may be integers or floating point numbers, depending on the in-game coordinate system.

view_yview

The y-coordinate, in game space, of the port of this view in the window.

view_wview

The width, in game space, of the port of this view in the window.

view_hview

The height, in game space, of the port of this view in the window.

view_angle

The angle at which to tilt this view about an arbitrary axis, probably given by the center of the current view.
View object/border variables

view_object

An identifying ID of the object to follow. Assigning to an instance ID will cause the view to follow that instance so long as it exists. Assigning an object index, such as obj_player, will cause the first instance of that object to be followed, which is ideal if there is only one instance of said object. Assigning the special value noone will cease following objects.

view_hbor

The horizontal border to allow around the object being followed, in game space. This guarantees, to the extent logically possible, that at least view_hbor pixels lie between the object and the left or right of the screen.

view_vbor

The vertical border to allow around the object being followed, in game space. This guarantees, to the extent logically possible, that at least view_vbor pixels lie between the object and the top or bottom of the screen.

view_hspeed

The maximum horizontal speed at which to follow objects, in game space.

view_vspeed

The maximum vertical speed at which to follow objects, in game space.