# Animate — Animated bitmaps

This program requires five bitmap files — `one.pic` to `five.pic`. Each of these would differ slightly. They might, for example, be five ‘snapshots’ of a running human figure, each with the legs at a different point in their cycle.

The program copies each bitmap into a window of its own, then makes each window visible in turn, each time slightly further across the screen.

To make bitmap files, first draw the pattern you want with any of the graphics drawing commands. (Use `gLINEBY 0,0` to draw single dots.) When the pattern is complete, use `gSAVEBIT` to make the bitmap file. For advanced animation, you could use a sprite as described in About OPXs.

        PROC animate:
              LOCAL id%(5),i%,j%,s$(5,10),w%,h%,edge%
              REM example width and height
              w%=16 :h%=28
              edge%=gWIDTH                    REM screen edge
              s$(1)="one.pic" :s$(2)="two.pic" :s$(3)="three.pic"
              s$(4)="four.pic" :s$(5)="five.pic" :j%=1
              WHILE j%<6
                    i%=gLOADBIT(s$(j%))
                    id%(j%)=gCREATE(0,0,w%,h%,0)
                    gCOPY i%,0,0,w%,h%,3
                    gCLOSE i% :j%=j%+1
              ENDWH
              i%=0 :gORDER 1,9
              DO
                    j%=(i%-5*(i%/5))+1                  REM (i% MOD 5)+1
                    gVISIBLE OFF                        REM previous window
                    gUSE id%(j%)                        REM new window
                    gSETWIN i%,20                        REM position it
                    gORDER id%(j%),1                  REM make foreground
                    gVISIBLE ON                        REM make visible
                    i%=i%+1 :PAUSE 2
              UNTIL KEY OR (i%>(edge%-w%))
        ENDP