I'm currently making a game that has blocks falling and the user controls them. I want to be able to detect when the blocks have stopped moving, because they have landed on another block or hit the bottom, in order to create a new block to drop (kind of like how Tetris spawns a new piece every time a block stops hits the bottom). How could I retrieve the y from this method so I know the block has stopped moving and has no velocity in the y direction?
Here is where I declare the variable and the method I'm using to change it (this moves the block downward):
int y = 0;
int ya = 0;
public void move() {
if(x + xa < game.getWidth() - WIDTH && x + xa > 0 ) {
ya = 2;
}if(y + ya > game.getHeight() - 50) {
ya = 0;
}
y = y + ya;
x = x + xa;
}
Somewhere else in the code, I would like to be able to do this:
// If the block stops moving (The y value in the move method is equal to 0)
if(y == 0) {
//Create new block object to drop, and allow the user to control this new block
}