Package framework.rendering

Source Code of framework.rendering.CollisionMaskRenderer

package framework.rendering;

import java.util.ArrayList;
import java.util.Collection;

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

import framework.collision.CollisionComponent;
import framework.component.Component;
import framework.component.ComponentSystem;
import framework.spacial.PositionComponent;

public class CollisionMaskRenderer {

  public static void renderCollisionMasks(Graphics g){
    Collection<Component> collisCompsCollection = ComponentSystem.getInstance().getComponentsOfType(CollisionComponent.class.getName());
    if(collisCompsCollection != null){
      ArrayList<Component> collisComps = new ArrayList<Component>(collisCompsCollection);
      for(int i = 0; i < collisComps.size(); i++){
        Component c = collisComps.get(i);
        PositionComponent posComp = (PositionComponent) c.getSiblingByType(PositionComponent.class.getName());
        if(posComp != null){
          Vector2f pos = posComp.getVector();
          if(pos != null){
            CollisionComponent collis = (CollisionComponent) c;
            if(collis.getMask() != null){
              g.setColor(Color.white);
              collis.getMask().renderForDebug(g, pos);
            }
          }
        }
      }
    }
  }
}
TOP

Related Classes of framework.rendering.CollisionMaskRenderer

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.