class Square extends PositionComponent {
var rotationSpeed = 0.3;
var velocity = Vector2(0, 0).normalized() * 25;
var squareSize = 128.0;
var color = BasicPalette.white.paint()
..style = PaintingStyle.stroke
..strokeWidth = 2;
@override
Future<void> onLoad() async {
super.onLoad();
size.setValues(squareSize, squareSize);
anchor = Anchor.topRight;
}
@override
void update(double dt) {
super.update(dt);
position += velocity * dt;
var angleDelta = dt * rotationSpeed;
angle = (angle + angleDelta) % (2 * pi);
}
@override
void render(Canvas canvas) {
super.render(canvas);
canvas.drawRect(size.toRect(), color);
}
}
angle = (angle + angleDelta) % (2 * pi);