Now change the include "llama3.moo" to "llama4.moo", and re-assemble. Notice the complex path that the llama now moves on. This is generated by using both positional variables and waveform variables together. Doing this is quite straightforward - let's have a look at the definition of "llama4.moo" and see what is going on...
; ; llama4.moo = a MacrOObject that ; defines a vector llama with slightly ; more complex motion llm4: ; header .dc.s 0 ;Prev .dc.s 0 ;Next .dc.s $03060000 ;3 longs secondary, 6 vects params .dc.s 0 ;Address of parameter block if not local .dc.s 0 ;Address of ranges table, if not local .dc.s 0 ;this'll be where the command string is, if not local .dc.s lineobj ;prototype to use .dc.s 0 ;no secondary data .dc.s llm4_end-llm4 ;length .dc.s 0 ;init routine (called when object is first generated) .dc.s 0,0 .dc.s 0,0,0,0All that's new in the header is that I have declared 4 extra variable parameter vectors.
; variables .dc.s $b00000 ;xpos .dc.s $10000 ;vel .dc.s $10000 ;fr. .dc.s $80000201 ;mode (bounce), limits .dc.s $200000 ;ypos .dc.s $0 ;vel .dc.s $10000 ;fr. .dc.s $80000202 ;mode (bounce), limitsThe first two are the positiona, as before...
.dc.s 0 .dc.s 0 .dc.s $18000 .dc.s 2 ;sine wave .dc.s 0 .dc.s 0 .dc.s $13000 .dc.s 2 ;another sine wave .dc.s 0 .dc.s 0 .dc.s $23000 .dc.s 2 ;another sine wave .dc.s 0 .dc.s 0 .dc.s $2c000 .dc.s 2 ;another sine waveAnd I have added some sine waves.
; ranges .dc.s $400000,$1080000,$c00000,-$60 .dc.s $80,-$40,$40,0 .dc.s 0,0,0,0 .dc.s 0,0,0,0I've added a few extra ranges here, which the waveforms will use to add to the positions generated by the positional variables. I also reduced the area of motion for the positional variables somewhat, so that when the waveforms are added in, the llama doesn't spend too much time off the screen!
; local secondary data space .dc.s llama ;vector list address .dc.s $01000100 ;scales .dc.s $600 ;constant to add to Y velocityThe secondary data space is the same as it was before...
; command .ascii "_c+B1=B1" ;add _c to B1 .ascii "A0!=a<" ;set xpos .ascii "C*D[34]+a<=a<" ;offset xpos .ascii "B0!=a>" ;set ypos .ascii "E*F[56]+a>=a>" ;offset ypos .ascii "_a=h" ;set VL address .ascii "_b=e:" ;set scales .align.v llm4_end:As you can see there are a couple of extra lines added to the command string. At first, the commands proceed as before, adding to B1 to generate the "gravity", and setting the xpos from A0. Then comes the statement "C*D[34]+a<=a<". What this does is displace the X-position from the simple one generated by the positional variable, in the following manner:
C and D are defined as sinewaves. The operator "*" is used to combine waveforms by multiplication (note that this is not a "straight" multiply - the result is shifted right by 32 after the multiply). So, "C*D[34]" multiplies together the two sinewaves C and D to generate a more interesting waveform, then scales the result onto the range -$60 to +$80, as specified in Ranges(3) and Ranges(4). This is added to the X position originally stored in "a<" by the previous statement, and the result is stored back into "a<".
For the y-displacement, the pair of sinewaves E and F are used in the same manner, the result scaled using Ranges(5) and Ranges(6), and added to the Y position already generated in "a>",
We are almost finished with the llama now, just a couple more examples to go. In the next one, we'll twiddle a few more of the parameters to make a more interesting llama.