Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Enemy {
- private Ball ball;
- Vector2 positionTwo = new Vector2();
- Vector2 velocityTwo = new Vector2();
- Vector2 movementTwo = new Vector2();
- Vector2 targetTwo = new Vector2();
- Vector2 dirTwo = new Vector2();
- private float width;
- private float height;
- float speed = 50;
- public Enemy (float x, float y)
- {
- positionTwo.set(x, y);
- targetTwo.set(x,y);
- this.width = 5;
- this.height = 5;
- }
- public float getWidth() {
- return width;
- }
- public float getHeight() {
- return height;
- }
- public void update (float deltaTime) {
- movementTwo.set(velocityTwo).scl(deltaTime);
- if (positionTwo.dst2(targetTwo) > movementTwo.len2()) {
- positionTwo.add(movementTwo);
- } else {
- positionTwo.set(targetTwo);
- }
- }
- public void moveTo (float x, float y) {
- dirTwo.set(targetTwo.set(x,y)).sub(positionTwo).nor();
- velocityTwo.set(dirTwo).scl(speed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement