Hello. I am almost finished my project, but I have one error. I am trying to have the mouse pointer repel all points within a range of 100 pixels. When I tried to write the code for that in the world class, I got the error "cannot find symbol: List<Point>objects = getObjectsInRange(range, Point.class);". Does anyone know how to fix this? Thank you.
Here is the code for the World:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.lang.Object;
import java.util.List;
import java.util.*;
// Name: Tommy Guo (GrandMasterG)
public class Field extends World
{
// The Margin around the outer edges of the world:
private static final int MARGIN = 100;
private static final double REPULSION = 1.1;
public Field()
{
super(800, 600, 1);
addPoints(100);
}
public void addPoints(int n)
{
for(int i=0;i<n;i++) {
int x = Greenfoot.getRandomNumber(getWidth()-MARGIN) + MARGIN/2;
int y = Greenfoot.getRandomNumber(getHeight()-MARGIN) + MARGIN/2;
addObject(new Point(),x,y);
}
}
public void act()
{
if(Greenfoot.mouseClicked(this)) {
MouseInfo mouse = Greenfoot.getMouseInfo();
if(mouse!=null) {
addObject(new Magnet(100),mouse.getX(),mouse.getY());
}
}
mouseRepel();
}
public void mouseRepel()
{
MouseInfo mouse = Greenfoot.getMouseInfo();
int x = mouse.getX();
int y = mouse.getY();
int range = 100;
List<Point>objects = getObjectsInRange(range, Point.class);
for(Point p: objects){
double dx = p.getExactX()-this.getExactX();
double dy = p.getExactY()-this.getExactY();
int angle = (int)Math.toDegrees(Math.atan2(dy,dx));
p.addForce(new Vector(angle, REPULSION));
}
}
//Cast mouse, make list, if touching, make for loop, doubles, check to see if in range, double dx, dy, etc.
}


