ComponentSystem cs = ComponentSystem.getInstance();
ParentComponent root = cs.getRoot();
final ParentComponent p1 = new ParentComponent();
p1.addComponent(new PositionComponent(100,100));
SpriteComponent s1 = new SpriteComponent("res/img/square.png", new Vector2f(-25, -25), 50, 50);
s1.setAlwaysOnTop();
p1.addComponent(s1);
p1.addComponent(new MouseFollowerComponent());
p1.addComponent(new CollisionComponent(new CircularCollisionMask(25)));
p1.addComponent(new OrientationComponent(-100));
final SpinComponent spin = new SpinComponent(0.1f);
//p1.addComponent(spin);
EventSystem.getInstance().registerEventListener(new EventListener() {
private int button;
@Override
public void onEvent(Event e) {
int b = ((MousePressedEvent) e).getButton();
if(b != button){
spin.setValue(-spin.getValue());
button = b;
}
p1.addComponent(spin);
}
@Override
public int getUniqueID() {
return 0;
}
@Override
public String getType() {
return "Custom";
}
}, "MousePressed", null);
EventSystem.getInstance().registerEventListener(new EventListener() {
@Override
public void onEvent(Event e) {
p1.removeComponent(spin);
}
@Override
public int getUniqueID() {
return 1;
}
@Override
public String getType() {
return "Custom";
}
}, "MouseReleased", null);
ParentComponent gridParent = SquaresGen.generateGrid(90, 50, 10, 10, 50);
root.addComponent(gridParent);
gridParent.addComponent(new OrbitalVelocityComponent(0.5f, new Vector2f(95, 55)));
ParentComponent p2 = new ParentComponent();
p1.addComponent(p2);
p2.addComponent(new PositionComponent(10, 150));
p2.addComponent(new SpriteComponent("res/img/square.png"));
p2.addComponent(new OrientationComponent(100));
p2.addComponent(new TextRenderComponent("Click to rotate!"));
ParentComponent p3 = new ParentComponent();
p3.addComponent(new PositionComponent (700,100));
p3.addComponent(new SpriteComponent("res/img/line.png",new Vector2f(0, 0), 50, 50));
p3.addComponent(new OrientationComponent(100));
root.addComponent(p1);
root.addComponent(p3);