ImageRenderComponent.java :  » Game » seed-videogame » seed » tests » Java Open Source

Java Open Source » Game » seed videogame 
seed videogame » seed » tests » ImageRenderComponent.java
package seed.tests;
 
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.state.StateBasedGame;

import seed.engine.RenderComponent;
 
public class ImageRenderComponent extends RenderComponent {
 
  Image image;
 
  public ImageRenderComponent(String id, Image image)
  {
    super(id);
    this.image = image;
  }
 
  @Override
  public void render(GameContainer gc, StateBasedGame sb, Graphics gr) {
    Vector2f pos = owner.getPosition();
    float scale = owner.getScale();
 
    image.draw(pos.x, pos.y, scale);
  }
 
  @Override
  public void update(GameContainer gc, StateBasedGame sb, int delta) {
    image.rotate(owner.getRotation() - image.getRotation());
  }
  
  public Image getImage(){
    return image;
  }
  
  public void setImage(Image i){
    image=i;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.