Difference between revisions of "AGIWiki/posn"

From ScummVM :: Wiki
Jump to navigation Jump to search
m (Created page with "__NOTOC__ {{AGIWiki}} The '''posn''' command returns TRUE if the screen coordinates of the screen object's bottom left pixel is within a specified region. ---- == Syntax == :...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{AGIWiki}}
{{AGIWiki}}
 
{{AGIWiki/Test commands}}
The '''posn''' command returns TRUE if the screen coordinates of the screen object's bottom left pixel is within a specified region.
The '''posn''' command returns TRUE if the screen coordinates of the screen object's bottom left pixel is within a specified region.
----


== Syntax ==
== Syntax ==
Line 16: Line 14:
The region to be tested is bounded by (X1, Y1) - (X2, Y2).
The region to be tested is bounded by (X1, Y1) - (X2, Y2).


The position test commands ('''posn''', '''[[AGIWiki/center.posn|center.posn]]''', '''[[AGIWiki/right.posn|right.posn]]''', and '''[[AGIWiki/obj.in.box|obj.in.box]]''' are used to determine if a screen object's position is within a certain area.
The position test commands ('''posn''', '''[[AGIWiki/center.posn|center.posn]]''', '''[[AGIWiki/right.posn|right.posn]]''', and '''[[AGIWiki/obj.in.box|obj.in.box]]''') are used to determine if a screen object's position is within a certain area.


The bottom left pixel of a screen object's view is its reference point. The '''posn''' command tests the location of this reference point.
The bottom left pixel of a screen object's view is its reference point. The '''posn''' command tests the location of this reference point.
Line 24: Line 22:
== Example ==
== Example ==


<syntax type = "C++">
<syntaxhighlight lang="cpp">
  if (posn(o1, 0, 120, 60, 130)) {
  if (posn(o1, 0, 120, 60, 130)) {
   print("the object's lower left corner is in the box");
   print("the object's lower left corner is in the box");
  }
  }
</syntax>
</syntaxhighlight>
 
== Technical Information ==
== Technical Information ==



Latest revision as of 15:11, 25 October 2018

AGIWiki


Test commands

The posn command returns TRUE if the screen coordinates of the screen object's bottom left pixel is within a specified region.

Syntax

posn(obj oA, byt X1, byt Y1, byt X2, byt Y2)

Remarks

Test commands are only valid in an if statement.

The region to be tested is bounded by (X1, Y1) - (X2, Y2).

The position test commands (posn, center.posn, right.posn, and obj.in.box) are used to determine if a screen object's position is within a certain area.

The bottom left pixel of a screen object's view is its reference point. The posn command tests the location of this reference point.

However, sometimes a programmer needs to test for positions relative to the center or right edge of the object. This could be done by using the posn command and the object's width and performing some additional mathematical commands. Sierra included the additional position test commands to make it easier to check for these conditions.

Example

 if (posn(o1, 0, 120, 60, 130)) {
   print("the object's lower left corner is in the box");
 }

Technical Information

Required interpreter version Available in all AGI versions
Bytecode value 11 (0x0B hex)

See Also

Sources