I think you have a closing squiggly bracket out of place in the ViralLoad class. I think you should remove one from the end of the class and put it before the if(!isAtEdge()) line.
public class ViralLoad extends Actor
{
private boolean shoot;
public double xspeed;
public double yspeed;
public double xspeed2;
public double yspeed2;
public int yspot;
public int xspot;
/**
* Act - do whatever the Person wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public ViralLoad()
{
shoot=true;
}
public void act()
{
MyWorld myWorld = (MyWorld) getWorld();
if(shoot)
{
xspot= myWorld.circle.getArcX();
yspot= myWorld.circle.getArcY();
setLocation(xspot,yspot);
if(Greenfoot.isKeyDown("space"))
{
shoot=false;
//yspeed = yspeed = .01;
xspeed2 =15 * myWorld.rectangle.getFilledRatio();
yspeed2 =-15 * myWorld.rectangle.getFilledRatio();
xspeed = xspeed2 * Math.cos(myWorld.circle.getAngle());
yspeed = yspeed2 * Math.sin(myWorld.circle.getAngle());
}
}
else if(!isAtEdge())
{
setLocation(getX()+(int)xspeed, getY()+(int)yspeed);
yspeed = yspeed + .01;
}
if(isTouching(Bird.class))
{
removeTouching(ViralLoad.class);
myWorld.addObject(new ViralLoad(),xspot,yspot);
}
if(this.isAtEdge())
{
getWorld().removeObject(this);
myWorld.addObject(new ViralLoad(),xspot,yspot);
}
}
}
ok i did that and it actually shoots now but the viralload doesnt go at the angle it's supposed to. It just goes straight
objc: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fffa1f9f3d8) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x1375a4f50). One of the two will be used. Which one is undefined.
also would you know why i get this error when trying to get my birds on the screen?? and only the top one moves now
ok i did that and it actually shoots now but the viralload doesnt go at the angle it's supposed to. It just goes straight
That may be because your location coordinates are stored in int fields. Any fractional movement in both the horizontal and vertical directions is lost when you use getX and getY in a setLocation statement. Retain the location coordinates in double fields and adjust their values so you can set the new locations.