
 Using the PlayPart Effect as a "Macro"


 In the First Tutorials of karate, we have seen the karate
 demo stand for One "main" script, which is a list
 created with <KSCRIPT > of parts to be played.
 these parts are objects created with <KPART >.

 In the Other hand, We could notice we often writes the
 same suits of effects (<Fx>) in parts.

 For example, In the script to come, we have always sprites dancing
in the front, and a serie of different effects in the back.
 For each parts, we would have written the same effects for the sprites
 to dance.

 We will not do that !!!

 In KARATE Script, parts can be played recursively:
 we have a special build-in effect called "PlayPart"
 which have this simple form with 2 parameters:

    <Fx> <Pa> PlayPart </Pa>
        <Pa>    PartLabel </Pa>       a part object, like those used in <PLAY >
        <Pa>    AFF|0|1 </Pa>         a float giving the frame time.
    </Fx>


 The effects which have to be played in each parts will all
 be in the part named: "MACRO_DancingSprites"
and then a simple "playpart" effects will be used to throw them.

 note a part played with "playpart" can perfectly use playpart itself,
 but you COULDN'T make a "vicious circle", with something like

 -Part A playing part A
 or:
 -Part A playing part B playing Part A,...

 It would cause an infinite loop and would crash the amiga. so don't :-)

 About the frame time: note if you give a constant parameter like:
 <Pa> cte  | 0 </Pa>
 your part drawn with playpart will not move, you have to give the date
 the way it's moving. Like the "afine fonction" "AFF | aa | bb"
 do the equation:
 result = aa + ( time * bb )

 AFF |0|1 will do:
 0 + (1 * time)
 and the time passed to the part will be the same as in the calling effect :-)
 You can perfectly try stange things with that argument.

 Note that if the dancing sprites are always present in the front,
 the movement they do "restart to 0" when we change of parts.
 it is normal, because in the script starting time offset, we have set 0.
 In a perfect world, the sprites at the front would have their given
 frametime, and the back effects would have anothers frametime by effects.

 This perfect world exist with the use of the effect "PlayScript".
 It will be discussed in tutorial C02.

 Don't use palette effects (setpalette or bindpalette) in the macros
 parts, because it would execute the palette changing several times.



-------------------------------------------------
<MAIN> myscript |0|1</MAIN>              the main script to play...

<KIMG> texture256x256 | data/texture1.iff </KIMG>   let's create an image.
                                                    Note this image must be 256x256.

<KIMG> impacman | data/oldpac.iff </KIMG>       These one, used for sprites
<KIMG> imghost  | data/ghost1.iff </KIMG>       can be any-sized.
<KIMG> imghost2  | data/inky.iff </KIMG>

<KCAM> cam_1 | 0|0|0|0|0|0|1  </KCAM>

--------------------------------------------------
<KSCRIPT>                           let's write a script to play.

    <ID> myscript </ID>


    <PLAY> part1 | 200 | 0 | 1 </PLAY>
    <PLAY> part2 | 200 | 0 | 1 </PLAY>
    <PLAY> part2 | 200 | 0 | 1 </PLAY>
 

    <PLAY> part1 | 400 | 0 | 1 </PLAY>
    <PLAY> part2 | 400 | 0 | 1 </PLAY>
    <PLAY> part2 | 400 | 0 | 1 </PLAY>

    <PLAY> part1 | 400 | 0 | 1 </PLAY>
    <PLAY> part2 | 400 | 0 | 1 </PLAY>
    <PLAY> part2 | 400 | 0 | 1 </PLAY>


  
</KSCRIPT>

--------------------------------------------------------
///<KPART> <ID> MACRO_DancingSprites  </ID>

 <Fx><Pa>SetCamCoord</Pa><Pa>cam_1</Pa>         a mini pacman will "follow"
            <Pa> sin |0 | 0.45 | 1 </Pa>    x   the big one (after) with a
            <Pa> cos | 0.25 | 1.2 | 0.25</Pa>    y   one second offset
            <Pa> cte | 0 </Pa>    z
            <Pa> 4cte |0|0|0|1</Pa>
            </Fx>
   <Fx><Pa>Sprite</Pa><Pa></Pa><Pa> impacman </Pa><Pa> 4cam| cam_1 |0.5|0.5|0|0|2 </Pa>
    </Fx>

 <Fx><Pa>SetCamCoord</Pa><Pa>cam_1</Pa>         a mini pacman will "follow"
            <Pa> sin |0 | 0.35 | 1 </Pa>    x   the big one (after) with a
            <Pa> cos | 0.25 | -1.2 | 0.25</Pa>    y   one second offset
            <Pa> cte | 0 </Pa>    z
            <Pa> 4cte |0|0|0|1</Pa>
            </Fx>
   <Fx><Pa>Sprite</Pa><Pa></Pa><Pa> imghost </Pa><Pa> 4cam| cam_1 |0.5|0.5|0|0|2 </Pa>
    </Fx>

 <Fx><Pa>SetCamCoord</Pa><Pa>cam_1</Pa>         a mini pacman will "follow"
            <Pa> sint |0 | 0.35 | 1 |100</Pa>    x   the big one (after) with a
            <Pa> cos | 0.25 | 1.1 | 0.25</Pa>    y   one second offset
            <Pa> cte | 0 </Pa>    z
            <Pa> 4cte |0|0|0|1</Pa>
            </Fx>
   <Fx><Pa>Sprite</Pa><Pa></Pa><Pa> imghost2 </Pa><Pa> 4cam| cam_1 |0.5|0.5|0|0|2 </Pa>
    </Fx>

 <Fx><Pa>SetCamCoord</Pa><Pa>cam_1</Pa>         a mini pacman will "follow"
            <Pa> sin |0 | -0.35 | 1 </Pa>    x   the big one (after) with a
            <Pa> cos | 0.25 | 1 | 0.25</Pa>    y   one second offset
            <Pa> cte | 0 </Pa>    z
            <Pa> 4cte |0|0|0|1</Pa>
            </Fx>
   <Fx><Pa>Sprite</Pa><Pa></Pa><Pa> impacman </Pa><Pa> 4cam| cam_1 |-0.5|0.6|0|0|2 </Pa>
    </Fx>


///</KPART>
------------------------
///<KPART>  <ID> part1  </ID>

    <Fx>
        <Pa>setpalette</Pa>
        <Pa> texture256x256 </Pa>   we have seen each image stands for a 256 color palette too.
    </Fx>

    <Fx>
        <Pa> Twirl </Pa>
        <Pa></Pa>
        <Pa> texture256x256 </Pa>

        <Pa>SIN|0|0.5|0.25</Pa> ofsx
        <Pa>COS|0|0.5|0.25</Pa> ofsY

        <Pa>SIN|0|0.05|1</Pa> start angle
        <Pa>CTE|0.2</Pa>    amp. angle
        <Pa>sin|0|0.4|0.9</Pa>    freq angle

        <Pa>CTE|0</Pa>         start dist.
        <Pa>cte|0</Pa> amp.dist
        <Pa>cte|0</Pa> freq dist

        <Pa>CTE|0</Pa> mapping type
    </Fx>


    <Fx> <Pa> PlayPart </Pa>
        <Pa>    MACRO_DancingSprites </Pa>       a part object, like those used in <PLAY >
        <Pa>    AFF|0|1 </Pa>         a float giving the frame time.
    </Fx>

 

///</KPART>
------------------------
///<KPART>  <ID> part2  </ID>

    <Fx>
        <Pa>setpalette</Pa>
        <Pa> texture256x256 </Pa>   we have seen each image stands for a 256 color palette too.
    </Fx>

 
   <Fx><Pa> Warper </Pa>
            <Pa> </Pa>              the rectangle where to draw (default)
            <Pa> texture256x256 </Pa> the 256x256 texture to deform

            <Pa>CTE|0.8</Pa>        a zoomx rate
            <Pa>CTE|0.8</Pa>        a zoomy rate
            <Pa>SIN|0|0.25|0.03</Pa> texture offset x
            <Pa>COS|0|0.25|0.03</Pa> texture offset Y

            <Pa>CTE|0.4</Pa>        amplitude of deformation
            <Pa>CTE|0.2</Pa>        frequency of deformation
            <Pa>SIN|0|0.2|2</Pa>    X offset of the deformation
            <Pa>COS|0|0.3|2</Pa>    Y...

            <Pa>CTE|0</Pa> mapping type
    </Fx>

    <Fx><Pa>RadialBlur</pa>
        <Pa>  </Pa>     rectangle by default.
        <Pa> coltab2 </Pa>              "persistence with decay" is very handy with radialblur.
        <Pa> sin|0.5|0.4|0.2 </Pa>  X center of the radial blur.
        <Pa> sin|0.5|0.3|0.2</Pa>   Y
        <Pa>cte|0.92</Pa>           Width zooming strength [0,1]
        <Pa>cte|0.92</Pa>           Height zooming strength [0,1]
    </Fx>

<KCOLORTABLE> coltab2 | data/remaptable.iff |1|  0|  0|  0    </KCOLORTABLE>



    <Fx> <Pa> PlayPart </Pa>
        <Pa>    MACRO_DancingSprites </Pa>       a part object, like those used in <PLAY >
        <Pa>    AFF|0|1 </Pa>         a float giving the frame time.
    </Fx>



///</KPART>
------------------------
///<KPART>  <ID> part3  </ID>

    <Fx>
        <Pa>setpalette</Pa>
        <Pa> texture256x256 </Pa>   we have seen each image stands for a 256 color palette too.
    </Fx>

  <Fx>
        <Pa> Twirl </Pa>
        <Pa></Pa>
        <Pa> texture256x256 </Pa>

        <Pa>SIN|0|0.5|0.25</Pa> ofsx
        <Pa>COS|0|0.5|0.25</Pa> ofsY

        <Pa>SIN|0|0.05|1</Pa> start angle
        <Pa>CTE|0</Pa>    amp. angle
        <Pa>CTE|0</Pa>    freq angle

        <Pa>CTE|0</Pa>         start dist.
        <Pa>SIN|0|0.3|0.5</Pa> amp.dist
        <Pa>COS|0|0.1|32</Pa> freq dist

        <Pa>CTE|0</Pa> mapping type
    </Fx>
 
    <Fx> <Pa> PlayPart </Pa>
        <Pa>    MACRO_DancingSprites </Pa>       a part object, like those used in <PLAY >
        <Pa>    AFF|0|1 </Pa>         a float giving the frame time.
    </Fx>






///</KPART>
