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

Falling

Now drop something.

  • update adds 1 to state["y"] each frame
  • draw paints a blue square at row state["y"], column 20

Notice what changed from the last exercise: the moving number is now the first index instead of the second. That is the entire difference between sideways and downwards.

Bigger y means further down, because row 0 is the top of the picture. This trips up nearly everyone once.

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


def draw(state):
grid = blank_grid()
# Paint a blue square at row state["y"], column 20.
return grid