Contents Up Previous Next

Room / Screen functions

AreThingsOverlapping
DisableGroundLevelAreas
EnableGroundLevelAreas
FadeIn
FadeOut
FlipScreen
GetBackgroundFrame
GetPlayerCharacter
GetRoomProperty
GetRoomPropertyText
GetScalingAt
GetViewportX
GetViewportY
GetWalkableAreaAt
HasPlayerBeenInRoom
RawClearScreen
RawDrawCircle
RawDrawFrameTransparent
RawDrawImage
RawDrawImageResized
RawDrawImageTransparent
RawDrawLine
RawDrawRectangle
RawDrawTriangle
RawPrint
RawPrintMessageWrapped
RawRestoreScreen
RawSaveScreen
RawSetColor
RawSetColorRGB
ReleaseViewport
RemoveWalkableArea
ResetRoom
RestoreWalkableArea
SetAreaScaling
SetBackgroundFrame
SetFadeColor
SetNextScreenTransition
SetScreenTransition
SetViewport
SetWalkBehindBase
ShakeScreen
ShakeScreenBackground
TintScreen


AreThingsOverlapping

AreThingsOverlapping(int thing1, int thing2)
Checks whether two characters or objects are overlapping each other on screen. This simply carries out a quick rectangular check on the two things to decide - so if they have large transparent regions around the edges, it may seem to be overlapping too soon.

THING1 and THING2 can either be a CHARID, or can be an object number PLUS 1000. So for example, passing EGO as THING1, and 1004 as THING2, will compare the character EGO with Object 4 in the current room.

Returns 0 if they are not overlapping, or the overlapping amount if they are. This amount is an arbitrary scale, but 1 means they are just about touching, all the way up to higher numbers for more overlappingness.

Calling this function with both the parameters as objects is the same as calling Object.IsCollidingWithObject.

Example:

if (AreThingsOverlapping(1002, EGO)) {
  // code here
}
will run the code if object 2 is overlapping EGO. This could be useful if object 2 was a bullet, for instance.

See Also: Character.IsCollidingWithChar, Object.IsCollidingWithObject


DisableGroundLevelAreas

DisableGroundLevelAreas(int disableTints)
Disables all ground-level interactions. This means that all Region events, the Player Stands On Hotspot event, and the room edges become disabled.

This command is useful in conjunction with the character[].z variable, if you want the player to be able to temporarily fly or levitate, for example. It allows you to stop the character from triggering Player Stands On interactions while they are in the air.

This command is also useful during some cutscenes, if you don't want the player to trigger events as they walk around the room while in the cutscene.

The DISABLETINTS parameter specifies whether the visual effects of the regions (ie. light levels and tints) are also disabled. If you pass this as 0, then just the interactions will be turned off.

Example:

DisableGroundLevelAreas(0);
will disable all ground-level interactions, but leave light levels working

See Also: Hotspot.Enabled, Region.Enabled, EnableGroundLevelAreas


EnableGroundLevelAreas

EnableGroundLevelAreas()
Re-enables all ground-level interactions. This is used to reverse the effects of using the DisableGroundLevelAreas command, and will return things to normal.

Example:

EnableGroundLevelAreas();
will re-enable all ground-level interactions.

See Also: Hotspot.Enabled, Region.Enabled, DisableGroundLevelAreas


FadeIn

FadeIn (int speed)
Fades in from a black screen to the current palette. This is used to restore the screen after a FadeOut call. SPEED is from 1 (slowest) to 64 (fastest).

NOTE: This is a blocking function.

Example:

FadeOut(30);
Wait(40);
FadeIn(10); 
will fade the screen to black, wait 1 sec (40 game cycles) and then fade in again.

See Also: CyclePalette, FadeOut, SetFadeColor


FadeOut

FadeOut (int speed)
Fades the screen out to black. SPEED is the speed of the fade, from 1 (slowest) to 64 (instant). You can restore the screen with FadeIn.

NOTE: This is a blocking function.

Example:

FadeOut(30);
Wait(40);
FadeIn(10); 
will fade the screen to black, wait 1 sec (40 game cycles) and then fade in again.

See Also: CyclePalette, FadeIn, SetFadeColor


FlipScreen

FlipScreen (int way)
Flips the screen round either the horizontal or vertical axis, or both. This function is for special effects only - all co-ordinates remain the same and it doesn't effect any other script functions.

The value of WAY selects:

0  normal
1  horizontal-flip (upside-down)
2  vertical-flip  (left-to-right)
3  both (upside-down and backwards)
NOTE: This function is still a bit buggy - black parts of the screen may show up wrong, and and pop-up messages will flip the screen back to normal.

Example:

FlipScreen(1); 
will flip the screen upside down.


GetBackgroundFrame

GetBackgroundFrame()
Returns the number of the current background being displayed. In a room without animating backgrounds, this will always return 0. Otherwise, the current frame number is returned from 0 to 4.

Example:

if (GetBackgroundFrame()==4)
  object[2].Visible = true;
will turn on object 2 if the background frame of the room is frame 4.

See Also: SetBackgroundFrame


GetPlayerCharacter

GetPlayerCharacter ()
THIS COMMAND IS NOW OBSOLETE.
The recommended replacement is to use the player character's ID property, as follows:

Example:

Display("The player character number is %d", player.ID);
See Also: Character.ID


GetRoomProperty

GetRoomProperty (string property)
Returns the custom property setting of the PROPERTY for the current room.

This command works with Number properties (it returns the number), and with Boolean properties (returns 1 if the box was checked, 0 if not).

Use the equivalent GetRoomPropertyText function to get a text property.

Note that you cannot retrieve room properties of other rooms - only the current room can be checked.

Example:

if (GetRoomProperty("CanBeAttackedHere"))
  Display("An evil monster lunges at you!");
will print the message if the current room has its "CanBeAttackedHere" box ticked.

See Also: GetRoomPropertyText


GetRoomPropertyText

GetRoomPropertyText (string property, string buffer)
Returns the custom property setting of the PROPERTY for the current room.

This command works with Text properties only. The property's text will be copied into the BUFFER that you pass to this command.

Use the equivalent GetRoomProperty function to get a non-text property.

Note that you cannot retrieve room properties of other rooms - only the current room can be checked.

Example:

string buffer;
GetRoomPropertyText("Description", buffer);
Display("The room's description: %s", buffer);
will retrieve the room's "description" property into the buffer, then display it.

See Also: GetRoomProperty


GetScalingAt

GetScalingAt (int x, int y)
Returns the room area scaling at room co-ordinates (X,Y).

The value returned is from 1 to 200, with 100 being the normal un-scaled setting.

Example:

if (GetScalingAt(player.x, player.y) == 100)
    Display ("The player is currently at normal size.");
See Also: GetWalkableAreaAt, SetAreaScaling


GetViewportX

GetViewportX ()
Returns the X-offset of the current viewport in a scrolling room. This allows you to find out what part of the room the player is looking at. The co-ordinate returned is the left edge of the screen, and so it can have a value between 0 and (ROOM WIDTH - 320).

If the room is a non-scrolling room, returns 0.

See the SetViewport function description for more information.

Example:

if (GetViewportX()>100)
    object[2].Visible = true;
will turn object 2 on if the player has scrolled the room by 100 pixels to the right.

See Also: GetViewportY, SetViewport


GetViewportY

GetViewportY ()
Returns the Y-offset of the current viewport in a scrolling room. This allows you to find out what part of the room the player is looking at. The co-ordinate returned is the top edge of the screen, and so it can have a value between 0 and (ROOM HEIGHT - 200).

If the room is a non-scrolling room, returns 0.

Example:

if (GetViewportY()>20)
    object[2].Visible = true;
will turn object 2 on if the player has scrolled the room by 20 pixels to the bottom.

See Also: GetViewportX, SetViewport


GetWalkableAreaAt

GetWalkableAreaAt (int x, int y)
Returns the number of the walkable area at SCREEN co-ordinates (X,Y). If there is no walkable area there, or if invalid co-ordinates are specified, returns 0.

NOTE: The co-ordinates are SCREEN co-ordinates, NOT ROOM co-ordinates. This means that with a scrolling room, the co-ordinates you pass are relative to the screen's current position, and NOT absolute room co-ordinates. This means that this function is suitable for use with the mouse cursor position variables.

Example:

if (GetWalkableAreaAt(mouse.x,mouse.y) == 0)
    Display ("You can't walk there.");
See Also: Hotspot.GetAtScreenXY, Region.GetAtRoomXY, GetScalingAt


HasPlayerBeenInRoom

HasPlayerBeenInRoom(int room_number)
Checks whether the player has ever been in ROOM_NUMBER (ie. has the 'First Time Player Enters Screen' event there ever been run). Returns 1 if they have, and 0 if they haven't.

You can use this function to determine whether the player has been to a particular location previously. If you reset the room with ResetRoom, then this command will return 0 until they enter the room again.

This command will always return 1 if you ask it about the current room; and it will always return 0 if you ask it about a non-state saving room (ie. rooms numbered > 300).

Example:

if (HasPlayerBeenInRoom(14)) {
  Display("The player has been to room 14 before.");
}
will display a message if the player has been to room 14.

See Also: ResetRoom


RawClearScreen

RawClearScreen (int colour)
The family of "raw" functions allow you direct access to the screen to do whatever you want with it. However, anything you do with these functions is permanent on the screen until the player leaves the room. They are most useful for things like a character stats screen where you want to print information directly to the screen.

This function clears the screen to the specified COLOUR (this is a number you can find in the Game, Palette mode of the editor). Whatever is currently on the background will be wiped.

NOTE: any GUIs you have will still appear on top of the screen, so if you want complete control you'll need to turn the GUIs off too.

NOTE: The Raw functions always draw onto the current background frame only.

Example:

RawClearScreen(31); 
will clear the screen to a blue color.

See Also: RawSetColor


RawDrawCircle

RawDrawCircle (int x, int y, int radius)
Draws a filled circle of radius RADIUS with its centre at (X,Y) in the current raw drawing colour.

Example:

RawDrawCircle(160,100,50); 
will draw a circle in the centre of the screen, of 50 pixels radius.

See Also: RawDrawLine, RawSetColor


RawDrawFrameTransparent

RawDrawFrameTransparent(int frame, int transparency)
Draws room background frame number FRAME onto the current background, at TRANSPARENCY percent transparency.

This allows you to perform day-to-night fading and other special effects.

NOTE: This command only works with hi-colour backgrounds.

NOTE: This command can be a bit on the slow side, so don't call it from repeatedly_execute.

TIP: If you want to gradually fade in the second background, remember to call RawRestoreScreen before using this command, otherwise it will converge too quickly.

Example:

RawDrawFrameTransparent(1, 50);
assuming the current background is the main frame 0, this will draw frame 1 on top of it at 50% opacity.

See Also: SetAmbientTint


RawDrawImage

RawDrawImage (int x, int y, int slot)
Draws image SLOT from the sprite manager onto the room background at location (X,Y).

NOTE: The X and Y co-ordinates given are ROOM co-ordinates, not SCREEN co-ordinates. This means that in a scrolling room you can draw outside the current visible area.

NOTE: This command only works if the image to be drawn is the same colour depth as the background scene.

Example:

RawDrawImage(100,100,134); 
will draw the image that’s stored in sprite manager’s slot 134 at the coordinates 100,100.

See Also: RawDrawImageResized, RawDrawImageTransparent, RawDrawLine, RawPrint


RawDrawImageResized

RawDrawImageResized(int x, int y, int slot, int width, int height)
Draws image SLOT from the sprite manager onto the screen at location (X,Y), but resized to (WIDTH, HEIGHT). This allows you to render a sprite at any size (WIDTH and HEIGHT are in 320x200-res co-ordinates, as usual).

Example:

RawDrawImageResized(100, 100, 134, 50, 50);
will draw sprite 134 at (100, 100) on the screen, at a size of 50x50 pixels.

See Also: RawDrawImage, RawDrawImageTransparent


RawDrawImageTransparent

RawDrawImageTransparent(int x, int y, int slot, int transparency)
Draws image SLOT from the sprite manager onto the screen at location (X,Y), with a translucency of TRANSPARENCY percent.

TRANSPARENCY is from 0-100; passing a TRANSPARENCY of 50 will draw the image semi-transparent; passing 0 is equivalent to just calling the normal RawDrawImage command.

NOTE: This command does not work in 256-colour games, or with 256-colour sprites.

Example:

RawDrawImageTransparent(100, 100, 134, 75);
will draw sprite 134 at (100, 100) on the screen, with 75 percent transparency.

See Also: RawDrawImage, RawDrawImageResized


RawDrawLine

RawDrawLine (int from_x, int from_y, int to_x, int to_y)
Draws a line from (FROM_X, FROM_Y) to (TO_X, TO_Y) in the current raw drawing colour.

NOTE: The X and Y co-ordinates given are ROOM co-ordinates, not SCREEN co-ordinates. This means that in a scrolling room you can draw outside the current visible area.

Example:

RawDrawLine(0,0,160,100); 
will draw a line from the left top of the screen (0,0) to the middle of the screen (160,100);

See Also: RawDrawCircle, RawDrawRectangle, RawDrawTriangle, RawSetColor


RawDrawRectangle

RawDrawRectangle (int x1, int y1, int x2, int y2)
Draws a filled rectangle in the current colour with its top-left corner at (x1,y1) and its bottom right corner at (x2, y2)

NOTE: The X and Y co-ordinates given are ROOM co-ordinates, not SCREEN co-ordinates. This means that in a scrolling room you can draw outside the current visible area.

Example:

RawDrawRectangle(0,0,160,100); 
will draw a rectangle over the top left hand quarter of the screen.

See Also: RawDrawImage, RawDrawLine


RawDrawTriangle

RawDrawTriangle (int x1, int y1, int x2, int y2, int x3, int y3)
Draws a filled triangle in the current colour with corners at the points (x1,y1), (x2,y2) and (x3,y3).

Well, don't look at me, you might find it useful for something :-)

Example:

RawDrawTriangle(0,0,160,100,0,200); 
will draw a triangle with corners at the points (0,0),(160,100),(0,200).

See Also: RawDrawImage, RawDrawLine, RawDrawRectangle


RawPrint

RawPrint (int x, int y, string text, ...)
This function prints the specified TEXT to screen location (X,Y). The text will be printed using the normal font and the current raw colour.

You can insert the value of variables into the message. For more information, see the string formatting section.

Example:

int power;
RawPrint (10,10,"Power:%d",power); 
will display the string Power: and the value of the integer power at 10,10. Useful for making stats screens.

See Also: RawPrintMessageWrapped, RawSetColor, SetNormalFont


RawPrintMessageWrapped

RawPrintMessageWrapped (int x, int y, int width, int font, int message_number)
This function prints the message MESSAGE_NUMBER (which can be a global message or room message) directly to the screen at (X,Y), using the specified FONT.

WIDTH is the width of the virtual textbox enclosing the text, and is the point that the text will wrap at. This function is designed for writing a long message to the screen with it wrapping normally like a standard textbox.

The text will be printed using the current raw colour.

Example:

RawPrintMessageWrapped (80, 40, 160, 1, 10); 
will display room message 10 in the centre of the screen, starting from Y = 40.

See Also: RawPrint, RawSetColor


RawRestoreScreen

RawRestoreScreen ()
Restores the screen from the backup image created with RawSaveScreen. Use this when you want to get back what was there before you started drawing.

Example:

RawSaveScreen();
RawDrawTriangle(0,0,160,100,0,200);
Wait(80);
RawRestoreScreen(); 
will save the screen, draw a triangle, wait for a while, and then restore the original screen.

See Also: RawSaveScreen


RawSaveScreen

RawSaveScreen ()
Makes a backup of the current background screen, in order that it can be restored later. This could be useful to back up the original image before writing over it, or to save a certain state of your drawing to restore later. Only one raw backup image can exist at a time, so this overwrites any previous saves you made.

NOTE: The backup image is lost when the player leaves the screen, or if they load a saved game position. Therefore, this is best only for short-term effects.

Example:

RawSaveScreen();
RawDrawTriangle(0,0,160,100,0,200);
Wait(80);
RawRestoreScreen(); 
will save the screen, draw a triangle, wait for a while and then restore the original screen.

See Also: RawRestoreScreen


RawSetColor

RawSetColor (int colour)
Sets the colour to be used for future raw drawing routines to COLOUR. This is a number you can obtain from the Game, Palette mode in the editor.

Example:

RawSetColor(1984); 
will set the drawing color to green.

See Also: RawClearScreen, RawDrawLine, RawPrint, RawSetColorRGB


RawSetColorRGB

RawSetColorRGB(int red, int green, int blue)
Sets the colour to be used for future raw drawing routines. The colour is specified as the red, green and blue components - each of these can be from 0-255.

This command is slow in 256-colour games, since the palette has to be scanned to find the nearest matching colour.

Example:

RawSetColorRGB(255, 255, 255); 
will set the drawing color to bright white.

See Also: RawSetColor


ReleaseViewport

ReleaseViewport ()
Releases the lock on the screen viewport, allowing it to automatically scroll around following the player character as normal.

Example:

int x;
while (x<100) {
   SetViewport(x,0);
   x++; 
   Wait(1);
}
ReleaseViewPort();
will scroll the room 100 pixels to the right and then return the screen to its original position and unlock the screen viewport.

See Also: SetViewport


RemoveWalkableArea

RemoveWalkableArea (int areanum)
Removes the walkable areas in colour AREANUM from the current room. You can put the area back with RestoreWalkableArea.

NOTE: When the player leaves the screen, all the walkable areas are reset. Therefore, if you want an area to remain off when they leave the screen, you will need to set a flag, then run the RemoveWalkableArea command in the "Player enters screen" event when they return.

Example:

RemoveWalkableArea(5); 
will make the walking area 5 unwalkable.

See Also: RestoreWalkableArea


ResetRoom

ResetRoom (int room_number)
Discards all the data that the engine has in memory about when the player last visited ROOM_NUMBER, and resets it as if they'd never been there. The next time the player goes to that room, all the objects and scripts will be in their initial state (as set up in the editor), and not how they were when the player left the room. The "First time enters screen" event will be run when they enter this room again.

This function is useful if you want to have a "View intro" option to allow the player to watch an intro again - this function can reset all the objects in the intro rooms to their starting positions.

NOTE: You cannot reset the current room (ie. the room that the player is in).

Example:

ResetRoom(0); 
will reset the intro room so it can be played again if the player wants to.

See Also: HasPlayerBeenInRoom


RestoreWalkableArea

RestoreWalkableArea (int areanum)
Makes the area AREANUM walkable again.

Example:

RestoreWalkableArea(4); 
will make the walking area 4 walkable again.

See Also: RemoveWalkableArea


SetAreaScaling

SetAreaScaling(int area, int min, int max)
Changes walkable area number AREA's scaling.

There are two ways to use this command:
1. Pass the same value for MIN and MAX. This will give the walkable area fixed scaling (same as setting it in the editor with "Use continuous scaling" un-ticked).
2. Pass different values for MIN and MAX. In this case, continuous scaling is enabled for the walkable area, and will go from MIN at the top to MAX at the bottom.

MIN and MAX have ranges from 5 to 200, the same as in the editor. Pass 100 for both values to revert to the normal zoom level (100%) for that area.

Example:

SetAreaScaling(5, 120, 170);
will set walkable area 5 to use continuous scaling from 120 to 170 percent.

See Also: GetScalingAt, GetWalkableAreaAt


SetBackgroundFrame

SetBackgroundFrame (int frame)
Locks the background to frame number FRAME of an animating-background screen. (Values for FRAME are from 0 to 4). This allows you to use the animating backgrounds feature for another purpose - you can have two frames of the background, one for example with a spaceship crashed on it. Then, once the right event has happened, call SetBackgroundFrame in the Player Enters Screen event to set the background before the screen fades in.

Call SetBackgroundFrame(-1) to set the default animating frames.

The frame lock is released when the game changes rooms.

Example:

if (GetGlobalInt(20)==1)
    SetBackgroundFrame(4); 
will change the current room’s background frame to 4 if the global integer 20 is 1.

See Also: GetBackgroundFrame


SetFadeColor

SetFadeColor(int red, int green, int blue)
Changes the colour which the screen fades out to, to have the specified RGB value. Each of the parameters can range from 0-255. The default is black, ie. (0, 0, 0)

The colour that you set here will be used in all future calls to FadeIn/FadeOut, and also for the screen transition if it is set to Fade In/Out.

Example:

SetFadeColor(200, 0, 0);
will mean that next time the screen fades out, it fades to red instead of black.

SeeAlso: FadeIn, FadeOut, SetScreenTransition


SetNextScreenTransition

SetNextScreenTransition(TransitionStyle)
Sets the room transition type to TransitionStyle, but ONLY for the next room change. After that, it will revert back to the normal transition type specified in the editor or with SetScreenTransition.

For the possible values for TransitionStyle, see SetScreenTransition.

Example:

SetNextScreenTransition(eTransitionBoxout);
character[EGO].ChangeRoom(10);
will go to room 10 with a box-out effect, but then return to the normal transition type from then on.

SeeAlso: SetScreenTransition


SetScreenTransition

SetScreenTransition(TransitionStyle)
Changes the default screen transition. TransitionStyle can be one of the following:
eTransitionFade
eTransitionInstant
eTransitionDissolve
eTransitionBoxout
eTransitionCrossfade
All future transitions will be done as specified until you call this function again.

Example:

SetScreenTransition(eTransitionFade); 
will change the room transitions to Fade.

SeeAlso: SetNextScreenTransition


SetViewport

SetViewport (int x, int y)
Locks the screen viewport to having the top-left hand corner at (X,Y) in a scrolling room. This allows you to manually pan across a scrolling room or to have the screen follow a non-player character.

The lock is released when you either call ReleaseViewport or the player changes rooms.

NOTE: The co-ordinates supplied are 320x200-scale co-ordinates, and will be automatically multiplied up by the engine.

NOTE: This function has no effect if the current room isn't a scrolling room.

Example:

int ypos = 0;
while (ypos < 60) {
  SetViewport(0, ypos);
  Wait(1);
  ypos++;
}
ReleaseViewport();
will scroll the screen down from the top 60 pixels, then release it back to follow the player around.

See Also: GetViewportX, GetViewportY, ReleaseViewport


SetWalkBehindBase

SetWalkBehindBase (int area, int baseline)
Changes the walk-behind AREA to have new BASELINE. This effectively allows you to turn walk-behinds on and off, although you can do other tricks with it as well. BASELINE is from 1 to the height of the room (normally 200) and moves the line which you set originally in the editor.

Passing BASELINE as 0 disables the walk-behind area, so that the player will always walk in front of it.

Basically, if the character's feet are below BASELINE, he will be drawn in front of it, otherwise he will be drawn behind it.

Example:

SetWalkBehindBase (3,0); 
will disable the walkbehind area number 3.

See Also: Object.Baseline


ShakeScreen

ShakeScreen (int amount)
Shakes the screen to simulate, for example, an earthquake. AMOUNT is how much the screen shakes: 1 is hardly anything, and 25 is a lot.

Example:

ShakeScreen(5); 
will shake the screen a little.

See Also: ShakeScreenBackground


ShakeScreenBackground

ShakeScreenBackground (int delay, int amount, int length)
Shakes the screen to simulate, for example, an earthquake. The game is not paused while the screen shakes - it will continue in the background.

DELAY specifies the 'shakiness' of the shake - 2 is the lowest you can pass for this, and will create the most shaky screen.

AMOUNT specifies the ferociousness of the shake - ie. how much the screen moves by when it does shake. Here, 1 is a very tiny shake, up to about 30 for a ferocious shake.

LENGTH specifies how long the shake lasts for, in game loops. For example, 80 would be equivalent to 2 seconds at the default game speed.

You can abort any current background shake that is in progress by calling this command with the LENGTH parameter as zero.

Example:

ShakeScreenBackground (4, 10, 80); 
will shake the screen a little for 2 seconds.

See Also: ShakeScreen


TintScreen

TintScreen (int red, int green, int blue)
Tints the screen with the specified RGB values. RED, GREEN and BLUE range from 1 to 100.

Pass (0, 0, 0) to turn off the tinting and go back to how the screen normally looks.

NOTE: This command is currently experimental, since it causes a massive slowdown in the engine, especially at high resolutions. If you use it, you should provide an option for the player to turn it off.

NOTE: This feature only works in hi-colour games.

Example:

TintScreen (100, 50, 50); 
will tint a heavy dose of red.

Browser Based Help. Published by chm2web software.
1