My aim is to create tetris game. Actually I am on very beginning. I am trying to make new block to spawn after previous reaches a bottom. When I run my code, first block acts normaly. But when this first block reaches destination, it seems like objects (blocks) begin to appear in a row constantly instead of only one block have to appear. After plenty of seconds whole Greenfoot application starts to freeze. If I dont stop execution of my code, greenfoot even can crush.
I want every next object to behave separately so that previous object stops acting when it reaches destination and control goes to new object.
Please explain what should I do in my situation, why does not my code behave as I expect? Why Greenfoot crashes?
My code:
Illustration:

import greenfoot.*;
public class Square extends Actor
{
//constructor
public Square(){
rightWay = false;
isKeyD = false;
destination = false;
queue = true;
}
private boolean rightWay; //whether block will move to the bottom
private boolean isKeyD; //support variable for isKeyDown construction
private boolean destination; //whether block gained bottom or another block
private boolean queue; //my attemt to fix bug; has to indicate if next block is in the air
public void act()
{
toWay();
moveForw();
stepRight();
stepLeft();
reachedDestination();
boost();
newActor();
}
//moves block one step right
public void stepRight(){
if(!getDestination()){
if(!getIsKeyD() && Greenfoot.isKeyDown("right")){
setLocation(getX() + 1, getY());
setIsKeyD(true);
}
if(getIsKeyD() && !Greenfoot.isKeyDown("right")){
setIsKeyD(false);
}
}
}
// and left
public void stepLeft(){
if(!getDestination()){
if(!getIsKeyD() && Greenfoot.isKeyDown("left")){
setLocation(getX() - 1, getY());
setIsKeyD(true);
}
if(getIsKeyD() && !Greenfoot.isKeyDown("left")){
setIsKeyD(false);
}
}
}
//changes queue and destination variables to indicate
//that block has reached bottom and must not move further
public void reachedDestination(){
if(getY() == getWorld().getHeight() - 1 || isTouching(null)){
setDestination(true);
setQueue(false);
}
}
//adds new block to world (seems like bug is located here)
public void newActor(){
if(getDestination() && !getQueue()){
setQueue(true);
getWorld().addObject(new Square(), 5, 0);
}
}
//makes block to face bottom
public void toWay(){
if(!getRightWay()){
turn(90);
setRightWay(true);
}
}
//basic move method
public void moveForw(){
if(getRightWay() && !getDestination()){
move(1);
}
}
//makes block move x2 faster
public void boost(){
if(!getIsKeyD() && Greenfoot.isKeyDown("down")){
moveForw();
setIsKeyD(true);
}
if(getIsKeyD() && !Greenfoot.isKeyDown("down")){
setIsKeyD(false);
}
}
//set and get support methods
void setRightWay(boolean input){
rightWay = input;
}
boolean getRightWay(){
return rightWay;
}
void setIsKeyD(boolean input){
isKeyD = input;
}
boolean getIsKeyD(){
return isKeyD;
}
void setDestination(boolean input){
destination = input;
}
boolean getDestination(){
return destination;
}
void setQueue(boolean input){
queue = input;
}
boolean getQueue(){
return queue;
}
}



