Exerpad
🔥 0
0 XP
Exercise 1 · Chapter: One Moving DotRequired+50 XP

It Moves

Time to make something actually move.

Write both functions:

  • update adds 1 to state["x"] every frame
  • draw paints a red square at row 6, column state["x"]

Run it. The dot slides across the sky.

You wrote both halves of an animation: numbers that change, and a picture made from them. Everything else in this milestone is a bigger version of this.

Expected output
........................................
........................................
........................................
........................................
........................................
........................................
.A......................................
........................................
........................................
........................................
........................................
........................................
........................................
########################################
........................................
........................................
........................................
........................................
........................................
........................................
..A.....................................
........................................
........................................
........................................
........................................
........................................
........................................
########################################
........................................
........................................
........................................
........................................
........................................
........................................
...A....................................
........................................
........................................
........................................
........................................
........................................
........................................
########################################
Need a hint?
3 available · costs 5 XP each
python
def update(state, keys):
# Add 1 to state["x"] so the dot moves right.
return state


def draw(state):
grid = blank_grid()
# Paint a red square at row 6, column state["x"].
return grid