About Lesson
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 right -
set 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.