100 Scratch Coding Recipes & Reusable Mechanics
📌 What you will learn
Copy-and-learn single-mechanic recipes for platformer physics, UI bars, clones, audio, lists, save codes, and visual polish.
Browse all 100 Scratch recipes
Pick the exact mechanic your current project needs and test it in 5 minutes.
Scratch Recipe: Smooth 4-Direction Walking Use change x/y inside a single forever loop with separate if checks for crisp diagonal movement. Learn more → Scratch Recipe: Icy Momentum & Friction Add acceleration to x_vel on key press and multiply x_vel by 0.85 each frame. Learn more → Scratch Recipe: Quick Dash with Cooldown Trigger a 6-frame high-speed burst and lock re-triggering via timer + cooldown. Learn more → Scratch Recipe: Platformer Coyote Time Track frames_since_ground and allow jumping while frames_since_ground < 5. Learn more → Scratch Recipe: Platformer Jump Buffering Remember a jump press for 5 frames so pressing slightly before landing still jumps. Learn more → Scratch Recipe: Hold-to-Jump-Higher Control Cut upward y_vel in half when the jump key is released early. Learn more → Scratch Recipe: Jump-Through One-Way Platforms Collide with the platform top only when y_vel <= 0 and player feet were above it. Learn more → Scratch Recipe: Bouncy Spring Pad Boost Set y_vel to +18 and play a boing sound whenever touching a spring sprite. Learn more → Scratch Recipe: Moving Conveyor Belt Floor Add +3 or -3 to player x whenever standing on a conveyor sprite. Learn more → Scratch Recipe: Underwater Gravity & Swim Reduce gravity to -0.3 and cap fall speed to -4 while touching water. Learn more → Scratch Recipe: Climbable Ladder Mechanic Disable gravity while touching a ladder and move vertically with Up/Down arrows. Learn more → Scratch Recipe: Directional Hit Knockback Push the player away from enemy x_position and add a small upward hop on damage. Learn more → Scratch Recipe: Arcade Screen Edge Wrapping Teleport x from +240 to -240 (and vice versa) like classic space arcade games. Learn more → Scratch Recipe: Keep Sprite Inside Stage Bounds Clamp x between -220 and 220 and y between -160 and 160 every frame. Learn more → Scratch Recipe: Smooth Angle Turning Toward Target Compute shortest signed angle difference and turn by a fraction each frame. Learn more → Scratch Recipe: Elastic Mouse Pointer Follow Change x by (mouse x - x)/6 and y by (mouse y - y)/6 for silky trailing. Learn more → Scratch Recipe: Orbit One Sprite Around Another Set x = center_x + r*sin(angle) and y = center_y + r*cos(angle). Learn more → Scratch Recipe: Gentle Floating Pickup Bob Offset y by sin(timer * 220) * 8 to make coins and power-ups look alive. Learn more → Scratch Recipe: Button Hover Scale Pop Ease size toward 112% when touching mouse-pointer and back toward 100% otherwise. Learn more → Scratch Recipe: Tactile Click Squash & Stretch Shrink briefly to 90% on mouse down and spring back to 105% → 100%. Learn more → Scratch Recipe: Smooth Scene Fade-In Cover stage with a black sprite at ghost 0 and change ghost by +10 ten times. Learn more → Scratch Recipe: Smooth Scene Fade-Out Bring a black overlay to front layer at ghost 100 and change ghost by -10 ten times. Learn more → Scratch Recipe: Camera Screen Shake Effect Set shake_power = 10 on impact and offset camera by random(-shake..shake) while multiplying by 0.8. Learn more → Scratch Recipe: White Damage Hit Flash Set brightness effect to 60 for 0.08s then reset to 0 on enemy hit. Learn more → Scratch Recipe: Speed Dash Afterimage Trail Clone the sprite every 2 frames, set ghost to 40, fade out over 8 frames, and delete. Learn more → Scratch Recipe: Landing Dust Puff Particles Spawn 4 tiny circle clones moving outward and fading when touching ground. Learn more → Scratch Recipe: Floating "+10" Score Popup Clone a score label at coin position, float up 20px while fading ghost, then delete. Learn more → Scratch Recipe: Smooth Pen Health Bar Draw a dark background bar then a colored foreground bar of width (hp/max_hp * 80). Learn more → Scratch Recipe: Full-Width Boss Health Bar Anchor a 360px Pen bar across the bottom of the stage with live phase markers. Learn more → Scratch Recipe: Cloned Heart Life Icons Spawn max_lives heart clones spaced 28px apart and switch costumes for empty hearts. Learn more → Scratch Recipe: MM:SS Countdown Formatter Compute mins = floor(t/60), secs = t mod 60, and pad single digits with "0". Learn more → Scratch Recipe: 0.1-Second Race Stopwatch Format elapsed time with round(timer * 10) / 10 for crisp tenths of a second. Learn more → Scratch Recipe: Visual Ability Cooldown Bar Draw remaining cooldown fraction using max(0, (ready_time - timer) / duration). Learn more → Scratch Recipe: Letter-by-Letter Typewriter Text Append letter i of sentence into display_text inside a repeat loop. Learn more → Scratch Recipe: Press Space to Skip Typewriter Break out of the letter loop early if Space is pressed, showing the full sentence. Learn more → Scratch Recipe: Retro Character Voice Blips Play a tiny pitched Pop sound every 2 characters during typewriter dialogue. Learn more → Scratch Recipe: Smooth Music Fade-Out Loop 10 times: change volume by -10, wait 0.1s, then stop all sounds. Learn more → Scratch Recipe: Rising Pitch Combo Sound Increase pitch effect by +10 on each rapid pickup and clear effects after 1.5s idle. Learn more → Scratch Recipe: One-Click Mute Audio Button Toggle a global "muted" flag (0/1) and set volume to 0% or 100% on broadcast. Learn more → Scratch Recipe: Assign Unique Local Clone IDs Increment a global counter, copy into local clone_id right before "create clone". Learn more → Scratch Recipe: Prevent Clones From Cloning Check "if <(is_clone) = (0)> then" before creating clones on a broadcast. Learn more → Scratch Recipe: Reliable Bullet-Hits-Enemy Cleanup Wait 0 seconds before deleting a bullet clone so the enemy detects the hit first. Learn more → Scratch Recipe: 3-Way Spread Shot Pattern Spawn 3 bullet clones at direction -15°, 0°, and +15° from the player. Learn more → Scratch Recipe: 3-Round Burst Weapon Repeat 3 times (create clone, wait 0.08s), then wait 0.4s cooldown. Learn more → Scratch Recipe: Smooth Homing Projectile Compute angle toward target and rotate by at most 4 degrees per frame. Learn more → Scratch Recipe: Returning Boomerang Throw Launch forward with decelerating velocity until it reverses and returns to Player. Learn more → Scratch Recipe: Orbiting Defensive Shield Keep 3 shield clones rotating evenly at 0°, 120°, and 240° around the player. Learn more → Scratch Recipe: Coin Magnet Power-Up Pull coin clones within distance < 140 smoothly toward the player’s position. Learn more → Scratch Recipe: Edge-Aware Platform Patrol Turn around whenever touching a wall or when a floor-probe below finds empty air. Learn more → Scratch Recipe: Distance-Triggered Enemy Chase Switch from calm patrol to chase only when distance to Player < 150. Learn more → Scratch Recipe: Simple Line-of-Sight Check Step a tiny invisible sensor toward the player; if it hits a wall first, stay hidden. Learn more → Scratch Recipe: Half-HP Boss Phase Transition Trigger faster attacks and a red flash once boss_hp < (boss_max_hp / 2). Learn more → Scratch Recipe: Spawn Enemies Outside Edges Pick a random edge (left/right/top/bottom) and place new enemy clones at ±235 / ±175. Learn more → Scratch Recipe: Prevent Spawning on Player Repeat random coordinates until distance to Player > 100 before showing enemy. Learn more → Scratch Recipe: Weighted Rarity Loot Table Roll 1–100: 1–65 Common, 66–90 Rare, 91–100 Epic. Learn more → Scratch Recipe: Non-Repeating Deck Draw Pick random 1..length of deck, read item, then delete that index. Learn more → Scratch Recipe: In-Place List Shuffle Loop i from 1 to length and swap item i with item (random 1..length). Learn more → Scratch Recipe: Sum All Numbers in a List Loop i from 1 to length adding item i into a total variable. Learn more → Scratch Recipe: Average of a Score List Compute total with a loop, then divide by length of list (if length > 0). Learn more → Scratch Recipe: Find Maximum Value in a List Initialize max = item 1 of list, then compare every remaining item. Learn more → Scratch Recipe: Find Minimum Value in a List Initialize min = item 1 of list, then update whenever item i < min. Learn more → Scratch Recipe: Filter Matching Items Into New List Loop through source list and append items meeting a condition to result list. Learn more → Scratch Recipe: Remove Duplicate List Entries Append item i to clean_list only if not <clean_list contains item i>. Learn more → Scratch Recipe: Convert 2D (Row, Col) to 1D List Index Use index = ((row - 1) * width) + col to store 2D maps in a Scratch list. Learn more → Scratch Recipe: Snap Sprite to Tile Grid Set x to round(x / 32) * 32 and y to round(y / 32) * 32. Learn more → Scratch Recipe: Split Delimited Save Code String Loop through letters accumulating into a buffer until hitting "|" separator. Learn more → Scratch Recipe: Reverse Any Text String Loop backward from length down to 1 joining each letter onto reversed. Learn more → Scratch Recipe: Zero-Pad Numbers (0042) Repeat until length of str = 4: set str to join("0", str). Learn more → Scratch Recipe: Format Large Scores (12,500) Insert commas every 3 digits from right to left for clean clicker HUDs. Learn more → Scratch Recipe: Abbreviate Clicker Numbers (1.5K / 2.3M) Divide by 1000 or 1000000 and append K or M for readable huge scores. Learn more → Scratch Recipe: Copyable Save Code List Box Put the generated save code in a 1-item list and show it so players can triple-click copy. Learn more → Scratch Recipe: Validate Loaded Save Codes Check expected field count and numeric ranges before applying loaded values. Learn more → Scratch Recipe: Mobile/Tablet On-Screen D-Pad Create 4 translucent arrow buttons checking mouse down and touching mouse-pointer. Learn more → Scratch Recipe: Touch Virtual Joystick Control Clamp knob within radius 35 of base and output normalized x/y steering. Learn more → Scratch Recipe: Single-Trigger Key Press Guard Run action once then wait until <not <key pressed?>> to stop hold-spam. Learn more → Scratch Recipe: Detect Double-Tap Sprint Key Record timestamp of first tap; if second tap occurs within 0.25s, activate sprint. Learn more → Scratch Recipe: Secret Cheat Code Sequence Detector Track progress index in a key sequence list; reset to 1 on wrong key. Learn more → Scratch Recipe: Smooth Day/Night Lighting Cycle Adjust sky backdrop brightness smoothly with sin(timer * 10). Learn more → Scratch Recipe: Layered Diagonal Rain Effect Clone thin angled lines scrolling down-left at two depths. Learn more → Scratch Recipe: Gentle Swaying Snowflakes Move y by -2 and x by sin(timer * 100 + clone_id * 30). Learn more → Scratch Recipe: 3D Starfield Warp Effect Expand star clones radially from (0, 0) while increasing speed and size. Learn more → Scratch Recipe: Fast Pen Filled Circle Set pen size to diameter, pen down, pen up—draws a crisp circle in 1 step! Learn more → Scratch Recipe: Pen Rounded UI Panel Draw a thick horizontal stroke with rounded pen caps for clean dialog panels. Learn more → Scratch Recipe: Draw Coordinate Grid with Pen Loop vertical lines every 40px and horizontal lines every 40px without refresh. Learn more → Scratch Recipe: Live Pen Bar Chart from List Draw vertical strokes spaced evenly with height proportional to list values. Learn more → Scratch Recipe: Stamped Multi-Digit Score Counter Loop through each digit of score, switch to matching costume, stamp, and shift x. Learn more → Scratch Recipe: Top-Down Depth Sorting by Y Send sprites with higher y further back so characters walk cleanly behind trees. Learn more → Scratch Recipe: Corner Minimap Player & Enemy Dots Scale world coordinates by 0.15 and stamp tiny colored dots in the corner. Learn more → Scratch Recipe: Level Checkpoint Respawn System Save checkpoint_x and checkpoint_y when touching a flag; respawn there on hazard hit. Learn more → Scratch Recipe: Smooth Room-to-Room Transition Fade out, switch room_id, place player at matching entrance, and fade in. Learn more → Scratch Recipe: Zelda-Style Room Camera Snap When x > 235, increment room_x, snap player to x = -225, and redraw room. Learn more → Scratch Recipe: Clean Turn-Based Battle Loop Alternate Player Turn and Enemy Turn with broadcast-and-wait blocks. Learn more → Scratch Recipe: Critical Hit Chance & Feedback Roll 1–10; on 10, double damage, flash yellow, and show "CRIT!" popup. Learn more → Scratch Recipe: One-Time Purchase Shop Item Track bought items in a list and switch button costume to "Sold Out". Learn more → Scratch Recipe: Slide-In Achievement Banner Queue unlocked badges in a list and glide a notification banner down for 2.5s. Learn more → Scratch Recipe: Movie-Style Scrolling Credits Start credits sprite at y = -200 and glide smoothly upward past y = 240. Learn more → Scratch Recipe: Zero-Bug Replay Button Broadcast "Reset All" and wait before broadcasting "Start Game" without refresh. Learn more → Scratch Recipe: Live FPS Counter Snippet Compute 1 / ((days since 2000 - last_day) * 86400) inside a forever loop. Learn more → Scratch Recipe: Delta-Time Speed Scaling Multiply movement speed by (dt * 30) so physics matches across 30 and 60 FPS. Learn more → Scratch Recipe: Safe Cloud High Score Updater Check <(score) > (☁ High Score)> only once at Game Over before writing. Learn more →
This guide is provided for educational purposes. Scratch screens and terms may change over time, so please check the official Scratch website as well.