mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	Added flame_oxygen (#823)
* Added flame_oxygen * Reworked structure * Added components and example * Added particle support * Updated code * Update example * Fixed mistake * Update * Updated documentation * Added system documentation * Fixed line length * Added most components docs * Docs done? * Update doc/oxygen.md Co-authored-by: Erick <erickzanardoo@gmail.com> * Added GameRef * Fixed GameRef * Reworked library to not use part system * Added GameRef docs * Removed library line * Updated CHANGELOG * Added License * Fixed linting problem * Update packages/flame_oxygen/example/lib/main.dart Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com> * Update after review from spydon * Added flipping * Fixed CI/CD * Fix * Update * Update doc/oxygen.md Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com> Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>
This commit is contained in:
		 Jochum van der Ploeg
					Jochum van der Ploeg
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							bdb4306ac5
						
					
				
				
					commit
					c015af8bee
				
			
							
								
								
									
										56
									
								
								packages/flame_oxygen/example/lib/system/move_system.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								packages/flame_oxygen/example/lib/system/move_system.dart
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | ||||
| import 'package:flame/extensions.dart'; | ||||
| import 'package:flame/game.dart'; | ||||
| import 'package:flame_oxygen/flame_oxygen.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
|  | ||||
| import '../component/timer_component.dart'; | ||||
| import '../component/velocity_component.dart'; | ||||
| import '../main.dart'; | ||||
|  | ||||
| class MoveSystem extends System with UpdateSystem, GameRef<ExampleGame> { | ||||
|   Query? _query; | ||||
|  | ||||
|   @override | ||||
|   void init() { | ||||
|     _query = createQuery([ | ||||
|       Has<PositionComponent>(), | ||||
|       Has<VelocityComponent>(), | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   void dispose() { | ||||
|     _query = null; | ||||
|     super.dispose(); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   void update(double delta) { | ||||
|     for (final entity in _query?.entities ?? <Entity>[]) { | ||||
|       final velocity = entity.get<VelocityComponent>()!.velocity; | ||||
|       final size = entity.get<SizeComponent>()!.size; | ||||
|       final position = entity.get<PositionComponent>()!.position | ||||
|         ..add(velocity * delta); | ||||
|  | ||||
|       final screenSize = Vector2.zero() & game!.size; | ||||
|       if (!screenSize.containsPoint(position) || | ||||
|           !screenSize.containsPoint(position + size)) { | ||||
|         velocity.setFrom(-velocity); | ||||
|  | ||||
|         game!.createEntity( | ||||
|           name: '${entity.name} says', | ||||
|           position: position + size / 2, | ||||
|           size: Vector2.zero(), | ||||
|           anchor: Anchor.topCenter, | ||||
|         ) | ||||
|           ..add<TextComponent, TextInit>( | ||||
|             TextInit( | ||||
|               'Kawabunga', | ||||
|               config: const TextPaintConfig(color: Colors.blue, fontSize: 12), | ||||
|             ), | ||||
|           ) | ||||
|           ..add<TimerComponent, double>(3); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user