Difference between revisions of "Shake.screen"
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | The '''shake.screen''' | + | The '''shake.screen''' 'shakes' the screen by rapidly offsetting the image by a few pixels horizontally and vertically a few times. |
− | + | == Syntax == | |
− | + | shake.screen([[number|byt]] COUNT); | |
− | + | == Remarks == | |
− | + | 'Shaking' offsets the [[graphics]] image back and forth by a few pixels. This is useful to provide feedback to the player for earthquakes, crashes, etc. | |
− | + | AGI creates the shake effect by first making an offset copy of the current graphics display. The offset is four pixels down and four pixels to the right. Then, using video synchronization as the timer, AGI swaps the displayed video four times in approximately 0.45 seconds. This is repeated '''COUNT''' times. | |
− | + | Once shaking starts, it cannot be interrupted. Using large values of '''COUNT''' is not advised because of this. For example, a value of 255 will shake the screen for approximately two minutes. | |
− | + | The '''shake.screen''' command can be used on the [[text]] screen. In this case, the screen will flash for the same amount of time, without any displacement. | |
− | + | The specifics on how AGI shakes the screen for HGC, CGA or non-MS-DOS platforms has not been fully studied, but is presumed to be similar to the above described behavior found in the EGA version of AGI. | |
− | |||
− | = | + | There is a fan-modified version of the AGI executable that uses the '''shake.screen''' command to change the color palette used in AGI. This was done to give game authors more color options. The modification would identify values of '''COUNT''' >= 100 and treat them as palette changes, instead of screen shakes. If you encounter a fan made game with '''COUNT''' values from 100 through 109, it was likely intended to be run on the fan-modified AGI version. |
− | + | == Possible Errors == | |
− | |||
− | |||
− | |||
− | |||
− | + | Using a value of zero is not a good idea. Contrary to previous reports, it will not shake the screen indefinitely, but it will shake the screen for approximately 8 hours. This is due to a bug in the shake function that decrements the count value before checking if it is zero; decrementing a two-byte value of zero results in a value of 65535, which corresponds to approximately 8 hours of shaking. | |
− | |||
− | |||
− | |||
− | |||
− | + | == Example == | |
− | |||
− | + | <div class="CodeBlockHeader">Code:</div> | |
− | } | + | <syntaxhighlight lang="agi"> |
− | </syntaxhighlight> | + | #define f99 earthquake |
− | + | if(isset(earthquake)) | |
− | + | { | |
+ | shake.screen(4); | ||
+ | reset(earthquake); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
− | + | == Technical Information == | |
− | |||
− | |||
− | == | + | {| border="1" cellpadding="2" |
+ | | style="background-color: #efefef" width="200" | '''Required Interpreter Version:''' | ||
+ | | width="175" | Available in all AGI versions. | ||
+ | |- | ||
+ | | style="background-color: #efefef" | '''Byte-Code Value:''' | ||
+ | | 110 (0x6E hex) | ||
+ | |} | ||
− | + | == See Also == | |
− | + | [[Display Commands]]<br /> | |
+ | [[Category:Commands]]<br /> |
Latest revision as of 21:39, 21 April 2019
The shake.screen 'shakes' the screen by rapidly offsetting the image by a few pixels horizontally and vertically a few times.
Syntax
shake.screen(byt COUNT);
Remarks
'Shaking' offsets the graphics image back and forth by a few pixels. This is useful to provide feedback to the player for earthquakes, crashes, etc.
AGI creates the shake effect by first making an offset copy of the current graphics display. The offset is four pixels down and four pixels to the right. Then, using video synchronization as the timer, AGI swaps the displayed video four times in approximately 0.45 seconds. This is repeated COUNT times.
Once shaking starts, it cannot be interrupted. Using large values of COUNT is not advised because of this. For example, a value of 255 will shake the screen for approximately two minutes.
The shake.screen command can be used on the text screen. In this case, the screen will flash for the same amount of time, without any displacement.
The specifics on how AGI shakes the screen for HGC, CGA or non-MS-DOS platforms has not been fully studied, but is presumed to be similar to the above described behavior found in the EGA version of AGI.
There is a fan-modified version of the AGI executable that uses the shake.screen command to change the color palette used in AGI. This was done to give game authors more color options. The modification would identify values of COUNT >= 100 and treat them as palette changes, instead of screen shakes. If you encounter a fan made game with COUNT values from 100 through 109, it was likely intended to be run on the fan-modified AGI version.
Possible Errors
Using a value of zero is not a good idea. Contrary to previous reports, it will not shake the screen indefinitely, but it will shake the screen for approximately 8 hours. This is due to a bug in the shake function that decrements the count value before checking if it is zero; decrementing a two-byte value of zero results in a value of 65535, which corresponds to approximately 8 hours of shaking.
Example
<syntaxhighlight lang="agi">
- define f99 earthquake
if(isset(earthquake))
{ shake.screen(4); reset(earthquake); }
</syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 110 (0x6E hex) |