Flashlight

From Adventure Game Studio | Wiki
Revision as of 18:24, 26 March 2007 by *>Monkey 05 06
Jump to navigation Jump to search

module 30137.0 by monkey_05_06.

Download v2.0 BETA 2

Download v1.9

Description

Emulates the "flashlight" effect using a GUI or screen overlays.

Macros (#define-s)

FLASHLIGHT_VERSION

Defines the current version of the module.

FLASHLIGHT_VERSION_190

Defines version 1.9 of the module.

FLASHLIGHT_VERSION_160

Defines version 1.6 of the module.

FLASHLIGHT_VERSION_150

Defines version 1.5 of the module.

FLASHLIGHT_VERSION_100

Defines version 1.0 of the module.

FLASHLIGHT_GUI

Sets the module to GUI mode. If this macro is set, it must be defined to the script o-name of a GUI of which the first 5 controls are buttons. If not set the module will default to Overlay mode.

Enumerated types

Flashlight_Vars

eFlashlight_MaximumRadius

Defines the maximum radius of the flashlight beam.

eFlashlight_MinimumRadius

Defines the minimum radius of the flashlight beam.

Functions and Properties

Flashlight.CharacterToFollow

writeprotected int Flashlight.CharacterToFollow

Defines the Character the flashlight will follow. If set to null the flashlight will follow the mouse instead.

See Also: Flashlight.FollowCharacter, Flashlight.FollowMouse

Flashlight.FollowCharacter

void Flashlight.FollowCharacter(Character* Char) void Flashlight.SetCharacterToFollow(Character* Char)

Sets the flashlight to follow Character CHAR. If CHAR is null then the flashlight will follow the mouse instead. If "Enforce object-based scripting" is turned off this function will be implemented as Flashlight.SetCharacterToFollow. The script autocomplete will automatically detect the correct version.

See Also: Flashlight.CharacterToFollow, Flashlight.FollowMouse

Flashlight.FollowMouse

void Flashlight.FollowMouse()

Sets the flashlight to follow the mouse instead of a Character. This is the same as passing null to Flashlight.FollowCharacter.

See Also: Flashlight.CharacterToFollow, Flashlight.FollowCharacter

Flashlight.Enabled

bool Flashlight.Enabled

Turns the flashlight effect on and off.

Flashlight.IsFollowingCharacter

writeprotected bool Flashlight.IsFollowingCharacter

Returns whether the flashlight is currently following a Character. This is the opposite of Flashlight.IsFollowingMouse.

See Also: Flashlight.FollowCharacter, Flashlight.IsFollowingMouse

Flashlight.IsFollowingMouse

writeprotected bool Flashlight.IsFollowingMouse

Returns whether the flashlight is currently following the mouse. This is the opposite of Flashlight.IsFollowingCharacter.

See Also: Flashlight.FollowMouse, Flashlight.IsFollowingCharacter

Flashlight.Radius

float Flashlight.Radius

Gets/sets the radius of the flashlight beam.

Note that this is the radius, not the diameter. This means that this property is half the width of the entire beam.

Flashlight.SetSprite

void Flashlight.SetSprite(DynamicSprite* sprite)

Allows you to set the sprite to use for the flashlight beam. To pass an existing sprite you can use DynamicSprite.CreateFromExistingSprite as the parameter. This function will reject null pointers.

See Also: Flashlight.Sprite

Flashlight.Sprite

writeprotected DynamicSprite* Flashlight.Sprite

The sprite used for the flashlight beam. You can use this property to delete the sprite before exiting your game, however you must ensure that Flashlight.Enabled is set to false first or your game will crash. This sprite is automatically loaded from "flashlight.bmp" in your game's Compiled folder if the file exists. If the file does not exist you must set this property with Flashlight.SetSprite before setting Flashlight.Enabled to true or your game will crash.

Flashlight.Transparency

int Flashlight.Transparency

Sets the overall transparency for the darkened areas of the screen. This property can only be used in GUI mode. In Overlay mode this property will remain at 100 as Overlays cannot currently have transparency.

Setup

Modes

GUI Mode

To activate GUI mode you must put the following in the Flashlight module header:

 #define FLASHLIGHT_GUI gFlashlight

Where gFlashlight is the script o-name of your GUI. The first 5 controls of this GUI must be buttons or the module will crash.

Overlay Mode

Overlay mode is the default mode for the module. You cannot use transparency in Overlay mode. If you want to use transparency, use GUI mode instead. Overlay mode depends on the ability to create 5 Overlays, so if you use background speech or are creating your own overlays be aware of this as the Overlays may fail to be created (though under normal circumstances this should not happen).

Other Setup

In order for the Flashlight module to work, you must either:

a) include a "flashlight.bmp" file in your game's Compiled folder OR

b) call Flashlight.SetSprite on a valid DynamicSprite before turning the Flashlight effect on.

Failure to do this will cause your game to crash.

Licensing

 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation  files  (the  "Software"),  to
 // deal in the Software without restriction, including without  limitation  the
 // rights to use, copy, modify, merge, publish, distribute, sublicense,  and/or
 // sell copies of the Software, and to permit persons to whom the  Software  is
 // furnished to do so, subject to the following conditions:
 //
 // The above copyright notice and this permission notice shall be  included  in
 // all copies or substantial portions of the Software.
 //
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,  EXPRESS  OR
 // IMPLIED, INCLUDING BUT NOT LIMITED TO  THE  WARRANTIES  OF  MERCHANTABILITY,
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  THE
 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE  FOR  ANY  CLAIM,  DAMAGES  OR  OTHER
 // LIABILITY, WHETHER IN AN ACTION OF  CONTRACT,  TORT  OR  OTHERWISE,  ARISING
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 // IN THE SOFTWARE.

Changelog

Version 2.0 BETA 2

 Date:        16 February 2007, 2:32 P.M. GMT -6:00
 Author:      monkey_05_06
 Description: Fixed bug if "Enforce object-based  scripting"  was  turned  off.

Version 2.0 BETA 1

 Date:        16 February 2007, 11:53 A.M. GMT -6:00
 Author:      monkey_05_06
 Description: Made Flashlight.CharacterToFollow writeprotected and added method
              Flashlight.FollowCharacter to fix bug when changing  rooms  while
              the   flashlight   was   following    the    player    character.

Version 1.9

 Date:        16 February 2007, 2:28 A.M. GMT -6:00
 Author:      monkey_05_06
 Description: Implemented methods for using a GUI  instead  of  Overlays  which
              should be faster, as well as allowing transparency (set  via  the
              Flashlight.Transparency property).

Version 1.6

 Date:        14 February 2007, 10:05 P.M. GMT -6:00
 Author:      monkey_05_06
 Description: Fixed  bug   with   flashlight   following   scaled   characters.

Version 1.5

 Date:        12 February 2007, 1:52 P.M. GMT -6:00
 Author:      monkey_05_06
 Description: Fixed bug  with  flashlight  following  Characters  in  scrolling
              rooms, corrected usage of Flashlight.Radius as a  diameter,  made
              Flashlight.Radius  a   float   instead   of    an    int,    made
              Flashlight.Sprite writeprotected to  allow  read  access  so  the
              sprite can be deleted, and  implemented  Flashlight.SetSprite  to
              remove dependency on file "flashlight.bmp".

Version 1.0

 Date:        12 February 2007, 1:56 A.M. GMT -6:00
 Author:      monkey_05_06
 Description: First public version of module.