Author Topic: Oscillating a view  (Read 9981 times)

0 Members and 1 Guest are viewing this topic.

Offline Cloudee1

Oscillating a view
« on: May 04, 2015, 08:41:49 PM »
With the decompiled sq5 script available, I have been playing around with some of the new cycle script options.

One such script, Osc... short for oscillation I assume is actually pretty cool. I am not sure when it is that I personally might use it, nevertheless I have been playing around with it so I figured I would share what it is that I have learned about it.

First off, you are going to want to add it to your current game. Here is the script... Of course you can give it any script number that fits your needs.

Code: [Select]
//*****************************************************
// osc
//*****************************************************
(include "sci.sh")(include "game.sh")
//*****************************************************
(script 972)                              (use "Cycle")
//*****************************************************
(class Osc of Cycle
    (properties
        client 0
        caller 0
        cycleDir 1
        cycleCnt 0
        completed 0
        howManyCycles -1
    )

    (method (init param1 theHowManyCycles theCaller)
        (if (>= paramTotal 2)
            = howManyCycles theHowManyCycles
            (if (>= paramTotal 3)
                = caller theCaller
            )
        )
        (super:init(param1))
    )


    (method (doit)
        (var OscNextCel)
        (if ((> (= OscNextCel (self:nextCel())) (send client:lastCel())) or (< OscNextCel 0))
            = cycleDir neg cycleDir
            (self:cycleDone())
        )(else
            (send client:cel(OscNextCel))
        )
    )


    (method (cycleDone)
        (if (howManyCycles)
            (send client:cel((self:nextCel())))
            (if (> howManyCycles 0)
                --howManyCycles
            )
        )(else
            = completed 1
            (self:motionCue())
        )
    )

)// end class
//*****************************************************

Next, you will want to use it in a room, so at the top with all of the other uses, add in the use line... You may need to change the sc and sco file names in the source folder to do it exactly like this.

Code: [Select]
(use "osc")

and finally you will want to apply it to an instance of a view. For my testing, I just created three instances and used the same view for all three of them. A square that grows from a dot outward.

Code: [Select]
(instance testViewOsc0 of Prop(properties view 1 cel 0 loop 0 x 120 y 160))
(instance testViewOsc1 of Prop(properties view 1 cel 0 loop 0 x 160 y 160))
(instance testViewOsc2 of Prop(properties view 1 cel 0 loop 0 x 200 y 160))

Then in the init section I went ahead and told each instance to oscillate with setCycle(Osc). Now actually watching it and counting the oscillations, I am of the opinion that it suffers from being off by 1.

Code: [Select]
        (testViewOsc0:init()setCycle(Osc)) // oscillates infinitely
        (testViewOsc1:init()cycleSpeed(4)setCycle(Osc 3))// out, in, out, in... ending where it began cel 0, so actually 4
        (testViewOsc2:init()setCycle(Osc 6))// o,i,o,i,o,i,o... ending on last cel, so actually 7

I have gone ahead and attached a copy of it in action if you want to take a peak.

*Edit
So I figured out a use for it... I have now applied oscillate to the flashing red warning lights in my pnc remake of space quest 1. I redrew the light a bit for this purpose and I like it.
« Last Edit: May 05, 2015, 09:48:19 AM by Cloudee1 »


Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.045 seconds with 22 queries.