
I isolated the problem into this class. I'm using Slick2D.
Code:
public class Runa extends BasicGame {
int startTime, tracker;
public ArrayList<Circle> circ = new ArrayList<Circle>();
public int[] a = new int[]{
15, 16, 17, 18, 19, 32, 36, 40, 45, 46, 55, 56, 57, 58, 63, 65, 68, 70, 72, 74, 79, 80, 81, 82, 86, 94, 95, 96, 97, 98, 99,
100, 101, 102, 103, 104, 105, 117, 120, 122, 126, 128, 129, 130, 131, 133, 138, 139, 140, 142, 149, 151, 155, 156,
158, 164, 166, 172, 174, 180, 182, 184, 188, 189};
public ArrayList<Integer> aList = new ArrayList<Integer>();
public Runa(String title) {
super(title);
}
@Override
public void init(GameContainer c) throws SlickException {
startTime = 0;
tracker = 0;
//this just transfers the hard coded values into an arraylist
for(int i = 0; i<a.length;i++){
aList.add(a[i]);
}
}
@Override
public void update(GameContainer c, int d) throws SlickException {
//this calculates the rhythm of the game
startTime+=d;
if(startTime>((60/(calcBPM(195.8,89)))*1000)){
startTime=0;
tracker++;
}
//this adds a new circle every time the current beat (tracker) reaches a beat on the aList
if(aList.indexOf(tracker)>0)
circ.add(new Circle(50,50,50));
//this should just move one circle at a time, meaning I thought that only one circle would be added above, and move it down 4 px
for(Circle circle: circ)
circle.setCenterY(circle.getCenterY()+4);
}
@Override
public void render(GameContainer c, Graphics g) throws SlickException {
//draws each circle in the arraylist
g.setColor(Color.red);
for(Circle circle: circ)
g.draw(circle);
}
//calculates the bpm
public double calcBPM(double d, int numSecs){
return d*60/numSecs;
}
public static void main(String[]args) throws SlickException{
new AppGameContainer(new Runa("Test"),680, 480, false).start();
}
}