mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 04:18:25 +08:00
37 lines
913 B
Dart
37 lines
913 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame_isolate_example/constants.dart';
|
|
import 'package:flame_isolate_example/standard/int_vector2.dart';
|
|
|
|
mixin ColonistsObject on PositionComponent {
|
|
IntVector2 get tileSize;
|
|
|
|
IntVector2 get tilePosition => IntVector2(
|
|
x ~/ Constants.tileSize,
|
|
y ~/ Constants.tileSize,
|
|
);
|
|
}
|
|
|
|
abstract class StaticColonistsObject extends SpriteComponent
|
|
with ColonistsObject {
|
|
Sprite get objectSprite;
|
|
|
|
double get difficulty;
|
|
|
|
@override
|
|
IntVector2 get tileSize;
|
|
|
|
@override
|
|
IntVector2 get tilePosition => IntVector2(
|
|
x ~/ Constants.tileSize,
|
|
y ~/ Constants.tileSize,
|
|
);
|
|
|
|
StaticColonistsObject(int x, int y) {
|
|
sprite = objectSprite;
|
|
width = tileSize.x * Constants.tileSize;
|
|
height = tileSize.y * Constants.tileSize;
|
|
super.y = y * Constants.tileSize;
|
|
super.x = x * Constants.tileSize;
|
|
}
|
|
}
|