Flashlight: Difference between revisions
→v2.0 BETA 3 now up yay ;)
*>Monkey 05 06 mNo edit summary |
*>Monkey 05 06 |
||
Line 1: | Line 1: | ||
{{Thread|30137.0|Flashlight module}} by [[monkey_05_06]]. | {{Thread|30137.0|Flashlight module}} by [[monkey_05_06]]. | ||
[http://www.meleepta.com/file.php?dir=ags&file= | [http://www.meleepta.com/file.php?dir=ags&file=Flashlight_2_0_BETA_3.rar Download v2.0 BETA 3] | ||
[http://www.meleepta.com/file.php?dir=ags&file=Flashlight_1_9.rar Download v1.9] | [http://www.meleepta.com/file.php?dir=ags&file=Flashlight_1_9.rar Download v1.9] | ||
==Description== | ==Description== | ||
Emulates the "flashlight" effect using a GUI or screen | Emulates the "flashlight" effect using a GUI or screen overlay. | ||
==Macros (#define-s)== | ==Macros (#define-s)== | ||
====FLASHLIGHT_VERSION==== | ====FLASHLIGHT_VERSION==== | ||
Defines the current version of the module. | Defines the current version of the module. | ||
====FLASHLIGHT_VERSION_200==== | |||
Defines version 2.0 of the module. | |||
====FLASHLIGHT_VERSION_190==== | ====FLASHLIGHT_VERSION_190==== | ||
Line 24: | Line 27: | ||
Defines version 1.0 of the module. | Defines version 1.0 of the module. | ||
==== | ==Functions and Properties== | ||
Sets the | ====Flashlight.BeamSprite==== | ||
''writeprotected DynamicSprite* Flashlight.BeamSprite'' | |||
Defines the DynamicSprite used as the 'beam' of the flashlight. This is essentially a black square with a transparent hole in the middle. You can use this property to delete the DynamicSprite before you quit the game and you can set the sprite using the Flashlight.SetBeamSprite method. | |||
====Flashlight.Enabled==== | |||
''bool Flashlight.Enabled'' | |||
Sets whether or not the flashlight effect will be enabled. If no BeamSprite is set then this property will be set to false until the BeamSprite is properly set. | |||
====Flashlight.FollowingCharacter==== | |||
''writeprotected Character* Flashlight.FollowingCharacter'' | |||
Returns the Character the flashlight beam is currently following (if any). If following the mouse or statically positioned this will return NULL. You can set the Character to follow using the Flashlight.SetFollowCharacter method. | |||
====Flashlight.IsFollowingCharacter==== | |||
''writeprotected bool Flashlight.IsFollowingCharacter'' | |||
Returns whether the flashlight beam is following any character (this is the same as checking whether the FollowingCharacter property is NULL). You can lock the flashlight's beam to a Character's position using the Flashlight.SetFollowCharacter method. | |||
====Flashlight.IsFollowingMouse==== | |||
''writeprotected bool Flashlight.IsFollowingMouse'' | |||
Returns whether the flashlight beam is following the mouse. You can lock the flashlight's beam to the mouse position using the Flashlight.SetFollowMouse method. | |||
==== | ====Flashlight.IsFollowingPlayer==== | ||
''writeprotected bool Flashlight.IsFollowingPlayer'' | |||
Returns whether the flashlight's beam is following the player Character. This will not actually test if the FollowingCharacter property is set to the current player Character; rather it simply determines whether the FollowingCharacter property will be updated if the player changes. You can lock the flashlight's beam to follow the player Character using the Flashlight.SetFollowCharacter method. | |||
' | |||
====Flashlight.IsGUIMode==== | |||
''writeprotected bool Flashlight.IsGUIMode'' | |||
Returns whether the flashlight is using a GUI. The benefit of using a GUI is the ability to set transparency using the Flashlight.Transparency property. You can set the flashlight to GUI mode using the Flashlight.SetGUIMode method. | |||
====Flashlight. | ====Flashlight.IsOverlayMode==== | ||
'' | ''writeprotected bool Flashlight.IsOverlayMode'' | ||
Returns whether the flashlight is using an Overlay. The draw-back to using an Overlay instead of a GUI is that you cannot set transparency. You can set the flashlight to Overlay mode using the Flashlight.SetOverlayMode method. | |||
'' | ====Flashlight.IsStatic==== | ||
''writeprotected bool Flashlight.IsStatic'' | |||
Returns whether the flashlight's beam is statically positioned. This means that in order to move the flashlight you must manually modify the Flashlight.X and Flashlight.Y properties. You can lock the flashlight's beam to a static position using the Flashlight.SetStatic method. | |||
' | |||
====Flashlight.Radius==== | |||
''float Flashlight.Radius'' | |||
Gets/sets the RADIUS (1/2 the diameter) of the flashlight beam. Cannot be set to less than 0.5 (it will be reset to 0.5 if set to less than this value). | |||
====Flashlight. | ====Flashlight.ScaleBeam==== | ||
''bool Flashlight. | ''bool Flashlight.ScaleBeam'' | ||
Controls whether the flashlight beam is scaled based on the scaling of the FollowingCharacter property. If not following a Character this does nothing. Note that the Flashlight.Radius property is NOT updated based upon any scaling, only the actual size of the beam will reflect this. | |||
====Flashlight. | ====Flashlight.SetBeamSprite==== | ||
'' | ''void Flashlight.SetBeamSprite(DynamicSprite* beamSprite)'' | ||
Sets the sprite to use for the flashlight beam. NULL values will be rejected. It is possible to set an existing sprite as the beam sprite by passing DynamicSprite.CreateFromExistingSprite as the parameter. See Flashlight.BeamSprite for more information. | |||
'' | ====Flashlight.SetFollowCharacter==== | ||
''void Flashlight.SetFollowCharacter(Character*, optional bool followPlayer)'' | |||
Locks the flashlight's beam to the Character's position. If (and only if) the Character passed is the current player AND followPlayer is TRUE (the default) the FollowingCharacter property will be locked to the PLAYER Character, updating if the player is changed; otherwise the beam will be locked exclusively to the position of the passed Character. Note that the Character MUST be in the current room or the beam will be locked to the mouse position instead. | |||
'' | |||
====Flashlight.SetFollowMouse==== | |||
''void Flashlight.SetFollowMouse()'' | |||
'' | Locks the flashlight's beam to the mouse's position. | ||
====Flashlight. | ====Flashlight.SetGUIMode==== | ||
'' | ''void Flashlight.SetGUIMode(GUI*)'' | ||
Sets the flashlight to use the passed GUI (if valid, otherwise defaults to Overlay mode). | |||
'' | ====Flashlight.SetOverlayMode==== | ||
''void Flashlight.SetOverlayMode()'' | |||
Sets the flashlight to use an Overlay. | |||
====Flashlight.SetStatic==== | |||
''void Flashlight.SetStatic()'' | |||
' | Locks the flashlight's beam to its current (X,Y) position. You can move it manually by modifying the X/Y properties, or lock it back to the mouse (Flashlight.SetFollowMouse) or a Character (Flashlight.SetFollowCharacter) using the appropriate functions. | ||
====Flashlight. | ====Flashlight.ScreenSprite==== | ||
''writeprotected DynamicSprite* Flashlight. | ''writeprotected DynamicSprite* Flashlight.ScreenSprite'' | ||
The | The DynamicSprite used to cover the screen. You can use this property to delete the DynamicSprite before you quit the game. | ||
====Flashlight.Transparency==== | ====Flashlight.Transparency==== | ||
''int Flashlight.Transparency'' | ''int Flashlight.Transparency'' | ||
Sets the | Sets the transparency for the (dark areas of the) flashlight effect. This is only valid if the flashlight is in GUI mode. This property is also passed through a bounding function similar to the way AGS's CHAR type works such that -1 will loop back around to 100, -2 to 99, -3 to 98, and 101 to 0, 102 to 1, 103 to 2, etc. | ||
====Flashlight.X==== | |||
''int Flashlight.X'' | |||
Gets the X co-ordinate of the center of the flashlight beam. If the beam is statically positioned (Flashlight.SetStatic) you can also use this to set the X co-ordinate. | |||
====Flashlight.Y==== | |||
''int Flashlight.Y'' | |||
Gets the Y co-ordinate of the center of the flashlight beam. If the beam is statically positioned (Flashlight.SetStatic) you can also use this to set the Y co-ordinate. | |||
==Setup== | ==Setup== | ||
===Modes=== | ===Modes=== | ||
====GUI | ====GUI mode==== | ||
To activate GUI mode you | GUI mode allows you to use {{link||Flashlight.Transparency|transparency}} in the darkened areas of the screen when applying the flashlight effect. | ||
To activate GUI mode you can put the following in the Flashlight module header: | |||
#define FLASHLIGHT_GUI gFlashlight | #define FLASHLIGHT_GUI gFlashlight | ||
Where ''gFlashlight'' is the script o-name of your GUI. The | Where ''gFlashlight'' is the script o-name of your GUI. The GUI no longer requires any controls (''Flashlight module v2.0 BETA 3''). Alternately you can set GUI mode at any time throughout the game by calling {{link||Flashlight.SetGUIMode}}. | ||
====Overlay | ====Overlay mode==== | ||
Overlay mode is the default mode for the module. You cannot use {{link||Flashlight.Transparency|transparency}} in Overlay mode. If you want to use transparency, use {{link||GUI mode}} instead | Overlay mode is the default mode for the module. You cannot use {{link||Flashlight.Transparency|transparency}} in Overlay mode. If you want to use transparency, use {{link||GUI mode}} instead. | ||
===Other Setup=== | ===Other Setup=== | ||
In order for the Flashlight module to work, you must | In order for the Flashlight module to work, you must: | ||
a) include a "flashlight.bmp" file in your game's Compiled folder | a) include a "flashlight.bmp" file in your game's Compiled folder ''and/or'' | ||
b) call Flashlight. | b) call {{link||Flashlight.SetBeamSprite}} on a valid {{link|DynamicSprite functions and properties||DynamicSprite}} '''before''' turning the Flashlight effect on. | ||
Failure to do this will | Failure to do this will prevent the module from working properly and prevent the {{link||Flashlight.Enabled}} property from being set (it will reset to '''false''' every loop until the {{link||Flashlight.BeamSprite|BeamSprite}} is properly set. | ||
==Licensing== | ==Licensing== | ||
Line 142: | Line 176: | ||
==Changelog== | ==Changelog== | ||
====Version 2.0 BETA 3==== | |||
Date: 21 November 2007, 2:57 P.M. GMT -6:00 | |||
Author: monkey_05_06 | |||
Description: Uses RawDraw methods to only require two sprites instead of six, | |||
and only one Overlay instead of five. Also GUI no longer | |||
requires ANY controls as opposed to previous requisite of five. | |||
Designed to be forward-compatible with AGS 3.0 while remaining | |||
compatible with AGS 2.72. | |||
Renamed: | |||
Flashlight.CharacterToFollow to Flashlight.FollowingCharacter, | |||
Flashlight.FollowCharacter to Flashlight.SetFollowCharacter, | |||
Flashlight.FollowMouse to Flashlight.SetFollowMouse, | |||
Flashlight.SetSprite to Flashlight.SetBeamSprite, and | |||
Flashlight.Sprite to Flashlight.BeamSprite. | |||
Added: | |||
Flashlight.IsFollowingPlayer, Flashlight.IsGUIMode, | |||
Flashlight.IsOverlayMode, Flashlight.IsStatic, | |||
Flashlight.ScaleBeam, Flashlight.SetGUIMode, | |||
Flashlight.SetOverlayMode, Flashlight.SetStatic, and | |||
Flashlight.ScreenSprite. | |||
====Version 2.0 BETA 2==== | ====Version 2.0 BETA 2==== | ||
Date: 16 February 2007, 2:32 P.M. GMT -6:00 | Date: 16 February 2007, 2:32 P.M. GMT -6:00 |