Package ru.vagrant_ai.questionmarkgame.obj.particle

Source Code of ru.vagrant_ai.questionmarkgame.obj.particle.Thorn

package ru.vagrant_ai.questionmarkgame.obj.particle;

import java.util.Random;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Vector2f;

import ru.vagrant_ai.questionmarkgame.main.GameplayState;
import ru.vagrant_ai.questionmarkgame.obj.Elements;
import ru.vagrant_ai.questionmarkgame.util.Util;
import ru.vagrant_ai.questionmarkgame.util.list.ITEM;
import ru.vagrant_ai.questionmarkgame.util.list.PT;

public class Thorn extends Particle {

  private Image util_img;
  private Vector2f vector;
  private short rotation;
  float x, y;
  float x_incr, y_incr;
  byte util_alive = (byte) (new Random().nextInt(35)+8+(Elements.extractLevel(ITEM.P_UPG_THORNY)*5));
 
  public Thorn(int x, int y)
  {
    id = PT.THORN;
   
    util_img = Util.loadImage("particle/thorn.png");
    rotation = (short) new Random().nextInt(360);
    util_img = util_img.getFlippedCopy(true, false);
    util_img.rotate(rotation);
    vector = new Vector2f(x,y);
    vector.normalise();
    vector.setTheta(rotation);
    x_incr = vector.getX();
    y_incr = vector.getY();
    this.x = x;
    this.y = y;
  }
 
  public void update()
  {
    x += x_incr*3f;
    y += y_incr*3f;
    util_alive--;
    if (util_alive < 0 || y > GameplayState.ground_level+GameplayState.player.height)
      alive = false;
  }
 
  public void render(Graphics g)
  {
    util_img.draw(x, y);
  }

}
TOP

Related Classes of ru.vagrant_ai.questionmarkgame.obj.particle.Thorn

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.