Creating collectibles in top-down scrolling games
此内容尚不支持你的语言。
💡 Having trouble with Scratch block assembly? Don’t know how to implement code logic? 🚀 Get Help Now
GameDevExplorer
Posted on July 22, 2025 • Advanced
🎮 Mystery solved: Collectibles in top-down scrollers!
I’ve been working on a massive Zelda-style RPG and hit a wall with collectibles. Why don’t I see cloned collectibles in top-down scrolling games? Is it even possible?
I’ve studied tons of RPGs and Zelda remakes, but none seem to use cloning for collectibles like rupees. Even ChatGPT couldn’t help me figure this out! 😅
The main challenge is making collectibles scroll properly with the background while using clones. Regular collision detection works fine, but the scrolling mechanics break everything.
Has anyone cracked this code? I really want to create the first top-down scrolling RPG with properly cloned collectibles! Any insights would be amazing! 🙏
ScrollMaster_Dev
Replied 3 hours later • ⭐ Best Answer
@GameDevExplorer I’ve actually solved this exact problem! The key is understanding how scrolling coordinates work with clones. Here’s the complete solution:
🗺️ Scrolling Collectibles System
Here’s how the system works:
🔧 Step 1: Collectible Sprite Setup
First, create your collectible sprite with these sprite-only variables:
world_x
- The item’s fixed world positionworld_y
- The item’s fixed world positioncollected
- Whether this clone was collected
when flag clicked set [clone_id v] to [0] repeat [50] // Create 50 collectibles change [clone_id v] by [1] create clone of [myself v] end hide
💎 Step 2: Clone Initialization
Each clone needs to know its world position:
when I start as a clone set [world_x v] to (pick random [-2000] to [2000]) set [world_y v] to (pick random [-1500] to [1500]) set [collected v] to [false] show forever // Calculate screen position based on camera scroll set x to ((world_x) - (camera_x)) set y to ((world_y) - (camera_y)) // Hide if off-screen for performance if <<(x position) < [-300]> or <(x position) > [300]>> then hide else if <<(y position) < [-250]> or <(y position) > [250]>> then hide else if <(collected) = [false]> then show end end end // Check for collection if <<touching [Player v]?> and <(collected) = [false]>> then set [collected v] to [true] change [rupees v] by [1] play sound [collect v] hide stop [this script v] end end
🎮 Step 3: Camera/Scroll System
Your main game needs these global variables for camera control:
// In your main game sprite or stage when flag clicked set [camera_x v] to [0] set [camera_y v] to [0] forever // Follow player with camera change [camera_x v] by (((player_x) - (camera_x)) / [10]) change [camera_y v] by (((player_y) - (camera_y)) / [10]) end
🚀 Step 4: Advanced Features
For even better performance and features:
Persistent Collection (Save System):
// Save collected items to a list when I receive [item collected v] add (join (world_x) (join [,] (world_y))) to [collected_items v] // Check if item was already collected when I start as a clone set [item_key v] to (join (world_x) (join [,] (world_y))) if <[collected_items v] contains (item_key)?> then set [collected v] to [true] hide end
Different Collectible Types:
when I start as a clone set [item_type v] to (pick random [1] to [3]) if <(item_type) = [1]> then switch costume to [rupee v] set [value v] to [1] else if <(item_type) = [2]> then switch costume to [heart v] set [value v] to [5] else switch costume to [key v] set [value v] to [1] end end
The secret is treating world coordinates separately from screen coordinates! Each clone remembers where it belongs in the world, then calculates where to appear on screen based on the camera position. 🎯
GameDevExplorer
Replied 45 minutes later
@ScrollMaster_Dev HOLY MOLY! 🤯 This is exactly what I needed!
I was trying to make the clones move with the scroll, but you’re right - keeping world coordinates separate from screen coordinates is genius! Testing this right now…
Update: IT WORKS PERFECTLY! My Zelda RPG finally has proper rupee collection! You’re a lifesaver! 🎉
RPGMaster_Alex
Replied 2 hours later
This is why I love this community! 💪 @ScrollMaster_Dev just solved one of the trickiest problems in Scratch game development.
Pro tip: You can also use this same technique for enemies, NPCs, and interactive objects. The world/screen coordinate separation is the foundation of any good scrolling game!
Can’t wait to see your Zelda RPG @GameDevExplorer! 🗡️
Vibelf_Community
Pinned Message • Moderator
🎮 Advanced Scrolling Game Development
Excellent problem-solving everyone! For those working on complex scrolling games, our tutors can help you master:
- 🗺️ Advanced camera systems
- 🎯 Efficient collision detection
- 💾 Save/load systems
- 🏰 Level design techniques
- ⚡ Performance optimization
📚 Related Topics
Ready to create the next amazing Scratch RPG? Get expert guidance from our game development tutors!