Hi everyone,
I've been building a game in MIT App Inventor and completed it in three phases. The first two phases worked fine, but after implementing Phase 3, everything broke. I'm hoping someone can help me debug this.
Project Overview:
It's a simple platform/endless runner-style game where a player sprite moves left/right on platforms, collects coins, avoids obstacles, and progresses to the next level.
Phase 1 – UI & Basic Setup:
Built the entire user interface.
Set up sprite positioning (defined where each sprite should appear on the screen).
Added a random background generator so the background changes each time.
Phase 2 – Core Mechanics (Working Fine):
Adjusted platform movement speed.
Platforms move upward; when they reach the top of the screen, they respawn from roughly the middle and continue moving up until they disappear off-screen.
When the user clicks/taps the screen, the player sprite changes direction (left/right).
The player should NOT move unless there's a platform directly beneath it (gravity/collision detection active).
Implemented a Restart button that resets the entire game to the initial state.
Phase 3 – New Features (THIS IS WHERE ALL BUGS STARTED):
I added the following features, but they're causing major issues:
Game Over Conditions:
If the player hits the top sprite (ceiling) OR falls into the water, the game should:
Show a "You Lost!" message.
Play a losing sound effect.
Stop ALL game movement (freeze everything).
Coin Collection:
If the player touches a coin sprite, they should gain +10 points.
Next Level Trigger:
If the player touches the "Next Level" sprite, the game should:
Pause for a few seconds.
Then restart automatically.
I'm using a Clock/Timer component for this delay.
The Problems I'm Facing (All in Phase 3):
All dialogs/sounds play simultaneously – When one event triggers, everything else fires at the exact same time (e.g., losing sound plays while coin sound also plays, and Next Level triggers all together).
Game declares "You Lost" before it even starts – As soon as the app loads, the losing condition triggers immediately without any player input.
Collision detection is completely unreliable – Sometimes collisions register, sometimes they don't. The player sometimes clips through platforms.
Timer/Clock issues – The pause before restarting doesn't work correctly; sometimes it freezes permanently, other times it restarts too quickly.
Multiple events stacking – If the player touches a coin and a spike at the same time, both events fire, causing conflicting results (e.g., gain points AND lose at the same time).
Restart button doesn't fully reset Phase 3 features – After restarting, the new features (sound, timer, next level) still have leftover values from the previous round.
What I've Tried So Far:
Checked all collision blocks (they seem correctly connected).
Added "Notifier" blocks to track variable values – they show correct numbers, but the logic still fails.
Tried separating events with "if-else" conditions, but they still overlap.
Verified all sprite names and component references.
My Specific Questions:
How can I make sure only ONE event (e.g., losing OR coin) fires at a time, instead of all of them together?
Why does the "You Lost" condition trigger at startup? How do I prevent game logic from running before the player actually interacts?
What's the correct way to pause the game for a few seconds using a Clock/Timer without freezing the whole app?
How do I properly reset ALL variables and timers when the Restart button is pressed?
What I Need Help With:
I'm attaching:
Screenshots of my blocks (Phase 3 logic especially).
My .aia file (if anyone wants to open it directly).
If anyone has experience with sprite collisions, timer delays, or preventing event overlap in App Inventor, I'd really appreciate your guidance. I'm stuck and have been trying to fix this for days.
Thank you so much in advance for your time!
P
Clever_Fox_3.aia (1.6 MB)
.S. I'm happy to share more details or explain any part of the code. Just let me know what you need.
