How to Make Earth Revolve Around the Sun in Scratch: A Complete Tutorial & Enhancements

How to Make Earth Revolve Around the Sun in Scratch Make Animation in Scratch Kodex Academy

Introduction: Make Earth Revolve Around the Sun in Scratch

Watch the full tutorial here – How to Make Earth Revolve Around the Sun in Scratch | Make Animation in Scratch | Kodex Academy

Animating Earth revolving around the Sun is a classic beginner/intermediate Scratch animation project. It combines trigonometry (sine & cosine), variables, loops, and visual scripting. Kids can learn how to use sin and cos blocks to compute X/Y positions based on an angle and radius, how to use pen tools to trace orbits, and how to add rotation, sound, and other effects.

This blog covers:

  • Step‑by‑step coding guide from the video
  • All possible scenarios and variants
  • Enhancement features with code
  • Best practices (SEO, usability)
  • External resources for further learning
  • Full example code (Scratch blocks style)

Core Concepts – Learn Before You Code!

Understanding the core concepts is key to successfully animating Earth’s revolution around the Sun in Scratch. This section explains what’s happening behind the scenes — so you’re not just copying code, but actually understanding how it works.

1. Sprites & Backdrop

Sprites are characters or objects in Scratch. For this project, you need:

  • Sun Sprite: Fixed in the center
  • Earth Sprite: Revolves around the Sun

Backdrop: Choose a space-themed background (like “Stars”) to simulate the solar system.

Tip: Resize Earth to ~50% for better visuals.

2. Trigonometric Functions: Sin and Cos

This is the magic behind the animation!

What Are sin() and cos() in Scratch?

Scratch includes math functions like sin, cos, tan, etc. These come from trigonometry, and help in calculating circular motion.

How Do They Work?

To simulate circular movement, you update an object’s X and Y positions like this:

  • X = Center X + radius × sin(angle)
  • Y = Center Y + radius × cos(angle)

Why Use Them?

Because they allow you to rotate a sprite smoothly around a center point — just like the Earth orbits the Sun!

Did you know? In Scratch, angles are in degrees, not radians. So sin(90) = 1, cos(0) = 1, etc.

3. Variables – Earth’s Motion Parameters

You’ll use variables to control the motion:

VariableTypePurpose
angleSprite-onlyTracks Earth’s current position in orbit
radiusSprite-onlyHow far Earth is from the Sun
speedSprite-onlyHow fast Earth moves (degrees per frame)
sun xGlobalX position of the Sun
sun yGlobalY position of the Sun

Read more about variables in Scratch: https://en.scratch-wiki.info/wiki/Variable

4. Loops & Animation Timing

To keep Earth moving smoothly, you’ll use the forever loop:

forever
   // update Earth's position using sin/cos
end

You can also add wait (0.05) seconds to control the animation speed.

5. Pen Tool – Drawing the Orbit

The Pen extension in Scratch allows sprites to draw lines as they move.

  • Use pen down to start drawing.
  • Use erase all at the beginning to clean old drawings.
  • Draw the orbit path to visualize Earth’s trajectory!

Learn more: Scratch Wiki – Pen Extension

6. Sound & Rotation

Add sound to make your project more fun and immersive!

  • Use looping sounds like “Xylo 3”
  • Use turn clockwise block to make the Earth rotate on its own axis

This helps simulate both rotation (Earth spinning) and revolution (orbiting the Sun).

7. Rotation Styles

Each sprite has a rotation style:

  • Don’t Rotate → Use for Sun (static)
  • All Around → Use for Earth (to spin it)

Set it in code:

set rotation style [all around v]

Make sure Earth rotates properly as it orbits!

8. Operators & Math Blocks

You’ll use operator blocks like:

  • + (Addition)
  • * (Multiplication)
  • sin, cos (Trigonometry functions)

These go inside the Motion > Go to x/y block to calculate real-time position changes.

go to x: (sun x + radius × sin(angle))
       y: (sun y + radius × cos(angle))

Learn more: Scratch Wiki – Operators

Summary of Core Concepts

ConceptDescription
Sprites & BackdropSun (fixed), Earth (rotating), starry space background
sin() & cos()For circular motion calculations
VariablesControl orbit parameters like angle, radius, speed
LoopsTo animate movement over time
Pen ToolTo draw the orbit path
Rotation StyleControls how sprites rotate visually
OperatorsNeeded for position calculations

How to Make Earth Revolve Around the Sun in Scratch: Step‑By‑Step Coding

Here’s how to recreate the project from the transcript with code sketches in Scratch blocks.

Setup

  • Delete the default cat sprite.
  • Choose a backdrop (e.g. Stars).
  • Add two sprites: Sun and Earth.
  • Resize Earth to about 50% or whatever size you like.

Sun Sprite Code

when green flag clicked
go to x: (0) y: (0)
set rotation style [don't rotate v]

This ensures the Sun stays fixed in the centre.

Earth Sprite: Variables

Create for Earth sprite only:

  • angle
  • radius
  • speed

Create for all sprites (or could be global variables):

  • sun x
  • sun y

Earth Sprite: Initialization

when green flag clicked
hide variable [angle v]
hide variable [radius v]
hide variable [speed v]
set [sun x v] to (0)
set [sun y v] to (0)
set [radius v] to (150)
set [speed v] to (1)   // degrees per tick
set [angle v] to (0)
set rotation style [all around v]

Also set Earth’s initial position if desired:

go to x: (something) y: (something)  // e.g. 88, 124 — optional starting offset

Earth Sprite: Orbit Movement

forever
    // compute new position
    set x to ((sun x) + (radius * (sin (angle))))
    set y to ((sun y) + (radius * (cos (angle))))
    change [angle v] by (speed)
    // option: rotate Earth sprite on its own axis
    turn cw (10) degrees   // or some value
    wait (0.05) secs       // to control speed visually
end

Drawing the Orbit with Pen

when green flag clicked
erase all
pen down
set pen color to [white v]    // or any color
forever
    // the same position update code as above
    go to x: ((sun x) + (radius * (sin (angle))))
    y: ((sun y) + (radius * (cos (angle))))
    change [angle v] by (speed)
    wait (0.05) secs
end

Adding Sound

when green flag clicked
forever
    play sound [Xylo 3 v] until done
end

Scenarios & Variants

These are additional scenarios you might want to try:

ScenarioWhat ChangesLearning Outcome
Earth rotates around Sun (circle)Standard use of sin and cos with fixed radiusUnderstand circular motion
Elliptical orbitUse different radii for x vs y component (e.g. radius_x and radius_y)Understand ellipse shapes
Multiple planetsAdd more sprites (Mercury, Venus, Mars…) with different radius, speed, sizeUnderstanding relative motion, scale, concurrency
Moons around planetsA moon sprite orbiting Earth which itself orbits SunHierarchical motion, nested orbits
Show graphs of sin and cosUse pen blocks to draw functions over angle vs outputConnect animation with math graphs
Phase shift / oscillationsStart angle at different initial values, or use cos/sin swappedLearn about phase shift in waves
Interactive controlLet user adjust speed and radius via slider or inputInteractivity, debugging, user input

Enhancement Features & Code Snippets

To make the project more engaging, you can add enhancements. Here are some with sample Scratch block‑style code.

  1. Variable UI Controls
    Let the user change speed or radius during runtime.
when [up arrow v] key pressed
change [radius v] by (10)
when [down arrow v] key pressed
change [radius v] by (-10)
when [right arrow v] key pressed
change [speed v] by (1)
when [left arrow v] key pressed
change [speed v] by (-1)

2. Multiple Planets with Different Speeds & Colors

For each planet sprite:

when green flag clicked
set [radius v] to (planet‑specific value)
set [speed v] to (planet‑specific speed)
set pen color to [color v]   // different color
// then orbit code as above

3. Elliptical Orbit

Use two radii: radius_x and radius_y:

set [radius_x v] to (150)
set [radius_y v] to (80)
forever
    set x to (sun x + (radius_x * sin(angle)))
    set y to (sun y + (radius_y * cos(angle)))
    change [angle v] by (speed)
    wait (0.05)
end

4. Background Stars Moving / Parallax Effect

To simulate depth: have multiple star sprites or backgrounds move slowly (or tween) as Earth orbits:

when green flag clicked
forever
    change y by (small amount)   // or change x
    wait (0.1)
end

Or switch costumes periodically for twinkling stars.

5. Day/Night Effect on Earth

Use two Earth costumes: one lit half, one dark half. Rotate or change brightness.

forever
    next costume
    wait (0.5)
end

6. Sound Variation

Instead of looping one sound, vary pitch or choose different sounds per planet orbit:

when green flag clicked
forever
    play sound [Xylo 3 v] until done
    wait (1 second)
    play sound [Bell v] until done
    wait (1 second)
end

7. Reset / Pause Controls

when [space v] key pressed
stop [all v]   // pause or stop motion

Or custom pause logic by using a variable like paused? and checking inside forever loops.

Putting It All Together

  1. Watch the video to see the final effect & follow along. (YouTube Link)
  2. Set up your Scratch project: backdrop, sprites.
  3. Create variables.
  4. Write initialization code (Sun at center, Earth radius etc.).
  5. Write orbit & rotation code (using sin, cos, loops).
  6. Add pen drawing, sound, and interactive controls for enhancements.
  7. Test, adjust speed/radius to your taste.
  8. Share it with friends or on Scratch.

Possible Troubleshooting

  • Earth moves too fast / too slow → adjust speed or add a wait block.
  • Orbit looks like line or ellipse unintentionally → ensure you use both sin(angle) and cos(angle) properly; if only one is varied, motion will collapse into a line.
  • Pen tool draws weird shapes → ensure erase all is used at start, pen down before loop, and pen color/size set.
  • Rotation style: If Earth’s sprite rotates weirdly (spins), you need to set rotation style “all around” for Earth; for Sun, set “don’t rotate” if you want it fixed.
  • Variable visibility: Hide variables once you’re comfortable with the project, unless they are needed to be shown.

Conclusion: Learn, Code, and Orbit!

Congratulations! 🎉 You’ve just learned how to make Earth revolve around the Sun in Scratch using sine and cosine — core trigonometric concepts simplified for a fun and visual learning experience.

This Scratch animation project not only helps you create realistic space animations, but also introduces you to powerful programming fundamentals such as:

  • Using variables to control motion
  • Applying trigonometry for circular movement
  • Implementing loops, pen extensions, and rotation styles
  • Creating interactive animations and games using Scratch

Whether you’re a Scratch beginner, a teacher looking for coding projects for kids, or just curious about how to make games in Scratch, this tutorial is a perfect starting point for combining STEM education with creativity.

Call to Action

  1. Don’t forget to check out the full video tutorial: How to Make Earth Revolve Around the Sun in Scratch | Make Animation in Scratch | Kodex Academy
  2. Like, comment & share the video
  3. Visit kodexacademy.com
  4. subscribe to the Kodex Academy YouTube channel for deeper Scratch content.

Happy coding with Kodex Academy! 🚀

Learn More with Kodex Academy

At Kodex Academy, we’re passionate about helping students learn coding in creative ways. This project teaches more than Scratch—it empowers young minds to build tools that work in the real world.

Explore more:

Stay updated with new content, free tutorials, and coding challenges!

Further Reading & Links

Recent Posts

How to Make a Math Racing Game in Scratch | Game Concepts and Complete Tutorial

In this tutorial, you’ll learn to build a Math Racing Game in Scratch. Players solve math problems to move their character forward; wrong answers benefit the opponent. It’s a race of speed, accuracy...

How to make Memory Skill Game in Scratch | Card Matching Game in Scratch – Part 2 | Step-by-Step Coding

In this tutorial you'll learn how to make memory skill game in Scratch / card matching game in Scratch. This is a great beginner‑to‑intermediate project for scratch tutorial game, scratch programming...

How to make a Card Matching Game in Scratch | Memory Skill Game in Scratch – Part 1 | Step-by-Step Coding

In this Scratch tutorial, we'll walk you through how to make a card matching game in Scratch, also known as a memory game or skill game. This is a popular beginner project that introduces essential...

Create a Quiz Game in Scratch | Spelling Test in Scratch | Picture Identification in Scratch

Want to make learning spelling fun, visual, and interactive? In this Scratch tutorial, you'll learn how to make a spelling quiz game in Scratch using picture identification, text-to-speech, and...

How to make a Double Jump Game in Scratch | Platformer game in Scratch | Step by Step Coding

How to make a Double Jump Game in Scratch. Scratch is a fantastic platform for beginners to learn programming by making games, animations, and interactive stories. Among the many kinds of games...

How to Use Variables in Scratch | Variable Blocks in Scratch | Complete Tutorial

Introduction: Variable Blocks in Scratch Whether you’re just getting started with Scratch programming or looking to take your projects to the next level, understanding variables and lists is...

How to Make Earth Revolve Around the Sun in Scratch: A Complete Tutorial & Enhancements

Animating Earth revolving around the Sun is a classic beginner/intermediate Scratch animation project. It combines trigonometry (sine & cosine), variables, loops, and visual scripting. Kids can learn...

How to Make a Game in Scratch | Snake Game in Scratch | Step-by-Step Game Coding

In this tutorial, we’ll build a Snake Grid style game in Scratch step by step (very similar to the Kodex Academy example). By doing this, you’ll cover many of the core Scratch building blocks. We will...

How to Use Operator Blocks in Scratch | Full Guide with Live Coding & Examples

One of the most powerful features in Scratch is its Operator Blocks — essential for handling math operations, logic comparisons, and string manipulations...

How to Create a Thirsty Crow Story in Scratch | Animation Story in Scratch for Kids

In this tutorial, you’ll learn how to create the classic “Thirsty Crow” story in Scratch, using simple animation, voice, and sprite actions. This is a perfect project for kids who are new to coding...

How to Create a Dodge Ball Game in Scratch: A Complete Step-by-Step Tutorial for Beginners

This step-by-step tutorial will guide you through how to create a Dodge Ball game in Scratch from scratch! In this game, you’ll control a character trying to dodge falling balls, earn points, and...

How to use Sensing Blocks in Scratch | Scratch programming for beginners | Live Coding with Examples

In today’s session, we’re diving deep into one of the most powerful features of Scratch — Sensing Blocks. These blocks allow your projects to interact with the world, detect touches, respond to...

Build an Egg Shooting Game in Scratch: Step-by-Step Coding | Complete Guide for Beginners

Learn how to create a fun, interactive shooting game in Scratch with this detailed tutorial inspired by classic arcade games. Perfect for kids and beginners looking to dive into Scratch programming!...

How to Make a Maze Game in Scratch | Step by Step Coding | Full Tutorial & Enhancements

Introduction: Why Build a Maze Game in Scratch? If you’re looking for a Scratch beginner project idea that’s fun, interactive, and educational, then building a maze game in Scratch is the...

Scratch Control Block Tutorial: Full Guide with Loops, Conditions, Cloning & Code Examples

“Control blocks” in Scratch are those blocks (from the Control category) that manage the flow of your script: when things happen, how many times they happen, making decisions, repeating actions...

How to Create a Car Racing Game in Scratch – Part 2 – Step-by-Step Coding

Welcome to your ultimate guide on how to make a car racing game in Scratch—a step‑by‑step tutorial. You'll learn Scratch game development techniques, see actual code blocks, and discover enhancements...

How to Make a Hurdle Jumping Game in Scratch – Build a Fun Hurdle Runner with Score & Win Screen

Are you ready to create your very own hurdle jumping game in Scratch—just like the iconic Chrome Dino or Super Mario? 🎮 Whether you're new to Scratch or just looking for your next fun project, this...

How to Create a Car Racing Game in Scratch – Part 1 – Step-by-Step Coding

In this Scratch car racing game tutorial, we’ll walk you through how to create a fully functional, visually exciting, and incredibly fun car racing game using Scratch. In this blog, we’ll cover: How...
Scroll to Top