This fixes the bug where you get 'stuck' while moving and passing an enemy. Need to sort out why this fixes it though. Closes #30.
This commit is contained in:
		
							parent
							
								
									ba5fc73127
								
							
						
					
					
						commit
						9c5bad5959
					
				
					 3 changed files with 6 additions and 9 deletions
				
			
		|  | @ -67,7 +67,7 @@ namespace gui { | |||
|   void FSM::MOVING(Event ) { | ||||
|     // this should be an optional that returns a point
 | ||||
|     if(auto move_to = $main_ui.play_move()) { | ||||
|       System::plan_motion(*move_to); | ||||
|       System::move_player(*move_to); | ||||
|       run_systems(); | ||||
|       $main_ui.dirty(); | ||||
|       state(State::IDLE); | ||||
|  |  | |||
							
								
								
									
										11
									
								
								systems.cpp
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								systems.cpp
									
										
									
									
									
								
							|  | @ -407,15 +407,12 @@ void System::device(World &world, Entity actor, Entity item) { | |||
|   } | ||||
| } | ||||
| 
 | ||||
| void System::plan_motion(Position move_to) { | ||||
| void System::move_player(Position move_to) { | ||||
|   auto& level = GameDB::current_level(); | ||||
|   auto& player_pos = GameDB::player_position(); | ||||
|   auto old_pos = level.world->get<Position>(level.player); | ||||
| 
 | ||||
|   player_pos.aiming_at = move_to.aiming_at; | ||||
| 
 | ||||
|   auto& motion = level.world->get<Motion>(level.player); | ||||
|   motion.dx = move_to.location.x - player_pos.location.x; | ||||
|   motion.dy = move_to.location.y - player_pos.location.y; | ||||
|   level.world->set<Position>(level.player, move_to); | ||||
|   level.collision->move(old_pos.location, move_to.location, level.player); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ namespace System { | |||
|   void enemy_ai_initialize(); | ||||
| 
 | ||||
|   void device(World &world, Entity actor, Entity item); | ||||
|   void plan_motion(Position move_to); | ||||
|   void move_player(Position move_to); | ||||
|   Entity spawn_item(World& world, const string& name); | ||||
|   void drop_item(Entity item); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Zed A. Shaw
						Zed A. Shaw