Articles, Blog

racket events video 1.9/4 — smoother events

December 3, 2019


Here’s where we left that rotating
barracuda. It’s flopping around in a very non-circular way. Let’s see if we can
fix that I want to rotate something that’s a bit more
circular. So I’ll basically glue the barracuda on top of the circle. I’ll call the whole thing a disk… better spell image properly. Now the model that the world keeps updating is gonna be a disk, instead
of a bar. Hmmm, that’s rotating more smoothly but too
quickly! let’s see… on tick by default goes twenty eight
times a second, let’s check every second… hmmm, now it’s
too slow: it’s moving one degree per second. This needs a more serious fix. First, I’ll calculate what the speed of the
second hand should be, it goes basically three hundred and sixty
degrees every sixty seconds. Now I need a function that rotates an
image one second’s worth of degrees. Here’s how I expect it to work. rotate-second might take DISK and then produce a new version of that
image rotated by… well, one second’s worth of degrees. here’s how i define it. I name the
function rotate-second, I have a placeholder called image, and now I say what I’m going to
do to that image. Whoops, some extra parentheses there… I’m gonna rotate SH-SPEED number of degrees that placeholder image. Now if i go down
two big-bang, Instead of using rotate-1 every second,
I’m going to use rotate second. Hmm: that’s the right speed, but you
know it’s going counter-clockwise — that’s weird. so, what I should do is… I want the
negative number of degrees basically. So, I multiply my speed by negative one. Much better. This looks like barracuda that could
function as a second hand. Ooops, there seems to have been a
problem. Wonder what that is? Scroll down… better scroll down some more… It says that it doesn’t match the actual value
with the… what I expected… Oh yeah! I was still expecting it to rotate the other way! So, in my check expect, I’ve got to multiply by negative one
also. there we go: it’s rotating in the right
direction at the rate speed… and all the tests pass!

No Comments

Leave a Reply