Difference between revisions of "AGIWiki/Animated object"

Jump to navigation Jump to search
m
Text replacement - "</source>" to "</syntaxhighlight>"
(Created page with "{{AGIWiki}} ''This article refers to "screen objects" or "animated objects". For other uses of the term "object", see the Object disambiguation page.'' '''Ob...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(8 intermediate revisions by 2 users not shown)
Line 11: Line 11:
Before you can use a screen object, it must be initialized. Initialization involves the following steps:
Before you can use a screen object, it must be initialized. Initialization involves the following steps:


# '''Animate the object.''' This is done using the '''[[AGIWiki/Animate.obj|animate.obj]]''' command. This tells the [[AGIWiki/Interpreter|interpreter]] that you want to use this object. There are a limited number of objects that the interpreter can use at any one time. This is set by a certain byte in the [[AGIWiki/OBJECT file|OBJECT file]]. [[AGIWiki/WinAGI|WinAGI]] allows you to easily edit the maximum number of screen objects. The more objects you use the slower the interpreter will run, but today's computer have less of a problem with this.
# '''Animate the object.''' This is done using the '''[[AGIWiki/animate.obj|animate.obj]]''' command. This tells the [[AGIWiki/Interpreter|interpreter]] that you want to use this object. There are a limited number of objects that the interpreter can use at any one time. This is set by a certain byte in the [[AGIWiki/OBJECT file|OBJECT file]]. [[AGIWiki/WinAGI|WinAGI]] allows you to easily edit the maximum number of screen objects. The more objects you use the slower the interpreter will run, but today's computer have less of a problem with this.
# '''Assign a view to the object.''' This is done using the '''[[AGIWiki/Set.view|set.view]]''' command. Each object must have a view assigned to it, and this is the view that is displayed on the screen wherever the object is. One view can be assigned to multiple screen objects. You must have the view loaded into memory before you assign it, using the '''[[AGIWiki/Load.view|load.view]]''' command. It is possible to assign the same view to more than one object. This can be used to create 'herds' of objects. The alligators in the King's Quest I moat are a good example.
# '''Assign a view to the object.''' This is done using the '''[[AGIWiki/set.view|set.view]]''' command. Each object must have a view assigned to it, and this is the view that is displayed on the screen wherever the object is. One view can be assigned to multiple screen objects. You must have the view loaded into memory before you assign it, using the '''[[AGIWiki/load.view|load.view]]''' command. It is possible to assign the same view to more than one object. This can be used to create 'herds' of objects. The alligators in the King's Quest I moat are a good example.
# '''Position the object on screen.''' The default values for the object's coordinates are (0,0). Set the initial position of the object with the '''[[AGIWiki/Position|position]]''' or '''[[AGIWiki/Position.v|position.v]]''' commands.
# '''Position the object on screen.''' The default values for the object's coordinates are (0,0). Set the initial position of the object with the '''[[AGIWiki/position|position]]''' or '''[[AGIWiki/position.v|position.v]]''' commands.
# '''Draw the object.''' This is done using the '''[[AGIWiki/Draw|draw]]''' command. The object is not visible on the screen until this command is issued.If you later need to remove it from the screen, use the erase command. When drawing objects, the object's location (set by '''[[AGIWiki/Position|position]]''' or '''[[AGIWiki/Position.v|position.v]]''') is validated using a method called '[[AGIWiki/Animated object#shuffling|shuffling]]' to ensure the object is not drawn outside the playable area, on a control line or on another object (if the object is not ignoring other objects).
# '''Draw the object.''' This is done using the '''[[AGIWiki/draw|draw]]''' command. The object is not visible on the screen until this command is issued.If you later need to remove it from the screen, use the erase command. When drawing objects, the object's location (set by '''[[AGIWiki/position|position]]''' or '''[[AGIWiki/position.v|position.v]]''') is validated using a method called '[[AGIWiki/Animated object#shuffling|shuffling]]' to ensure the object is not drawn outside the playable area, on a control line or on another object (if the object is not ignoring other objects).


=== Example ===
=== Example ===
Line 20: Line 20:
The following example displays an animation of VIEW.004 at (80, 120) on the screen, using object 2:
The following example displays an animation of VIEW.004 at (80, 120) on the screen, using object 2:


<syntax type="C++">
<syntaxhighlight lang="cpp">
  animate.obj(o2);
  animate.obj(o2);
  load.view(4);
  load.view(4);
Line 26: Line 26:
  position(o2, 80, 120);
  position(o2, 80, 120);
  draw(o2);
  draw(o2);
</syntax>
</syntaxhighlight>


== Cycling objects ==
== Cycling objects ==
Line 35: Line 35:


Normally when an object is moving around, its loop number is determined by its direction:
Normally when an object is moving around, its loop number is determined by its direction:
 
{|
|
{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
! Direction
! Direction
Line 67: Line 68:
| 1 (if loop 1 exists; otherwise loop 0)
| 1 (if loop 1 exists; otherwise loop 0)
|}
|}
| [[File:AGIWiki objdir.png]]
|}]


The direction is only chosen automatically if there are less than 5 loops in the view assigned to the object.
The direction is only chosen automatically if there are less than 5 loops in the view assigned to the object.
Line 120: Line 123:
== Moving objects ==
== Moving objects ==


Each object on screen has a direction it is moving in. This is a numerical value from 0 to 8:
Each object on screen has a direction it is moving in. This is a numerical value from 0 to 8:


When an object is moving normally (and has a direction greater than 0), it will continue moving until it is told to stop, move in another direction, or runs into an obstacle (such as a control line, a block, or another object).
When an object is moving normally (and has a direction greater than 0), it will continue moving until it is told to stop, move in another direction, or runs into an obstacle (such as a control line, a block, or another object).
Line 236: Line 239:


Some of the text in this article is based on the [[AGIWiki/AGI Studio|AGI Studio]] help file and the [[AGIWiki/WinAGI|WinAGI]] help file.
Some of the text in this article is based on the [[AGIWiki/AGI Studio|AGI Studio]] help file and the [[AGIWiki/WinAGI|WinAGI]] help file.
== Data types ==
{{AGIWiki/Data types}}
TrustedUser
2,147

edits

Navigation menu