Exercise 1 · Chapter: One Moving DotRequired+50 XP
It Moves
Time to make something actually move.
Write both functions:
updateadds1tostate["x"]every framedrawpaints a red square at row6, columnstate["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