Im creating 32 object with each method call, and they should move in different directions, but what is happening is that they spawn, but wont move. What might be the issue here?
class that handles all the objects in the world
public void update(float delta){
runTime += delta;
player.update(delta);
for(Enemy e: enemy){
e.update(delta);
}
for(CircleBullet b: bullets){
b.update(delta);
}
if(runTime > 0.25){
enemy.add(new Enemy1(0,GameConstants.GAMEHEIGHT-12,12,12, new Vector2(90,-200),new Vector2(0,150), 1));
enemy.add(new Enemy1(GameConstants.GAMEWIDTH-12,GameConstants.GAMEHEIGHT-12,12,12,
new Vector2(-90,-200),new Vector2(0,150), -1));
runTime = 0;
}
}
The class that creates the 32 bullets.
public class shot {
private Vector2 position;
private ArrayList<CircleBullet> bullets = new ArrayList<CircleBullet>();
private Vector2 velocity;
public shot(float x, float y){
velocity = new Vector2(0,5);
position = new Vector2(x,y);
for(int i = 0; i<32; i++){
velocity.setAngle(i*11.25f);
GameWorld.bullets.add(new CircleBullet(position, velocity.x, velocity.y));
}
}
public void update(float delta){
for(CircleBullet b: bullets){
b.update(delta);
}
}
public float getX(){
return position.x;
}
public float getY(){
return position.y;
}
public ArrayList<CircleBullet> getBullets(){
return bullets;
}
}
CircleBullet class
public class CircleBullet {
private Vector2 position;
private Vector2 velocity;
public CircleBullet(Vector2 position, float vx, float vy){
this.position = position;
this.velocity = new Vector2(vx, vy);
}
public void update(float delta){
position.add(velocity.cpy().scl(delta));
}
public float getX(){
return position.x;
}
public float getY(){
return position.y;
}
}