GetScreenWidth

From ZDoom Wiki

Jump to: navigation, search

int GetScreenWidth (void)

Usage

Returns the horizontal resolution. For example, if you are playing in 800x600 it will return 800. This is mainly useful for formatting hudmessages which you want to put in the same position on all screens when using SetHudSize.

Return value

The horizontal resolution of the screen.

Examples

This script places an @ symbol at the left hand side of the screen, 100 pixels from the bottom.

script 1 (void)
{
    int h = GetScreenHeight();
    SetHudSize(GetScreenWidth(), h, 1);
 
    h = (h - 100) << 16;

    HudMessage(s:"@"; HUDMSG_PLAIN, 1,
        CR_BLUE, 0.1, h + 0.1, 10.0);
}

The application of this is that upon building a custom graphic for a HUD, you may want to position info/health/meters/etc. around the edge of the screen according to some positioning system, without necessarily resizing them. See also the command SetFont.

Personal tools