EDGEDETECT(current, position, size, outer, inner=0) = IIF(position <= inner, 1, IIF((position+size) >= outer, -1, current)) ~; current must be +/-1, returns current if not at edge~
3. Draw Shape = pixactive(1),~a.(v2), b.(v3), ; save current direction flags~v2.(edgedetect(v2, v0, 40, 320)), ; get new X direction flag~v3.(edgedetect(v3, v1, 40, 240)), ; get new Y direction flag~v0.(v0+(v2*IN1)), v1.(v1+(v3*IN2)), ; calculate new position~PixShape(v0, v1, 40, 40, 9001,1), ; draw the shape~out( iif( a==v2, 0, 1) + iif( b==v3, 0, 2)) ; output flags if direction changed
4.
5. Initialize = pixactive(2), pixsize(320,240), PixOn,~V0.(ran*160), V1.(ran*120), ; initialize starting X, Y~v2.(1), v3.(1), ; initialize direction flags~PixShapeSet(1, 0, 1, rgb(255,128,0)), ; set up border & color~PixFillStyle(0), PixDrawMode(1), ; set up blackness to erase~TxtLabel("Overwrite Animation")~goto(me+1)
6. Draw Shape = pixactive(2),~PixAutoRepaint(0), ; turn off repaint to avoid flicker~a.(v2), b.(v3), ; save current direction flags~v2.(edgedetect(v2, v0, 40, 320)), ; get new X direction flag~v3.(edgedetect(v3, v1, 40, 240)), ; get new Y direction flag~PixRect(v0, v1, 40, 40),~v0.(v0+(v2*IN1)), v1.(v1+(v3*IN2)), ; calculate new position~PixShape(v0, v1, 40, 40, 9001), ; draw the shape~PixRepaint, PixAutoRepaint(1), ; show the new image; restore auto repaint~out( iif( a==v2, 0, 1) + iif( b==v3, 0, 2)) ; output flags if direction changed
9. Draw Shape = pixactive(3), PixAutoRepaint(0),~a.(v2), b.(v3), ; save current direction ~v2.(edgedetect(v2, v0, 40, PixFrameWidth)), ; get new X direction flag~v3.(edgedetect(v3, v1, 40, PixFrameHeight)), ; get new Y direction flag~PixCombine(4,, v0, v1, 40, 40, v0, v1),~v0.(v0+(v2*IN1)), v1.(v1+(v3*IN2)), ; calculate new position~PixShape(v0, v1, 40, 40, 9001), ; draw the shape~PixRepaint, PixAutoRepaint(1),~out( iif( a==v2, 0, 1) + iif( b==v3, 0, 2)) ; output flags if direction changed