Difference between revisions of "Making Ego Swim in Water"
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Tutorials and Guides|Tutorials and Guides Table of Contents]]<br /> | ||
+ | | ||
+ | |||
+ | <div align="center"><span style="font-size: 22pt">How To Make Your Own AGI Game</span><br /> | ||
+ | ''by David Smith''</div> | ||
+ | |||
+ | | ||
+ | |||
== Making ego swim in Water == | == Making ego swim in Water == | ||
− | In order to make it so that the ego character swims when you touch the water, you will need to prepare several things. First, draw a special view that represents the ego swimming. Often, you can take your regular ego view and trim it down so the bottom half is gone and add water splash marks. Exactly how you do it is up to you. For the use of this tutorial, let's say you saved this view as view.010 but you can call it whatever you want in your own game. Besides drawing the view of ego swimming, you will have to customize the picture with the body of water. You will need to set the priority color for the water to cyan. In | + | In order to make it so that the ego character swims when you touch the water, you will need to prepare several things. First, draw a special view that represents the ego swimming. Often, you can take your regular ego view and trim it down so the bottom half is gone and add water splash marks. Exactly how you do it is up to you. For the use of this tutorial, let's say you saved this view as view.010 but you can call it whatever you want in your own game. Besides drawing the view of ego swimming, you will have to customize the picture with the body of water. You will need to set the priority color for the water to cyan. In [[PicEdit]], this is the fourth color to the right, or often given the value of 3. It is easiest to set the priority color for the body of water at the same time as filling in the color of the water on the visible seen. The visible color is selected by clicking the left mouse button while the mouse is on a color and the priority color is set by clicking the right mouse button when the mouse is on a color. So, select the visible color (blue for water?) and the priority color of cyan, and fill the water area. After filling in the body of water, be sure to turn off the priority color by clicking the the right mouse button on the no color button. |
After doing these two things, you ready to program the logic so it will properly make the ego swimming. In the first section of the logic code, be sure to load the view of the ego swimming, as well as the normal ego walking view. For this tutorial, they are views 10 and 0, respectively: | After doing these two things, you ready to program the logic so it will properly make the ego swimming. In the first section of the logic code, be sure to load the view of the ego swimming, as well as the normal ego walking view. For this tutorial, they are views 10 and 0, respectively: | ||
Line 12: | Line 20: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | | ||
Then, in the main body of the logic, place this code: | Then, in the main body of the logic, place this code: | ||
Line 17: | Line 26: | ||
<div class="CodeBlockHeader">Code:</div> | <div class="CodeBlockHeader">Code:</div> | ||
<syntaxhighlight lang="agi"> | <syntaxhighlight lang="agi"> | ||
− | + | if (isset(f3)) { | |
set.view(10); | set.view(10); | ||
set(f31); | set(f31); | ||
Line 26: | Line 35: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | | ||
The flag, f3, is set when the ego is fully touching the priority color of cyan, in other words, when the ego is on water. | The flag, f3, is set when the ego is fully touching the priority color of cyan, in other words, when the ego is on water. | ||
Line 32: | Line 42: | ||
This technique can be used for other things besides going in the water. Say, you wanted a character to become darker when stepping into a shadow, you could just replace the swimming ego with the shadowy view. In this case, however, you wouldn't want to set and reset f31. | This technique can be used for other things besides going in the water. Say, you wanted a character to become darker when stepping into a shadow, you could just replace the swimming ego with the shadowy view. In this case, however, you wouldn't want to set and reset f31. | ||
− | + | | |
== A tutorial on flag 31 (f31) == | == A tutorial on flag 31 (f31) == | ||
Line 47: | Line 57: | ||
| | ||
− | [[ | + | [[Tutorials and Guides|Tutorials and Guides Table of Contents]] |
− | <span style="float: left">[[ | + | <span style="float: left">[[Basic Logic Set-up for a Typical Scene|< Previous: Basic Logic]]</span> <span style="float: right"><span class="Inactive"><!-- [[|]] -->Next: ></span></span> |
| | ||
[[Category:Tutorials]] | [[Category:Tutorials]] |
Latest revision as of 12:11, 26 December 2013
Tutorials and Guides Table of Contents
by David Smith
Making ego swim in Water
In order to make it so that the ego character swims when you touch the water, you will need to prepare several things. First, draw a special view that represents the ego swimming. Often, you can take your regular ego view and trim it down so the bottom half is gone and add water splash marks. Exactly how you do it is up to you. For the use of this tutorial, let's say you saved this view as view.010 but you can call it whatever you want in your own game. Besides drawing the view of ego swimming, you will have to customize the picture with the body of water. You will need to set the priority color for the water to cyan. In PicEdit, this is the fourth color to the right, or often given the value of 3. It is easiest to set the priority color for the body of water at the same time as filling in the color of the water on the visible seen. The visible color is selected by clicking the left mouse button while the mouse is on a color and the priority color is set by clicking the right mouse button when the mouse is on a color. So, select the visible color (blue for water?) and the priority color of cyan, and fill the water area. After filling in the body of water, be sure to turn off the priority color by clicking the the right mouse button on the no color button.
After doing these two things, you ready to program the logic so it will properly make the ego swimming. In the first section of the logic code, be sure to load the view of the ego swimming, as well as the normal ego walking view. For this tutorial, they are views 10 and 0, respectively:
<syntaxhighlight lang="agi">
if (isset(f5)) { load.view(0); load.view(10); }
</syntaxhighlight>
Then, in the main body of the logic, place this code:
<syntaxhighlight lang="agi">
if (isset(f3)) { set.view(10); set(f31); } else { set.view(0); reset(f31); }
</syntaxhighlight>
The flag, f3, is set when the ego is fully touching the priority color of cyan, in other words, when the ego is on water. At this point, the ego should switch to swimming mode. The reason f31 is set when you are on water is because this flag is what allows the ego to continuously move when in a static position. In water, you want the ego to continue to keep moving, even in one spot in order to simulate wading. Then, when the ego gets back out of the water, this flag should be reset, because when you stop walking, you don't continue moving. A tutorial on f31.
This technique can be used for other things besides going in the water. Say, you wanted a character to become darker when stepping into a shadow, you could just replace the swimming ego with the shadowy view. In this case, however, you wouldn't want to set and reset f31.
A tutorial on flag 31 (f31)
The template game (as well as all Sierra games), has a bit of code in logic 0, that allows for the ego to stop cycling when the ego stops moving around. This is done because when the ego stops walking, they should no longer be moving. However, there are times, when the character is not moving, that you want the graphics to continue cycling anyway. For this, there is a special flag. In the template game, it is f31. Sierra used different flags for different games, like f33, but in the template game, it is set up as f31, so that is what you should use. When flag 31 is set, the ego will continue to animate, or cycle, even when in a static, non-moving position. This can be useful in several different cases. One could be if you want the ego to be in a swimming state. When they stop moving around, and stay in one place, they would still be animated, in order to simulate wading. Another case you would want to set this flag is if the ego were doing an action while standing in place. Say you have them pulling out a sword, or turning their head from side to side looking around. In order to ensure that these animations take place, f31 needs to be set. If f31 is not set, then whenever ego is standing in a static place, a stop.cycling(o0) is automatically issued. After utilizing the f31 flag, it is important to reset it.
Opening/ Closing doors
Getting objects
Making NPCs (non-player characters)
Setting timers
Tutorials and Guides Table of Contents
< Previous: Basic Logic Next: >