|
@@ -13,9 +13,9 @@ use crate::behavior::order::Order;
|
13
|
13
|
use crate::behavior::ItemBehavior;
|
14
|
14
|
use crate::config::{
|
15
|
15
|
ANIMATE_EACH, DEBUG, DEFAULT_SELECTED_SQUARE_SIDE, DEFAULT_SELECTED_SQUARE_SIDE_HALF,
|
16
|
|
- DISPLAY_OFFSET_BY, DISPLAY_OFFSET_BY_SPEED, MAX_FRAME_I, META_EACH,
|
17
|
|
- MOVE_TO_REACHED_WHEN_DISTANCE_INFERIOR_AT, PHYSICS_EACH, SCENE_ITEMS_CHANGE_ERR_MSG,
|
18
|
|
- SPRITE_EACH, TARGET_FPS,
|
|
16
|
+ DISPLAY_OFFSET_BY, DISPLAY_OFFSET_BY_SPEED, MAX_FRAME_I, META_EACH, MOVE_FAST_VELOCITY,
|
|
17
|
+ MOVE_HIDE_VELOCITY, MOVE_TO_REACHED_WHEN_DISTANCE_INFERIOR_AT, MOVE_VELOCITY, PHYSICS_EACH,
|
|
18
|
+ SCENE_ITEMS_CHANGE_ERR_MSG, SPRITE_EACH, TARGET_FPS,
|
19
|
19
|
};
|
20
|
20
|
use crate::physics::util::scene_point_from_window_point;
|
21
|
21
|
use crate::physics::util::window_point_from_scene_point;
|
|
@@ -185,7 +185,8 @@ impl MainState {
|
185
|
185
|
}
|
186
|
186
|
SceneItemPrepareOrder::Hide(scene_item_usize) => {
|
187
|
187
|
let mut scene_item = self.get_scene_item_mut(*scene_item_usize);
|
188
|
|
- scene_item.next_order = Some(Order::HideTo(scene_click_point));}
|
|
188
|
+ scene_item.next_order = Some(Order::HideTo(scene_click_point));
|
|
189
|
+ }
|
189
|
190
|
}
|
190
|
191
|
|
191
|
192
|
self.scene_item_prepare_order = None;
|
|
@@ -255,16 +256,27 @@ impl MainState {
|
255
|
256
|
// Scene items movements
|
256
|
257
|
for scene_item in self.scene_items.iter_mut() {
|
257
|
258
|
match scene_item.state.current_behavior {
|
258
|
|
- ItemBehavior::MoveTo(scene_point) => {
|
|
259
|
+ ItemBehavior::Standing => {}
|
|
260
|
+ ItemBehavior::MoveTo(move_to_scene_point)
|
|
261
|
+ | ItemBehavior::MoveFastTo(move_to_scene_point)
|
|
262
|
+ | ItemBehavior::HideTo(move_to_scene_point) => {
|
|
263
|
+ let velocity = match &scene_item.state.current_behavior {
|
|
264
|
+ ItemBehavior::MoveTo(_) => MOVE_VELOCITY,
|
|
265
|
+ ItemBehavior::MoveFastTo(_) => MOVE_FAST_VELOCITY,
|
|
266
|
+ ItemBehavior::HideTo(_) => MOVE_HIDE_VELOCITY,
|
|
267
|
+ _ => {
|
|
268
|
+ panic!("This code should not be reached")
|
|
269
|
+ }
|
|
270
|
+ };
|
259
|
271
|
// FIXME BS NOW: velocity
|
260
|
|
- let move_vector = (scene_point - scene_item.position).normalize() * 1.0;
|
|
272
|
+ let move_vector =
|
|
273
|
+ (move_to_scene_point - scene_item.position).normalize() * velocity;
|
261
|
274
|
// TODO ici il faut calculer le déplacement réél (en fonction des ticks, etc ...)
|
262
|
275
|
scene_item.position.x += move_vector.x;
|
263
|
276
|
scene_item.position.y += move_vector.y;
|
264
|
277
|
scene_item.grid_position =
|
265
|
278
|
util::grid_position_from_scene_point(&scene_item.position);
|
266
|
279
|
}
|
267
|
|
- _ => {}
|
268
|
280
|
}
|
269
|
281
|
}
|
270
|
282
|
|
|
@@ -463,7 +475,15 @@ impl MainState {
|
463
|
475
|
) -> GameResult<MeshBuilder> {
|
464
|
476
|
if let Some(scene_item_prepare_order) = &self.scene_item_prepare_order {
|
465
|
477
|
match scene_item_prepare_order {
|
466
|
|
- SceneItemPrepareOrder::Move(scene_item_usize) => {
|
|
478
|
+ SceneItemPrepareOrder::Move(scene_item_usize)
|
|
479
|
+ | SceneItemPrepareOrder::MoveFast(scene_item_usize)
|
|
480
|
+ | SceneItemPrepareOrder::Hide(scene_item_usize) => {
|
|
481
|
+ let color = match &scene_item_prepare_order {
|
|
482
|
+ SceneItemPrepareOrder::Move(_) => graphics::BLUE,
|
|
483
|
+ SceneItemPrepareOrder::MoveFast(_) => graphics::MAGENTA,
|
|
484
|
+ SceneItemPrepareOrder::Hide(_) => graphics::YELLOW,
|
|
485
|
+ };
|
|
486
|
+
|
467
|
487
|
let scene_item = self.get_scene_item(*scene_item_usize);
|
468
|
488
|
mesh_builder.line(
|
469
|
489
|
&vec![
|
|
@@ -474,7 +494,7 @@ impl MainState {
|
474
|
494
|
),
|
475
|
495
|
],
|
476
|
496
|
2.0,
|
477
|
|
- graphics::WHITE,
|
|
497
|
+ color,
|
478
|
498
|
)?;
|
479
|
499
|
}
|
480
|
500
|
}
|