Graphical Window Animation

version 3 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section 2 - I6 Animation Routines

    Include (-
    [ GraphicsUpdate;
    if (animation == 0) rtrue;
         if ((+ current frame +) > end_frame) { ! Final frame of animation reached
            switch (loop) {
            0: ! We're not looping through the animation, so end it
                InterruptAnimation();
            1: ! We're looping, so reset the current frame
                (+ current frame +) = repeat_frame;
            }
         }
    else {
    (+ current graphics drawing rule +)();
    (+ current frame +)++;
    }
    ];

    [ AnimateFigures L fps loop_op;
        start_frame = 1;
        end_frame = BlkValueRead(L, LIST_LENGTH_F);
        animation = 1;
        loop = loop_op;
        (+ current frame +) = start_frame;
        repeat_frame = start_frame;
        glk_request_timer_events(1000/fps);
    ];

    [ InterruptAnimation ;
        animation = 0;
        loop = 0;
        glk_request_timer_events(0);
    ];

    [ AnimEscDelay key ix;
        if (loop) rtrue;
        while (animation) {
            glk_request_char_event(gg_mainwin);
            glk_select(gg_event);
            ix = HandleGlkEvent(gg_event, 1, gg_arguments);
            if (ix >= 0 && gg_event-->0 == 2) {
                key = gg_event-->2;
                if (key == $fffffff8) {
                    InterruptAnimation();
                }
            }
        }
        glk_cancel_char_event(gg_mainwin);
    ];

    -)