I'm working on a game that has a dolphin that needs to find fish to eat and danger to avoid with the help of his sonar and I'm new on all Greenfoot related stuff, I started working a week ago, so I'm having some big problem with this and I have to finish the whole game in a week, so please help!!
This is what I've done so far, and it's in the dolphin's code class:
int r=100; Actor sonar = new sonar(); public void shoot(){ if(Greenfoot.isKeyDown("space")) { if(r==100){ r--; getWorld().addObject(sonar, getX(), getY()); sonar.move(5); if(sonar.getX()==400){ getWorld().removeObjects(getWorld().getObjectsAt(sonar.getX(), sonar.getY(), sonar.class)); } } } if(r==0){ r=100; } }