Files
Renan ccee9a466b Move files to src and comply with the dart package layout convention (#621)
* 👌 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>
2021-01-20 09:05:43 -03:00

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);
});
}
}