Difference between revisions of "Shake.screen"

From AGI Wiki
Jump to navigationJump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
The '''shake.screen''' command shakes the screen a specified number of times.
+
The '''shake.screen''' 'shakes' the screen by rapidly offsetting the image by a few pixels horizontally and vertically a few times.
  
<code>shake.screen(shakeCount);</code>
+
== Syntax ==
  
The screen is shaken <code>shakeCount</code> times. The screen is "shaken" by moving the entire screen image around on the monitor to give a violent tremor effect.
+
shake.screen([[number|byt]] COUNT);
  
Note: although shaking the screen 100 or more times is not recommended (because the screen will shake for a long time), it should be noted that the shake.screen command is altered if you are using [[AGIPAL]] so that any value between 100 and 109 changes the game's palette instead of shaking the screen.
+
== Remarks ==
  
&nbsp;
+
'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.
  
==Parameters==
+
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.
  
* shakeCount: a number, 0-255, specifying how many times to shake the screen  
+
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.
  
Possible errors
+
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.
  
* Some [[Interpreter|interpreters]], such as [[NAGI]], do not support the shake.screen command and will do nothing if the command is issue. It is safe to issue the command on these interpreters, but it will be ignored.
+
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.
* Specifying a value of 0 for shakeCount appears to make the screen shake forever.  
 
  
==Examples==
+
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.
  
The following code will shake the screen five times whenever the player enters this room:
+
== Possible Errors ==
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockStyle">
 
<syntaxhighlight lang="agi">
 
#include "defines.txt"
 
  
if (new_room)
+
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.
{
 
    load.pic(room_no);
 
    draw.pic(room_no);
 
    discard.pic(room_no);
 
  
    draw(ego);
+
== Example ==
    show.pic();
 
  
    shake.screen(5);
+
<div class="CodeBlockHeader">Code:</div>
}
+
<syntaxhighlight lang="agi">
</syntaxhighlight></div>
+
#define f99 earthquake
 
+
if(isset(earthquake))
==See also==
+
  {
 +
  shake.screen(4);
 +
  reset(earthquake);
 +
  }
 +
</syntaxhighlight>
  
* [[AGIPAL]]
+
== Technical Information ==
* [[defines.txt]]
 
* [[New Room Section]]
 
  
==Sources==
+
{| 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)
 +
|}
  
* [[AGI Studio]] help file
+
== See Also ==
  
&nbsp;
+
[[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

Code:

<syntaxhighlight lang="agi">

  1. 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)

See Also

Display Commands