mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
base update order on initial positions
This commit is contained in:
parent
2a02da1c2f
commit
31c5519bc8
|
@ -41,7 +41,10 @@ impl Simulation {
|
|||
let mut entities = EntityMap::default();
|
||||
let mut animation = Animation::default();
|
||||
|
||||
for (item, location) in a {
|
||||
let mut entities_to_add: Vec<_> = a.collect();
|
||||
entities_to_add.sort_unstable_by_key(|(_, location)| location.x + location.y * 100);
|
||||
|
||||
for (item, location) in entities_to_add {
|
||||
animation.populate(entities.add(item, location), sfx);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use core::ops::Neg;
|
||||
|
||||
use agb::fixnum::Vector2D;
|
||||
use alloc::{boxed::Box, collections::VecDeque, vec::Vec};
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use slotmap::{new_key_type, SlotMap};
|
||||
|
||||
use crate::{
|
||||
|
@ -311,7 +311,7 @@ impl EntityMap {
|
|||
|
||||
let mut animations = Vec::new();
|
||||
|
||||
let mut entities_to_try_update = self
|
||||
let entities_to_try_update = self
|
||||
.map
|
||||
.iter()
|
||||
.map(|(key, entity)| (key, entity.desired_action(hero)))
|
||||
|
@ -321,13 +321,6 @@ impl EntityMap {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
entities_to_try_update.sort_unstable_by_key(|(e, _)| {
|
||||
let e = self.map.get(*e).unwrap();
|
||||
e.location.x + e.location.y * 1000
|
||||
});
|
||||
|
||||
let entities_to_try_update = entities_to_try_update;
|
||||
|
||||
for (entity_to_update_key, direction) in entities_to_try_update.iter().copied() {
|
||||
let (_, hero_has_died_result, win_has_triggered_result) = self
|
||||
.attempt_move_in_direction(
|
||||
|
|
Loading…
Reference in a new issue