This is what i have, and not quite sure of the command to use to import.
import greenfoot.*;
/**
* A bullet that can hit asteroids.
*
* @author Tyler Schenk
* @verion 15July2015
*/
public class Bullet extends SmoothMover
{
private static final int damage = 16;
/** A bullet looses one life each act, and will disappear when life = 0 */
private int life = 30;
public Bullet()
{
}
public Bullet(Vector speed, int rotation)
{
super(speed);
setRotation(rotation);
addToVelocity(new Vector(rotation, 15));
Greenfoot.playSound("EnergyGun.wav");
}
public void act()
{
if(life <= 0) {
getWorld().removeObject(this);
}
else {
life--;
move();
checkAsteroidHit();
}
}
/**
* Check whether we have hit an asteroid.
*/
private void checkAsteroidHit()
{
Asteroid asteroid = (Asteroid) getOneIntersectingObject(Asteroid.class);
if (asteroid != null)
{
getWorld().removeObject(this);
asteroid.hit(damage);
}
}
}
would import java.util.Vector; be what i would want to insert? And if so, would i want to insert that into the SmoothMover and the Bullet classes?
Sorry for all the questions, this is the first time i have ever messed with programming.
ok well i have gotten that issue fixed, now i have a new problem. When i go to compile i get an error stating "java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: rocketWithThrust.png" but the image is in the greenfoot folder.
Make sure you use the exact name of the file where case is important for both the name and suffix.
For the IllegalArgumentException you need to show the code around which the error occurred (it is best the post the entire class as well as the entire error trace).
java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: rocketWithThrust.png
at Rocket.<init>(Rocket.java:20)
at Space.<init>(Space.java:26)
its there, i have triple checked, im starting think Asteroids has something against me :(
is there a setting that needs to be set for it to look in the correct folder?
its there, i have triple checked, im starting think Asteroids has something against me :(
is there a setting that needs to be set for it to look in the correct folder?
How about you post a screenshot of the contents of the images folder (to an image/file sharing service like dropbox, and then post a link here)? I'm guessing the name doesn't match case or that the image format is not valid.