mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 04:18:25 +08:00
As discussed previously, this PR moves the Space Shooter Tutorial to the tutorials folder for direct inclusion in the docs. A few things to note, other than basic grammar and formatting, nothing was changed other than migrating the information to the current tutorial format. This should allow the tutorials.flame-engine.org subdomain to be deleted. Note: Upon moving this tutorial, I discovered it is incomplete and missing the majority of the game. Also, I realized that I left the android folder and some files that weren't necessary for the platform tutorial and have deleted those.
29 lines
602 B
Dart
29 lines
602 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
void main() {
|
|
runApp(GameWidget(game: SpaceShooterGame()));
|
|
}
|
|
|
|
class Player extends PositionComponent {
|
|
static final _paint = Paint()..color = Colors.white;
|
|
@override
|
|
void render(Canvas canvas) {
|
|
canvas.drawRect(size.toRect(), _paint);
|
|
}
|
|
}
|
|
|
|
class SpaceShooterGame extends FlameGame {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
add(
|
|
Player()
|
|
..position = size / 2
|
|
..width = 50
|
|
..height = 100
|
|
..anchor = Anchor.center,
|
|
);
|
|
}
|
|
}
|