~aritra1911/ansi_anim

8243b8721f7d07923a72e6ed66541c1f332f0874 — Aritra Sarkar 2 years ago 15b2358
Make a rect jump up & down
1 files changed, 16 insertions(+), 1 deletions(-)

M src/main.c
M src/main.c => src/main.c +16 -1
@@ 82,9 82,24 @@ int main(void)
    }
    move_cursor(orig_cursor_pos);

    dir_t dir = DOWN;

    while ( 1 ) {
        /* Read a byte from the standard input */
        while ( read(STDIN_FILENO, &c, 1) < 1 );
        while ( read(STDIN_FILENO, &c, 1) < 1 ) {

            if ( rects[2].origin.y + rects[2].height > screen_size.y ) {
                dir = UP;
            } else if ( rects[2].origin.y <= 1 ) {
                dir = DOWN;
            }

            orig_cursor_pos = get_cursor_pos();
            erase(&rects[2]);
            nudge(&rects[2], dir, 4);
            draw(&rects[2]);
            move_cursor(orig_cursor_pos);
        }

        if ( !iscntrl(c) ) {
            if ( c == 'q' ) break;