<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<br><div><div>On Feb 2, 2011, at 7:20 AM, I wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">There are a number of other things that would simplify the code, some of which would also make things (slightly) more efficient.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Your sprite switches between its two images every 10 clock-ticks, where a clock-tick defaults to 1/28 second.<span class="Apple-converted-space"> </span>Instead, just set the tick interval to what you want, and skip the 0.1 and the rounding.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">(big-bang ...</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-converted-space"> </span>(on-tick tick (/ 1 2.8)) <span class="Apple-converted-space"> </span>; or (on-tick tick 1/3) or (on-tick tick .382) or whatever</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-converted-space"> </span>... )</div></blockquote><div><br></div>On second thought, this may help more than I thought: every clock-tick requires redrawing the screen, so doing one tenth as many clock ticks should significantly reduce the delay and flicker.</div><div><br><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">And since there are only two possible images in the world, I would probably use a boolean or a pair of symbols or strings to choose between them:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">...</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">(Symbols or booleans would be slightly more efficient, but I introduce strings much earlier in my course than symbols or booleans.)</div></blockquote><div><br></div>Obviously, you're using booleans already, so you could make this simpler and more efficient by saying</div><div><br></div><div>(define-struct world (pos mouse-pos fred?))</div><div>(define initial-world (make-world CENTER CENTER true))</div><div>...</div><div>(define (sprite-image w)</div><div> (if (world-fred? w) pic1 pic2)))</div><div>(define (draw w)</div><div> (place-image</div><div> (rotate (angle-between (world-pos w) (world-mouse-pos w))</div><div> (sprite-image w))</div><div> (posn-x (world-pos w)) (posn-y (world-pos w))</div><div> BACKGROUND)))</div><div><br></div><div>(define (tick w)</div><div> (make-world</div><div> (world-pos w)</div><div> (world-mouse-pos w)</div><div> (not (world-fred? w))))</div><div><br></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div>Stephen Bloch</div><div><a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a></div><div><br class="webkit-block-placeholder"></div></span><br class="Apple-interchange-newline"> </div><br></body></html>