This document defines the specific rules governing bubble behavior in the ZenTap game, ensuring consistent and predictable gameplay mechanics.
Calculate the maximum number of full-size bubbles that can fit on the screen to optimize spawning and prevent overcrowding.
Formula:
Effective bubble area = (diameter + spacing)² = (50 + 10)² = 3600px²
Available screen area = (screen_width - 2*margin) × (screen_height - 2*margin - 100)
Max bubbles = floor(Available screen area / Effective bubble area)
lib/game/components/bubble_spawner.dartcalculateMaxBubblesForScreen()If a bubble collides with other bubbles 3 times, it automatically pops to prevent clustering and maintain fluid gameplay.
lib/game/components/bubble.dartcollisionCount, lastCollisionTime_handleBubbleCollision()When the device is shaken, only one bubble is created per shake event to maintain controlled spawning.
lib/game/zentap_game.darthandleShake()lib/utils/tilt_detector.dartshakeDebounceTimePrevent bubbles from spawning on top of or too close to existing bubbles to maintain visual clarity and prevent immediate collisions.
lib/game/components/bubble_spawner.dart_getValidSpawnPosition(), _findSafePositionNear(), _isPositionSafe()// Bubble sizing and spacing
const double BUBBLE_MAX_DIAMETER = 50.0;
const double BUBBLE_MIN_SPACING = 10.0;
const double SCREEN_MARGIN = 120.0;
const double UI_TOP_MARGIN = 100.0;
// Collision rules
const int MAX_BUBBLE_COLLISIONS = 3;
const double COLLISION_GRACE_PERIOD = 2.0; // seconds
// Shake rules
const double SHAKE_DEBOUNCE_TIME = 500.0; // milliseconds
const int BUBBLES_PER_SHAKE = 1;
// Collision avoidance
const double MIN_SPAWN_DISTANCE = 80.0; // pixels
const int MAX_SPAWN_ATTEMPTS = 15;
const double SEARCH_RADIUS = 100.0; // pixels around user tap