In order to create animations where images can interact with each other, we need to understand how to move images and to test where images are in relation to each other. In this activity you will explore animation velocity and graphical conditionals.
For each of the following questions, specify which direction the image will move:
for i in range(100): x += 10 y += 10 graphics.clear() graphics.draw_image('image.gif', x, y)
for i in range(100): x += 6 y -= 8 graphics.clear() graphics.draw_image('image.gif', x, y)
for i in range(100): x -= 4 y += 3 graphics.clear() graphics.draw_image('image.gif', x, y)
for i in range(100): x -= 1 y -= 2 graphics.clear() graphics.draw_image('image.gif', x, y)
Consider the following code:
for i in range(1000): x += delta_x y += delta_y if x > window_width: delta_x = 0 delta_y = 0 if x < 0: x = window_width / 2 y = window_height / 2 if y > window_height: delta_y *= -1 if y < 0: y = window_height graphics.clear() graphics.draw_image('image.gif', x, y)