Hey there! Me and my friends are trying to make a game of frogger for our tech class. We received instructions on how to do it but our teacher has not been very clear. Right now we are trying to get the cars to spawn and move across the road randomly. We have a problem with the `"addObject" statement. Here is our code:
The error message we get when trying to compile is : cannot find symbol - method addObject(Car,int,int)
This is according to the instructions the only missing link we need for this to work. If you can find any errors please let me know.
public int pickLane(){
int lane;
lane = Greenfoot.getRandomNumber(4);
return lane;
}
public void tryAddingCar(){
if (Greenfoot.getRandomNumber(100) < 3)
{
int lane;
int speed;
Car randomCar;
int x;
int y;
lane = pickLane();
speed = pickSpeed();
if (lane == 0){
randomCar = new Car(0);
}
else if (lane == 1){
randomCar = new Car(0);
}
else if (lane == 2){
randomCar = new Car(0);
}
else if (lane == 3){
randomCar = new Car(0);
}
else {
randomCar = new Car(0);
}
addObject(randomCar,400,200);
randomCar.setSpeed(pickSpeed());
}
}
public int pickSpeed(){
int speed;
speed = 2+Greenfoot.getRandomNumber(7);
return speed;
}
