Package com.tankz.systems.rendering.spatials

Source Code of com.tankz.systems.rendering.spatials.Explosion

package com.tankz.systems.rendering.spatials;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;

import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.World;
import com.tankz.components.Expiration;
import com.tankz.components.Transform;

public class Explosion extends Spatial {

  private Transform transform;
  private float radius;
  private Color color;
  private Expiration expiraton;

  public Explosion(World world, Entity owner) {
    super(world, owner);
  }

  @Override
  public void initalize() {
    ComponentMapper<Expiration> expirationMapper = world.getMapper(Expiration.class);
    expiraton = expirationMapper.get(owner);

    ComponentMapper<Transform> transformMapper = world.getMapper(Transform.class);
    transform = transformMapper.get(owner);
    radius = 5;
    color = new Color(Color.yellow);
  }

  @Override
  public void render(Graphics g) {
    radius += world.getDelta() * 0.1f;
   
    color.a = expiraton.getLifeTimePercentage();
   
    g.setColor(color);
    g.setAntiAlias(true);
    g.fillOval(transform.getX()-radius, transform.getY()-radius, radius*2, radius*2);
  }

}
 
TOP

Related Classes of com.tankz.systems.rendering.spatials.Explosion

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.