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);
root.addComponent(new ColourChangeComponent());