window.button_down? Gosu::KbLeft self.x -= SPEED elsif window.button_down? Gosu::KbRight self.x += SPEED end if window.button_down? Gosu::KbUp self.y -= SPEED elsif window.button_down? Gosu::KbDown self.y += SPEED end end end Let’s get moving!
runs somewhere randomly” • Cat doesn’t teleport, cat does have to travel through space between origin and destination • Break movement into discrete frames
use the magnitude of the move and the cat speed to figure out how many frames the move should take. From that, we take the angle of the move, calculate the cosine and sine of the angle, and multiply those values by the speed to figure out how much we should move per frame in both axes