Theory
🐱 5. Home Run Hitter
Let’s use your new skills to help a baseball player hit the ball across the field! We’ll combine what we’ve learned about costumes, backdrops, and sound tools to get really creative.
Step1:
🎮🧢 Create new program and add Batter and Baseball sprites 🏟️👧⚾️. Use Baseball 2 backdrop from library 🖼️. Position batter next to home plate and place baseball on left of screen as if it’s been pitched. ⚾🏠
Step2:
Let’s start with the code for your baseball. Click on the little thumbnail image of the baseball underneath the stage to bring up its script editor. Notice that there is now a baseball icon in the script editor as well. This means that any code you place is affecting that sprite.
Step3:
🚩👁️🗨️ art with when flag clicked event block to activate script. Then add show looks block for baseball visibility. Adjust size to 50% with set size to () % looks block and position with go to x: () y: (__) motion block. ⚾️🏃♂️👀
Step4:
🖱️🏃♂️ Drag baseball near batter, leaving space in front of bat. Then, use glide () secs to x: () y: () motion block to move it to left as if hit a home run. Add another glide () secs to x: () y: () motion block and hide looks block for ball to disappear, giving illusion of flying off into distance! ⚾️🏃♂️🚀
Step5:
🖱️👩🦰 Click batter’s thumbnail, switch to script editor. Go to Costumes tab, pick different costumes to show bat swinging motion. Start script with when flag clicked event block, add wait (0.5) seconds control block. Then, switch costume to (__) looks block for each position, adding wait (0.2) seconds between changes for smooth animation. Experiment with timing and motion coordinates until it feels right! 🏏🕰️
Step6: Code Complete
🔊🎾 First, go to Sounds tab, choose “Tennis Hit” from the sound library. Then, switch to Code tab, add start sound (__) block to batter’s script after switching to batter-c costume. Now, she’ll make a satisfying “crack” sound when her bat touches the ball! 🦇💥