mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-14 03:40:21 +08:00
* 👌 Use `Offset` type directly in `JoystickAction.update` calculations (#631) * Move files to src and comply with the dart package layout convention * Fixing widgets example Co-authored-by: Serge Matveenko <lig@countzero.co> Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
30 lines
685 B
Dart
30 lines
685 B
Dart
import 'dart:math';
|
|
|
|
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
final game = MyGame();
|
|
runApp(
|
|
GameWidget(
|
|
game: game,
|
|
),
|
|
);
|
|
}
|
|
|
|
class MyGame extends BaseGame {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
final r = Random();
|
|
final image = await images.load('test.png');
|
|
List.generate(500, (i) => SpriteComponent.fromImage(Vector2.all(32), image))
|
|
.forEach((sprite) {
|
|
sprite.x = r.nextInt(size.x.toInt()).toDouble();
|
|
sprite.y = r.nextInt(size.y.toInt()).toDouble();
|
|
add(sprite);
|
|
});
|
|
}
|
|
}
|