Skip to content

Commit 1953fea

Browse files
committed
fix snake game controls + edit this page link
the pydata theme key bindings use arrow keys which conflicted with the example implementation
1 parent 232c128 commit 1953fea

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

docs/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"github_user": "idom-team",
111111
"github_repo": "idom",
112112
"github_version": "main",
113-
"doc_path": "docs",
113+
"doc_path": "docs/source",
114114
}
115115

116116
# Add any paths that contain custom static files (such as style sheets) here,

docs/source/content/examples.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Try typing in the text box and pressing 'Enter' 📋
3333
The Game Snake
3434
--------------
3535

36-
Click to start playing and use the arrow keys to move 🎮
36+
Click to start playing and use WASD to move 🎮
3737

3838
Slow internet may cause inconsistent frame pacing 😅
3939

docs/source/examples/snake_game.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ def GameView():
3434

3535

3636
class Direction(enum.Enum):
37-
ArrowUp = (0, -1)
38-
ArrowLeft = (-1, 0)
39-
ArrowDown = (0, 1)
40-
ArrowRight = (1, 0)
37+
w = (0, -1)
38+
a = (-1, 0)
39+
s = (0, 1)
40+
d = (1, 0)
4141

4242

4343
@idom.element
4444
def GameLoop(grid_size, block_scale, set_game_state):
4545
# we `use_ref` here to capture the latest direction press without any delay
46-
direction = idom.hooks.use_ref(Direction.ArrowRight.value)
46+
direction = idom.hooks.use_ref(Direction.d.value)
4747

4848
snake, set_snake = idom.hooks.use_state([(grid_size // 2 - 1, grid_size // 2 - 1)])
4949
food, set_food = use_snake_food(grid_size, snake)

0 commit comments

Comments
 (0)