Java游戏-敌人AI

Java游戏-敌人AI,java,Java,我正在用libgdx做我的第一个java游戏。这是一个射击游戏,我的敌人AI有一个问题:我不能让他们移动或射击子弹,他们只是在随机位置产卵并停留在那里。这是我的敌人课程中的内容: import java.util.Random; import View.World; import com.badlogic.gdx.math.Vector2; public class Enemy { private static final Random r = new Random(); flo

我正在用libgdx做我的第一个java游戏。这是一个射击游戏,我的敌人AI有一个问题:我不能让他们移动或射击子弹,他们只是在随机位置产卵并停留在那里。这是我的
敌人
课程中的内容:

import java.util.Random;

import View.World;

import com.badlogic.gdx.math.Vector2;

public class Enemy {

private static final Random r = new Random();
    float ROTATION_SPEED = 500;
    int x = r.nextInt(36); //top x
    int y = r.nextInt(24); //top y
    Vector2 vect = new Vector2(x,y);




    public Follower(float SPEED, float rotation, float width, float height,
                    Vector2 position) {
            super(SPEED, rotation, width, height, position);
    }

    public void move (Vector2 position){
        getPosition().x =+ 5;
        getPosition().y =+ 5;
    }
    @Override
    public void advance(float delta, Esfera ship) {

      position.lerp(vect, delta);

        rotation += delta * ROTATION_SPEED;

        if(rotation > 360)
                rotation -= 360;

        super.update(ship);
       if(vect.equals(this.getPosition())){
            x = r.nextInt(36);
            y = r.nextInt(24);

       }
}

在我的世界级比赛中,我得到了这样的机会来制造敌人:

public class World {

//More variable declarations

Iterator<Follower> eIter;
int Timer = 0;
int counter;
float x = 0;
float y = 0;

public float randFloat(float Min, float Max) {
    return Min + (float)(Math.random() * (Max - Min + 1));
}
public void update(){
    Timer++;
    if(counter < 40){
        if(Timer % 100 == 0){
            float x = randFloat(0, 50.0f);
            float y = randFloat(0, 50.0f);
            enemies.add(new Follower(5f, 0, 1, 1, new Vector2(x, y)));

            counter++;
        }
    }
公共类世界{
//更多变量声明
迭代器eIter;
int定时器=0;
整数计数器;
浮动x=0;
浮动y=0;
公共浮动和浮动(浮动最小值、浮动最大值){
返回Min+(float)(Math.random()*(Max-Min+1));
}
公共无效更新(){
定时器++;
如果(计数器<40){
如果(计时器%100==0){
浮动x=随机浮动(0,50.0f);
浮动y=随机浮动(0,50.0f);
添加(新跟随者(5f,0,1,1,新向量2(x,y));
计数器++;
}
}
}


我应该实施什么来至少不断地打动我的敌人?

我认为你需要更加努力地理解你试图解决的问题和你已经得到的代码。就你遇到的技术问题问一些小的、具体的问题。目前你已经问了一系列问题,这些问题相当于“请为我写我的游戏”,这样做你不太可能得到很多答案。那种“我有这个,现在让我们击倒它做这个”的心态很有精神,但也有问题。程序中的一行、一种方法或一个对象应该做一件事。正确,如果设计合理,不需要更改。