Box Drop is an interactive Android game where players tap the screen to drop colored boxes. The objective is to manage the falling boxes while ensuring they do not exceed the screen boundaries. As the boxes accumulate, the ground opens to allow the boxes to pass through, creating a dynamic gameplay experience.
- Tap to drop boxes from the top of the screen.
- Colored boxes with random colors.
- Physics simulation using the JBox2D library.
Before running the project, ensure you have the following installed:
- Android Studio
- Java Development Kit (JDK) 1.8 or higher
- Gradle
-
Clone the repository:
git clone https://github.com/Boweii22/Box-Drop---Kotlin.git cd box-drop -
Open the project in Android Studio:
- Launch Android Studio.
- Select "Open an existing Android Studio project" and navigate to the cloned repository.
-
Build the project:
- In Android Studio, click on
Build>Rebuild Projectto ensure all dependencies are properly configured.
- In Android Studio, click on
-
Run the project:
- Connect your Android device or start an emulator.
- Click on the
Runbutton or pressShift + F10to launch the application.
- Tap anywhere on the screen to drop a new box.
- Boxes will fall due to gravity and stack on each other.
- Note: You need to click the screen quickly and multiple times to effectively open the ground, allowing the boxes to pass through when they reach 20% of the screen height.
- The ground will close when the boxes drop below 80% of the screen height.
- The game continues until you close the application.
The main code for the Box Drop game is implemented in the BoxDropView class. Here’s a brief overview of its functionality:
- Box Creation: Boxes are created dynamically when the screen is tapped.
- Physics Simulation: Utilizes the JBox2D library for realistic box behavior.
- Ground Management: The ground opens and closes based on the height of the stacked boxes.
onDraw(Canvas canvas): Handles the rendering of the boxes and the ground.createBox(float x, float y): Creates a new box with a random color.removeGround()/restoreGround(): Manages the opening and closing of the ground based on box height.
Contributions are welcome! If you have suggestions or improvements, please fork the repository and submit a pull request.
-
JBox2D: A 2D physics engine for Java that powers the game's physics simulation.
-
Thanks to all the contributors and community members who provide valuable feedback.
