Interactive · Gutenberg
Snake Game block for WordPress
Classic Snake game playable in the browser. Keyboard and on-screen touch controls, high-score tracking, multiple speed levels and color themes.
Get Blockenberg
Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.
What it actually does
Classic Snake game playable in the browser. Keyboard and on-screen touch controls, high-score tracking, multiple speed levels and color themes.
Inspector panels on this block: Content, Game Settings. Those titles come from index.js, not from a shared template.
Behavior controls: “Default Speed” options: Slow, Medium, Fast, Insane.
Where to find it
Gutenberg inserter → Interactive → search “Snake Game” (block name `blockenberg/snake-game` in block.json). Style it in the sidebar after insert.
How to use Snake Game block for WordPress
- Install Blockenberg. Install from WordPress.org and activate the plugin.
- Insert the block. Edit a page, click +, search for “Snake Game”, insert it. Category: Interactive.
- Configure inspector controls that exist on this block. Open Content. Set “Grid Size (cells)”, “Canvas Size (px)”, “Default Speed”, “Wall Kills Snake”.
- Check the published page. The view script reads HTML data attributes: data-opts. The block editor preview may not run the same view script.
Inspector controls from this block’s code
| Control | What the code does |
|---|---|
| Grid Size (cells) | Numeric range control in the inspector. Range 10–30. block.json default: 20. Saved as `gridSize`. |
| Canvas Size (px) | Numeric range control in the inspector. Range 280–600. block.json default: 400. Saved as `canvasSize`. |
| Default Speed | Select control; the chosen value is saved on the block. Options: Slow; Medium; Fast; Insane. block.json default: medium. Saved as `defaultSpeed`. |
| Wall Kills Snake | On/off toggle in the inspector. Off by default. Saved as `wallsKill`. |
| Show High Score | On/off toggle in the inspector. On by default. Saved as `showHighScore`. |
| Show Touch Controls | On/off toggle in the inspector. On by default. Saved as `showControls`. |
| Typography — Title | Shared Blockenberg typography popover (family, size, weight, spacing). Saved as `titleTypo`. |
| Subtitle | Shared Blockenberg typography popover (family, size, weight, spacing). Saved as `subtitleTypo`. |
| Snake Body | Color control in the inspector. block.json default: #22c55e. Saved as `snakeColor`. |
| Snake Head | Color control in the inspector. block.json default: #16a34a. Saved as `snakeHeadColor`. |
| Food | Color control in the inspector. block.json default: #ef4444. Saved as `foodColor`. |
| Grid Lines | Color control in the inspector. block.json default: #f3f4f6. Saved as `gridColor`. |
| Board Background | Color control in the inspector. block.json default: #ffffff. Saved as `boardBg`. |
| Section Background | Color control in the inspector. block.json default: #f0fdf4. Saved as `sectionBg`. |
| Accent Color | Color control in the inspector. block.json default: #22c55e. Saved as `accentColor`. |
| Title Color | Color control in the inspector. block.json default: #14532d. Saved as `titleColor`. |
What the front-end script actually does
- The view script reads HTML data attributes: data-opts.
- It writes to localStorage in the visitor’s browser, not to wp_options.
- Drawing happens on a canvas element after the page loads.
- Keyboard handlers move focus between items.
- JavaScript functions that perform the math: updateScoreUI.
When this is the right block
- Classic Snake game playable in the browser. Keyboard and on-screen touch controls, high-score tracking, multiple speed levels and color themes — that is the job of Snake Game, not a generic content block.
- Use it when you need the editor control labeled “Grid Size (cells)”, which exists on this block’s inspector.
- It matches pages about snake, game, arcade.
- The math runs in the visitor’s browser after publish — no extra calculator plugin.
Notes from the implementation
viewScript: this folder’s frontend.js is enqueued on the front end for this block.
FAQ
How do I add the Snake Game block in WordPress?
Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “Snake Game”. It sits under Interactive. After insert, open Content and set “Grid Size (cells)”, “Canvas Size (px)”, “Default Speed”, “Wall Kills Snake”.
Does Snake Game need a server or extra plugin?
No. After Blockenberg is active, the view script runs in the browser with the values you saved on the block.
Is the Snake Game Gutenberg block free?
Yes. Snake Game ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.
Can I style Snake Game to match my theme?
Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Content, Game Settings).
Related interactive blocks
Bingo Card
Interactive 5×5 Bingo card with number calling, win detection, and celebration animations.
Tetris Game
A fully playable Tetris game block. Supports keyboard and on-screen controls, levels, score, and rich style customization.
Tic-Tac-Toe
Playable Tic-Tac-Toe game with AI opponent, score tracking, custom symbols, and multiple difficulty modes.
Trivia Game
A timed multiple-choice trivia game with built-in questions across Science, History, Geography, and Pop Culture categories.
2048 Game
The classic sliding-tile 2048 puzzle. Swipe or use arrow keys to merge tiles and reach the 2048 tile.
Dice Roller
Interactive dice roller supporting d4, d6, d8, d10, d12, d20 and d100. Roll multiple dice, see individual results, totals, and past roll history.
Get Blockenberg
Install Blockenberg from WordPress.org, then insert Snake Game from the Gutenberg inserter.