Android Open Source - Infinite Enemy






From Project

Back to project page Infinite.

License

The source code is released under:

GNU General Public License

If you think the Android project Infinite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.detel.infinite.models;
/*from  ww  w  .  jav a  2s  . c  o  m*/
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

/**
 * Created by Derick on 2/24/14.
 */
public class Enemy {

    public enum State{
        Idle,Walking,Jumping
    }

    private State state;
    private Boolean facingLeft;

    private Vector2 position;
    private Vector2 acceleration;
    private Vector2 velocity;

    private int health = 100;
    private int attackPower = 5;

    private boolean jumpingPressed = false;
    private long jumpTime;

    private Rectangle bounds;
    private Rectangle hitBox;
    private static final Vector2 SIZE = new Vector2(1f,2f);
    private static final Vector2 HIT_SIZE = new Vector2(0.6f,2f);

    public Enemy(int x, int y){
        state = State.Idle;

        position = new Vector2(x,y);
        acceleration = new Vector2();
        velocity = new Vector2();

        bounds = new Rectangle(x,y,SIZE.x,SIZE.y);
        hitBox = new Rectangle(x + (SIZE.x - HIT_SIZE.x),y,HIT_SIZE.x,HIT_SIZE.y);
    }

    public State getState(){
        return state;
    }

    public Boolean isFacingLeft(){
        return facingLeft;
    }

    public Vector2 getPosition(){
        return position;
    }

    public Vector2 getAcceleration(){
        return acceleration;
    }

    public Vector2 getVelocity(){
        return velocity;
    }

    public Vector2 getSize(){
        return SIZE;
    }

    public Vector2 getHitSize(){
        return HIT_SIZE;
    }

    public Rectangle getBounds(){
        return bounds;
    }

    public Rectangle getHitBox() {
        return hitBox;
    }

    public int getHealth(){
        return health;
    }

    public int getAttackPower(){
        return attackPower;
    }

    public Boolean getJumpingPressed(){
        return jumpingPressed;
    }

    public long getJumpTime(){
        return jumpTime;
    }

    public void setState(State state){
        this.state = state;
    }

    public void setFacingLeft(Boolean facingLeft){
        this.facingLeft = facingLeft;
    }

    public void setHealth(int health){
        this.health = health;
    }

    public void setJumpingPressed(boolean jumpingPressed){
        this.jumpingPressed = jumpingPressed;
    }

    public void setJumpTime(long jumpTime){
        this.jumpTime = jumpTime;
    }
}




Java Source Code List

com.detel.infinite.Infinite.java
com.detel.infinite.MainActivity.java
com.detel.infinite.Main.java
com.detel.infinite.controllers.CameraController.java
com.detel.infinite.controllers.ChunkController.java
com.detel.infinite.controllers.EnemyController.java
com.detel.infinite.controllers.KnifeController.java
com.detel.infinite.controllers.PlayerController.java
com.detel.infinite.controllers.WorldController.java
com.detel.infinite.models.BlockAir.java
com.detel.infinite.models.Block.java
com.detel.infinite.models.Chunk.java
com.detel.infinite.models.Enemy.java
com.detel.infinite.models.Player.java
com.detel.infinite.models.ThrowingKnife.java
com.detel.infinite.models.World.java
com.detel.infinite.screens.ScreenBase.java
com.detel.infinite.screens.ScreenGameOver.java
com.detel.infinite.screens.ScreenGame.java
com.detel.infinite.screens.ScreenMainMenu.java
com.detel.infinite.screens.ScreenPause.java
com.detel.infinite.views.WorldRenderer.java