In this exciting Tynker project, we create a cannon that shoots animals (cats & dogs 🐶) using cloning and physics blocks.
When the mouse is pressed, the cannon aims at the pointer and fires cloned animals with realistic motion using impulse and gravity.
This project helps students understand game physics, cloning, and mouse interactions in a fun and visual way.
Students will learn:
-
✅ What cloning is and why it’s useful
-
✅ How physics engine works in Tynker
-
✅ Using impulse for motion
-
✅ Mouse interaction (aim & shoot)
-
✅ Gravity and restitution (bouncing effect)
Characters Used
| Sprite | Role |
|---|---|
| Stage | -Controls physics & gravity |
| Cannon | -Aims and fires |
| Animal | -Clone projectile (dog/cat) |
| Base | -Static ground/support |
Stage Code – Setting Up Physics
What this does:
-
Starts the physics engine
-
Applies gravity downward
Logic Explanation:
-
Gravity
(0, 10)pulls objects down, making the motion realistic.
This is what allows the animals to fall and bounce naturally.
Cannon Sprite – Aiming & Shooting
Cannon Behavior:
-
Remains static
-
Rotates towards the mouse
-
Fires continuously while mouse is pressed
Logic Flow:
-
Cannon stays fixed in place
-
Forever checks: Is mouse pressed?
-
Points towards mouse pointer
-
Creates a clone of the animal
-
Small delay (0.05 sec) for smooth firing
This creates a rapid-fire cannon effect
Animal Sprite – Clone Logic (Main Action)
This is where the magic happens
On Start:
-
Hide the original animal (only clones are visible)
When Clone Starts:
-
Enable bouncy effect (restitution = 1)
-
Randomly switch costume (dog or cat)
-
Go to the cannon position
-
Point toward mouse
-
Apply impulse to shoot forward
-
Delete clone after 10 seconds





Comments
Post a Comment