Android Open Source - TileArena Linear Projectile






From Project

Back to project page TileArena.

License

The source code is released under:

MIT License

If you think the Android project TileArena 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 game.tile.arena.entity.projectile;
/*from   w  w  w .  ja  v a 2  s.  c o  m*/
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

import game.tile.arena.util.Position;

public class LinearProjectile extends Projectile {

    public static class Builder  {

        private String filePrefix;
        private Position pos;
        private Position movement;
        private boolean orientation;
        private int hits = 1;
        private int damage = 1;

        public Builder(String filePrefix, Position pos, Position movement, boolean orientation) {
            this.filePrefix = filePrefix;
            this.pos = pos;
            this.movement = movement;
            this.orientation = orientation;
        }

        public Builder setHits(int hits) {
            this.hits = hits;
            return this;
        }

        public Builder setDamage(int damage) {
            this.damage = damage;
            return this;
        }

        public LinearProjectile create() {
            return new LinearProjectile(filePrefix, pos, movement, orientation, hits, damage);
        }
    }

    // Direction and speed.
    private Position movement;

    public LinearProjectile(String filePrefix, Position pos, Position movement, boolean orientation, int hits, int damage) {
        super(filePrefix, pos, orientation, hits, damage);
        this.movement = movement;
    }

    public Position getCurrentMovement() {
        return movement;
    }

    @Override
    public boolean update(double delta) {
        pos = pos.addPolar(movement.scaleY(delta));
        return valid() && !checkCollision();
    }

    @Override
    public void render(SpriteBatch batch) {
        super.draw(batch, movement.x);
    }
}




Java Source Code List

game.tile.arena.Game.java
game.tile.arena.TileArena.java
game.tile.arena.android.AndroidLauncher.java
game.tile.arena.client.HtmlLauncher.java
game.tile.arena.desktop.DesktopLauncher.java
game.tile.arena.entity.Entity.java
game.tile.arena.entity.Player.java
game.tile.arena.entity.attack.AttackBow.java
game.tile.arena.entity.attack.AttackList.java
game.tile.arena.entity.attack.Attack.java
game.tile.arena.entity.enemy.Enemy.java
game.tile.arena.entity.enemy.ai.EnemyAI.java
game.tile.arena.entity.enemy.ai.EnemyDodgeAI.java
game.tile.arena.entity.enemy.ai.EnemyRandomAI.java
game.tile.arena.entity.projectile.LinearProjectile.java
game.tile.arena.entity.projectile.Projectile.java
game.tile.arena.sprite.EntitySprite.java
game.tile.arena.sprite.Image.java
game.tile.arena.util.MathHelper.java
game.tile.arena.util.Position.java
game.tile.arena.util.Preferences.java
game.tile.arena.util.controller.Joystick.java
game.tile.arena.util.controller.KeyboardController.java
game.tile.arena.util.controller.MouseAttackInput.java
game.tile.arena.util.controller.PlayerController.java
game.tile.arena.util.controller.TouchController.java
game.tile.arena.util.input.InputManager.java
game.tile.arena.util.input.JoystickInput.java
game.tile.arena.util.input.KeyboardMoveInput.java
game.tile.arena.util.input.WeaponSwitchInput.java
game.tile.arena.world.Tile.java
game.tile.arena.world.World.java