mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +08:00 
			
		
		
		
	 3bdb90fb5c
			
		
	
	3bdb90fb5c
	
	
	
		
			
			* Adding flame_lint and removing dart code metrics * Update packages/flame_flare/example/pubspec.yaml * updating analyze action * adding missing dardoc dep on flame_lint * removing test folder from the lint package * fixing sdk versions * license and changeog fix * Update packages/flame_lint/README.md Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com> * additional readme fix Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:math';
 | |
| 
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame_oxygen/flame_oxygen.dart';
 | |
| import 'package:flutter/foundation.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| 
 | |
| import 'component/timer_component.dart';
 | |
| import 'component/velocity_component.dart';
 | |
| import 'system/debug_system.dart';
 | |
| import 'system/kawabunga_system.dart';
 | |
| import 'system/move_system.dart';
 | |
| import 'system/sprite_system.dart';
 | |
| 
 | |
| void main() {
 | |
|   runApp(GameWidget(game: ExampleGame()));
 | |
| }
 | |
| 
 | |
| class ExampleGame extends OxygenGame with FPSCounter {
 | |
|   @override
 | |
|   Future<void> init() async {
 | |
|     if (kDebugMode) {
 | |
|       world.registerSystem(DebugSystem());
 | |
|     }
 | |
|     world.registerSystem(MoveSystem());
 | |
|     world.registerSystem(SpriteSystem());
 | |
|     world.registerSystem(KawabungaSystem());
 | |
| 
 | |
|     world.registerComponent<TimerComponent, double>(() => TimerComponent());
 | |
|     world.registerComponent<VelocityComponent, Vector2>(
 | |
|       () => VelocityComponent(),
 | |
|     );
 | |
| 
 | |
|     final random = Random();
 | |
|     for (var i = 0; i < 10; i++) {
 | |
|       createEntity(
 | |
|         name: 'Entity $i',
 | |
|         position: size / 2,
 | |
|         size: Vector2.all(64),
 | |
|         angle: 0,
 | |
|       )
 | |
|         ..add<SpriteComponent, SpriteInit>(
 | |
|           SpriteInit(await loadSprite('pizza.png')),
 | |
|         )
 | |
|         ..add<VelocityComponent, Vector2>(
 | |
|           Vector2(
 | |
|             random.nextDouble() * 100 * (random.nextBool() ? 1 : -1),
 | |
|             random.nextDouble() * 100 * (random.nextBool() ? 1 : -1),
 | |
|           ),
 | |
|         );
 | |
|     }
 | |
|   }
 | |
| }
 |