]> git.tdb.fi Git - libs/demoscene.git/commitdiff
Add a repeat statement
authorMikko Rasa <tdb@tdb.fi>
Sat, 8 Jun 2019 15:54:17 +0000 (18:54 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 8 Jun 2019 15:54:17 +0000 (18:54 +0300)
source/sequencer.cpp
source/sequencer.h

index 19c4041ab2f1d954a8ff7720d739019c6811a460..b4969bb30337182b35500b7ec378797bd8c1e86c 100644 (file)
@@ -147,6 +147,7 @@ Sequencer::Loader::Loader(Sequencer &s, Demo &d):
        add("base", &Loader::base);
        add("define_action", &Loader::define_action);
        add("instant", &Loader::instant);
+       add("repeat", &Loader::repeat);
        add("segment", &Loader::segment);
 }
 
@@ -168,6 +169,15 @@ void Sequencer::Loader::instant(float beat)
        segment(beat, beat);
 }
 
+void Sequencer::Loader::repeat(float b, float d, unsigned n)
+{
+       for(unsigned i=0; i<n; ++i)
+       {
+               SetForScope<float> set_base(base_beat, base_beat+b+i*d);
+               load_sub_with(*this);
+       }
+}
+
 void Sequencer::Loader::segment(float start, float end)
 {
        SegmentLoader ldr(obj, base_beat+start, base_beat+end, demo);
index 1cd1ebc8f139bc9c1ad6b5af2d1e0bfa79da0615..d85b6f879c255db7ff352ef3f61869224ce3e235 100644 (file)
@@ -31,6 +31,7 @@ public:
                void base(float);
                void define_action(const std::string &);
                void instant(float);
+               void repeat(float, float, unsigned);
                void segment(float, float);
        };