MODULE update; (* Bouncing ball demo: per-frame state updates on the tigr real-time window. *) FROM tigr IMPORT TigrPtr, tigrWindow, tigrFree, tigrClosed, tigrClear, tigrUpdate, TPixelType, tigrFillCircle, TK_ESCAPE, tigrKeyDown; FROM helper IMPORT tigrRGB; VAR screen : TigrPtr; posx, posy : INTEGER; velx, vely : INTEGER; radius : INTEGER; w, h : CARDINAL; black, ball : TPixelType; BEGIN screen := tigrWindow(320, 240, "update", 0); posx := 160; posy := 120; velx := 3; vely := 2; radius := 20; black := tigrRGB(0, 0, 0); ball := tigrRGB(230, 60, 60); WHILE (NOT (tigrClosed(screen) > 0)) AND (NOT (tigrKeyDown(screen, TK_ESCAPE) > 0)) DO w := screen^.w; h := screen^.h; posx := posx + velx; posy := posy + vely; IF (posx - radius) <= 0 THEN posx := radius; velx := -velx; END; IF (posy - radius) <= 0 THEN posy := radius; vely := -vely; END; IF (posx + radius) >= INTEGER(w) THEN posx := INTEGER(w) - radius; velx := -velx; END; IF (posy + radius) >= INTEGER(h) THEN posy := INTEGER(h) - radius; vely := -vely; END; tigrClear(screen, black); tigrFillCircle(screen, posx, posy, radius, ball); tigrUpdate(screen); END; tigrFree(screen); END update.