I don't know what's wrong with this program. Every time I start the game the Terminal Window appears. (I want to make a snake game using arrays.) Please help!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Snake extends Actor
{
/**
* Act - do whatever the Snake wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int foodEaten=0;
Tail a[];
private Snake behind;
public void act()
{
design();
eat();
movee();
}
public void design ()
{
GreenfootImage snake= new GreenfootImage (20,20);
snake.setColor(new Color(0,138,0)); //green
snake.fill();
setImage(snake);
}
public void eat()
{
{
if (isTouching(Yellow.class))
{
removeTouching (Yellow.class);
foodEaten++;
}
}
}
public void movee()
{
for (int i=0; i<foodEaten+1; i++)
{
if (i==0){
if( a[i].getRotation()==0) a[0].setLocation(getX()+1,getY());
if( a[i].getRotation()==90) a[0].setLocation(getX(),getY()+1);
if( a[i].getRotation()==180) a[0].setLocation(getX()-1,getY());
if( a[i].getRotation()==270) a[0].setLocation(getX(),getY()-1); }
else
{
{
int x1=a[i].getX();
int y1=a[i].getY();
if( a[i].getRotation()==0) a[i].setLocation(x1+1,y1);
if( a[i].getRotation()==90) a[i].setLocation(x1,y1+1);
if( a[i].getRotation()==180) a[i].setLocation(x1-1,y1);
if( a[i].getRotation()==270) a[i].setLocation(x1,y1-1);
}
}
}
}
}
