Win text follows camera
This commit is contained in:
		
					parent
					
						
							
								a859d72da3
							
						
					
				
			
			
				commit
				
					
						e5b041c2c9
					
				
			
		
					 2 changed files with 25 additions and 5 deletions
				
			
		|  | @ -17,7 +17,10 @@ | |||
| * (?) multiplayer | ||||
| * more audio | ||||
| * "jumpable" component to avoid jumping on sensors | ||||
| * bug: in level2, move the blue character to win, then reset. The characters are lighter than expected. | ||||
| * bug: in level2, move the blue character to win, then reset. The characters are lighter than expected. (also level 4) | ||||
| * wasm warning | ||||
| * redshift warning | ||||
| * itchio test | ||||
| 
 | ||||
| ## Build | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										25
									
								
								src/game.rs
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								src/game.rs
									
										
									
									
									
								
							|  | @ -52,7 +52,8 @@ impl Plugin for GamePlugin { | |||
| 					.with_system(player_movement_system) | ||||
| 					.with_system(level_keyboard_system) | ||||
| 					.with_system(move_camera) | ||||
| 					.with_system(character_particle_effect_system), | ||||
| 					.with_system(character_particle_effect_system) | ||||
| 					.with_system(move_win_text_system), | ||||
| 			) | ||||
| 			.add_system_to_stage(CoreStage::PostUpdate, collision_event_system); | ||||
| 	} | ||||
|  | @ -101,6 +102,9 @@ pub struct CollisionCount(usize); | |||
| #[derive(Component)] | ||||
| pub struct Melty(pub Color); | ||||
| 
 | ||||
| #[derive(Component)] | ||||
| pub struct WinText; | ||||
| 
 | ||||
| // Systems
 | ||||
| 
 | ||||
| fn setup( | ||||
|  | @ -287,7 +291,7 @@ fn collision_event_system( | |||
| 
 | ||||
| 						// If color approximately white
 | ||||
| 						if app_state.current() == &AppState::Game | ||||
| 							&& Vec4::from(new_color).min_element() >= 0.9 | ||||
| 							&& new_color.min_element() >= 0.9 | ||||
| 						{ | ||||
| 							app_state.replace(AppState::Win).ok(); | ||||
| 						} | ||||
|  | @ -491,7 +495,8 @@ fn win_setup( | |||
| 			transform: Transform::from_xyz(0., 0., 3.), | ||||
| 			..default() | ||||
| 		}) | ||||
| 		.insert(Level); | ||||
| 		.insert(Level) | ||||
| 		.insert(WinText); | ||||
| 	commands | ||||
| 		.spawn_bundle(Text2dBundle { | ||||
| 			text: Text::from_section( | ||||
|  | @ -506,7 +511,8 @@ fn win_setup( | |||
| 			transform: Transform::from_xyz(0., 0., 4.), | ||||
| 			..Default::default() | ||||
| 		}) | ||||
| 		.insert(Level); | ||||
| 		.insert(Level) | ||||
| 		.insert(WinText); | ||||
| } | ||||
| 
 | ||||
| fn move_camera( | ||||
|  | @ -535,6 +541,17 @@ fn move_camera( | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| fn move_win_text_system( | ||||
| 	camera_query: Query<&Transform, With<Camera>>, | ||||
| 	mut win_text_query: Query<&mut Transform, (With<WinText>, Without<Camera>)>, | ||||
| ) { | ||||
| 	let camera_pos = camera_query.single(); | ||||
| 	for mut pos in win_text_query.iter_mut() { | ||||
| 		pos.translation.x = camera_pos.translation.x; | ||||
| 		pos.translation.y = camera_pos.translation.y; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| fn level_keyboard_system( | ||||
| 	mut commands: Commands, | ||||
| 	mut current_level: ResMut<CurrentLevel>, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue