Falling Down - PatrickLuhmann/Modron_Monodrone GitHub Wiki
Falling Down is a sample activity of the Monodrone project.
This sample will be used to experiment with Pong- and Breakout-like gameplay.
The basic game will have a paddle at the bottom of the screen which the player can move horizontally. An object will fall from the top of the screen, and the user will be awarded points if they catch it with their paddle.
Possible Game Extensions
- Multiple falling objects
- Objects have variable velocity and acceleration (gravity being an obvious one)
- Objects have a x-axis velocity, not just y-axis
- Objects can bounce off walls
- There are obstacles that interfere with objects
- Stationary blocks
- Rotating blocks
- Moving blocks
- Black holes
- Obstacles appear and disappear
- Obstacles that can be moved by the player, possibly only after being "activated" in some manner
Design
The activity uses a custom Runnable SurfaceView to handle updating the game state and drawing the game objects.
It turns out that SimpleOnGestureListener was not sufficient for handling paddle movement. The built-in gestures did not have a concept of DOWN + MOVE around + UP. Instead, View.onTouchEvent() parses the events and keeps track of whether the paddle is being moved or not.
There is one game field. It is divided into two sections. At the top is the scoreboard, and below it is the play area.
- The score area is small, maybe 15% - 20% of the screen (vertically).
- The play area takes up the rest of the screen.
The score area displays the number of balls that the user has caught.
The play area has a paddle at the bottom. The paddle is a simple rectangle of about 20% the width of the screen.
The ball starts at the top of the play area and falls to the bottom. The ball should be small, probably less than 10% of the width of the play area. The ball could have constant velocity, but that seems too boring. Instead, I will implement sources of gravity. The obvious source is the "ground" represented by the bottom of the screen. This should apply a constant acceleration on the ball. Other sources of gravity could be added on the play area to make motion interesting. There could also be objects that change the velocity of the ball when there is a collision.
Need to come up with rules on how the movement of the paddle can change the movement of the ball. Historically, I believe that the velocity of the paddle was somehow transferred to the ball. This will probably require experimentation to find something that looks good. In addition, a change in vel-x could be made based on where on the paddle the ball collided. This would simulate a paddle that was convex or concave. For example, a concave paddle hit on the right side would send the ball off to the right.
I feel like there needs to be multiple lists of objects.
- all objects - just for bookkeeping?
- objects that apply a gravity effect - is the ground considered an object?
- objects that are affected by gravity
- objects that move on their own - i.e. not stationary and not moved by the player