Difference between revisions of "Move.obj.v"

From AGI Wiki
Jump to navigationJump to search
(Created page with "move.obj.v   == <br />Syntax == <blockquote><code>move.obj.v(oA,vX,vY,STEPSIZE,fDONEFLAG);</code></blockquote> == <br />Description == Object oA moves from it’s cu...")
 
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
move.obj.v
+
The '''move.obj.v''' command sets an object's [[movement mode]] to 'move object' meaning it will move toward an indirectly specified screen coordinate.
  
&nbsp;
+
== Syntax ==
  
== <br />Syntax ==
+
move.obj.v([[screen object|obj]] oA, [[variable|var]] vX, [[variable|var]] vY, [[variable|var]] vSTEP, [[flag|flg]] fDONE);
  
<blockquote><code>move.obj.v(oA,vX,vY,STEPSIZE,fDONEFLAG);</code></blockquote>
+
== Remarks ==
  
== <br />Description ==
+
[[Screen object]] '''oA''' begins moving toward the point '''vX''', '''vY'''. AGI calculates the best direction based on distance from the point. The screen object will move '''vSTEP''' pixels each step. If '''vSTEP''' = 0, the screen object's current [[step size]] is used. When the [[screen object]] is less than '''vSTEP''' pixels away from point ('''vX''', '''vY'''), the screen object's direction is set to 0, flag '''fDONE''' is set to TRUE, and the [[screen object]] switches to normal motion. The screen object's original step size is restored.
  
Object oA moves from it’s current location to vX,vY by STEPSIZE pixels every step. fDONEFLAG is reset when the command is issued, and set when the object reaches it’s destination. If STEPSIZE is 0, the current step size of object oA is used. If object oA is ego (object 0), the interpreter executes the <code>[[program.control]]</code> command.
+
Flag '''fDONE''' is reset to FALSE when the command is executed.
  
Warning: If your program is relying on the flag fDONEFLAG to be set before continuing with something, such as going to the next part of a cutscene, make sure that the object will always be able to reach it’s destination. It is possible that it could get caught behind a barrier or something, and not be able to get where it needs to go, in which case the game might sit there forever doing nothing. This is more of a problem when the object being moved is ego - it might work fine from where you test it, but it may be possible for the player to move ego into such a position where they will get "stuck" when being moved.
+
Setting the movement mode to 'move object' will automatically enable the [[screen object]] for [[updating]] if not currently enabled. The [[cycling property]] is not modified by the '''move.obj.v''' command.
  
== <br />Sources ==
+
If '''oA''' is [[ego]], it automatically switches to [[program control mode]]. It also returns to [[player control mode]] automatically when it reaches its target location.
 +
If you use the '''[[set.dir]]''' command when an screen object's motion is set to move to a point, the [[screen object]] will move in that direction for one [[interpreter cycle]], but will begin moving toward the end point again after that.
  
[[AGI Studio Help File]]
+
== Possible Errors ==
  
== <br />See also ==
+
AGI does not check that screen object number '''oA''' is a valid [[screen object]]. If it is not, this command will overwrite other data on the [[memory heap]], which may cause unexpected results, including possibly [[crashing AGI]].
  
* <code>[[move.obj]]</code>
+
If either '''vX''' or '''vY''' are off screen ('''vX''' &gt;= 160; '''vY''' &gt;= 168), the command behaves a bit differently. As soon as the [[screen object]] reaches an edge, AGI will set flag fDONE to TRUE, and switch the screen object to normal motion, but the screen object's direction is not set to zero. If the [[screen object]] was moving diagonally when it touched the edge, it will continue moving along the edge since its direction was not set to zero. To avoid unintentional results, it is best to avoid using invalid values for '''vX''' and '''vY'''.
* <code>[[step.size]]</code>
 
* <code>[[Moving objects]]</code>
 
* [[Moving Objects]]
 
  
&nbsp;
+
'''WARNING''': If your game relies on the flag fDONE to be set before continuing with something, such as going to the next part of a cut scene, make sure that the [[screen object]] will always be able to reach its destination. It is possible that it could get caught behind a barrier or something, and not be able to get where it needs to go, in which case the game will sit there forever doing nothing. This is more of a problem when the [[screen object]] being moved is [[ego]] - it might work fine from where you test it, but it may be possible for the player to move ego into such a position where they will get “stuck” when being moved.
  
[[Category:Object Commands]]
+
== Example ==
[[Category:View Commands]]
+
 
[[Category:References]]
+
<div class="CodeBlockHeader">Code:</div>
[[Category:Logic]]
+
<syntaxhighlight lang="agi">
 +
v201 = 120;
 +
v202 = 44;
 +
v203 = 2;
 +
move.obj.v(o1, v201, v202, v203, f99);
 +
[ object will move to the point (120, 44),
 +
[ two pixels per step
 +
</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:'''
 +
| 82 (0x52 hex)
 +
|}
 +
 
 +
== See Also ==
 +
 
 +
'''[[move.obj]]'''<br />
 +
'''[[set.dir]]'''<br />
 +
[[Category:Commands]]<br />

Latest revision as of 16:22, 11 April 2019

The move.obj.v command sets an object's movement mode to 'move object' meaning it will move toward an indirectly specified screen coordinate.

Syntax

move.obj.v(obj oA, var vX, var vY, var vSTEP, flg fDONE);

Remarks

Screen object oA begins moving toward the point vX, vY. AGI calculates the best direction based on distance from the point. The screen object will move vSTEP pixels each step. If vSTEP = 0, the screen object's current step size is used. When the screen object is less than vSTEP pixels away from point (vX, vY), the screen object's direction is set to 0, flag fDONE is set to TRUE, and the screen object switches to normal motion. The screen object's original step size is restored.

Flag fDONE is reset to FALSE when the command is executed.

Setting the movement mode to 'move object' will automatically enable the screen object for updating if not currently enabled. The cycling property is not modified by the move.obj.v command.

If oA is ego, it automatically switches to program control mode. It also returns to player control mode automatically when it reaches its target location. If you use the set.dir command when an screen object's motion is set to move to a point, the screen object will move in that direction for one interpreter cycle, but will begin moving toward the end point again after that.

Possible Errors

AGI does not check that screen object number oA is a valid screen object. If it is not, this command will overwrite other data on the memory heap, which may cause unexpected results, including possibly crashing AGI.

If either vX or vY are off screen (vX >= 160; vY >= 168), the command behaves a bit differently. As soon as the screen object reaches an edge, AGI will set flag fDONE to TRUE, and switch the screen object to normal motion, but the screen object's direction is not set to zero. If the screen object was moving diagonally when it touched the edge, it will continue moving along the edge since its direction was not set to zero. To avoid unintentional results, it is best to avoid using invalid values for vX and vY.

WARNING: If your game relies on the flag fDONE to be set before continuing with something, such as going to the next part of a cut scene, make sure that the screen object will always be able to reach its destination. It is possible that it could get caught behind a barrier or something, and not be able to get where it needs to go, in which case the game will sit there forever doing nothing. This is more of a problem when the screen object being moved is ego - it might work fine from where you test it, but it may be possible for the player to move ego into such a position where they will get “stuck” when being moved.

Example

Code:

<syntaxhighlight lang="agi"> v201 = 120; v202 = 44; v203 = 2; move.obj.v(o1, v201, v202, v203, f99); [ object will move to the point (120, 44), [ two pixels per step </syntaxhighlight>

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 82 (0x52 hex)

See Also

move.obj
set.dir