Step 1: Understand the Stage Size
📏 Scratch stage is:
X-axis: from -240 (left) to 240 (right)
Y-axis: from -180 (bottom) to 180 (top)
Explain:
“If your player keeps going past these edges, they’ll disappear! We’ll write code to stop them.”
🧩 Method 1: Prevent From Going Offscreen (Simple)
if <x position > 230> then
set x to 230
end
if <x position < -230> then
set x to -230
end
–> Add these checks inside the forever
loop under the movement code.
Explanation for choosing position:
x position > 230
→ if a player is too far rightset x to 230
→ Move it back to the edge
Step 2: Use “if on edge, bounce” (Fun Visual Option)
This makes the sprite bounce back instead of going offstage—it works well for arcade-style games.