Annotation of researchv9/jtools/src/demo/bounce.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * b.c - new bouncing line
        !             3:  */
        !             4: 
        !             5: #include <jerq.h>
        !             6: #define N 25
        !             7: Point foo[] = {
        !             8:        312, 799,
        !             9:        650, 650,
        !            10:        7, -11
        !            11:        -5, 3,
        !            12:        13, 7,
        !            13:        3, 11,
        !            14: };
        !            15: 
        !            16: main(argc, argv)
        !            17: char *argv[];
        !            18: {
        !            19:        register i = 0, j;
        !            20:        Point from[N], to[N];
        !            21:        Point dfrom, dto;
        !            22:        request(KBD);
        !            23:        initdisplay(argc, argv);
        !            24:        rectf(&display, Drect, F_XOR);
        !            25:        for(j=0; j<N; j++){
        !            26:                from[j] = Drect.origin;
        !            27:                to[j] = Drect.origin;
        !            28:        }
        !            29: /*     from[0] = foo[0];
        !            30:        from[1] = foo[0];
        !            31:        to[0] = foo[1];
        !            32:        to[1] = foo[1];*/
        !            33:        dfrom = foo[2];
        !            34:        dto = foo[3];
        !            35:        for (; kbdchar()==-1; wait(CPU)){
        !            36:                j = i;
        !            37:                if (++i >= N)
        !            38:                        i = 0;
        !            39:                segment(&display, from[i], to[i], F_XOR);
        !            40:                from[i] = from[j];
        !            41:                bump(&from[i], &dfrom);
        !            42:                to[i] = to[j];
        !            43:                bump(&to[i], &dto);
        !            44:                segment(&display, from[i], to[i], F_XOR);
        !            45:        }
        !            46:        exit();
        !            47: }
        !            48: 
        !            49: bump(p,dp)
        !            50: register Point *p, *dp;
        !            51: {
        !            52:        if ((p->x += dp->x) > Drect.corner.x || p->x < Drect.origin.x) {
        !            53:                dp->x = -dp->x;
        !            54:                p->x += dp->x << 1;
        !            55:        }
        !            56:        if ((p->y += dp->y) > Drect.corner.y || p->y < Drect.origin.y) {
        !            57:                dp->y = -dp->y;
        !            58:                p->y += dp->y << 1;
        !            59:        }
        !            60: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.