mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Merge pull request #174 from gwilymk/fix-clippy-warnings-in-purple-night
Fix clippy warnings in purple night
This commit is contained in:
commit
48f89edc8c
|
@ -67,7 +67,7 @@ fn main() {
|
||||||
write!(&mut writer, "{}", output).unwrap();
|
write!(&mut writer, "{}", output).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_tiles<'a>(layer: &'a tiled::LayerData) -> impl Iterator<Item = u16> + 'a {
|
fn extract_tiles(layer: &'_ tiled::LayerData) -> impl Iterator<Item = u16> + '_ {
|
||||||
match layer {
|
match layer {
|
||||||
tiled::LayerData::Finite(tiles) => {
|
tiled::LayerData::Finite(tiles) => {
|
||||||
tiles.iter().flat_map(|row| row.iter().map(|tile| tile.gid))
|
tiles.iter().flat_map(|row| row.iter().map(|tile| tile.gid))
|
||||||
|
@ -84,17 +84,14 @@ fn get_map_id(tileid: u32) -> u16 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_spawn_locations<'a>(
|
fn get_spawn_locations(
|
||||||
object_group: &'a tiled::ObjectGroup,
|
object_group: &tiled::ObjectGroup,
|
||||||
enemy_type: &str,
|
enemy_type: &str,
|
||||||
) -> (
|
) -> (Vec<u16>, Vec<u16>) {
|
||||||
impl Iterator<Item = u16> + 'a,
|
|
||||||
impl Iterator<Item = u16> + 'a,
|
|
||||||
) {
|
|
||||||
let mut spawns = object_group
|
let mut spawns = object_group
|
||||||
.objects
|
.objects
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|object| &object.obj_type == enemy_type)
|
.filter(|object| object.obj_type == enemy_type)
|
||||||
.map(|object| (object.x as u16, object.y as u16))
|
.map(|object| (object.x as u16, object.y as u16))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
@ -103,5 +100,5 @@ fn get_spawn_locations<'a>(
|
||||||
let xs = spawns.iter().map(|pos| pos.0).collect::<Vec<_>>();
|
let xs = spawns.iter().map(|pos| pos.0).collect::<Vec<_>>();
|
||||||
let ys = spawns.iter().map(|pos| pos.1).collect::<Vec<_>>();
|
let ys = spawns.iter().map(|pos| pos.1).collect::<Vec<_>>();
|
||||||
|
|
||||||
(xs.into_iter(), ys.into_iter())
|
(xs, ys)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ extern crate alloc;
|
||||||
mod rng;
|
mod rng;
|
||||||
mod sfx;
|
mod sfx;
|
||||||
|
|
||||||
|
use core::cmp::Ordering;
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
use rng::get_random;
|
use rng::get_random;
|
||||||
|
@ -324,7 +326,7 @@ impl SwordState {
|
||||||
*counter = 0;
|
*counter = 0;
|
||||||
}
|
}
|
||||||
match self {
|
match self {
|
||||||
SwordState::LongSword => (0 + *counter / 8) * 4,
|
SwordState::LongSword => (*counter / 8) * 4,
|
||||||
SwordState::ShortSword => (41 + *counter / 8) * 4,
|
SwordState::ShortSword => (41 + *counter / 8) * 4,
|
||||||
SwordState::Dagger => (96 + *counter / 8) * 4,
|
SwordState::Dagger => (96 + *counter / 8) * 4,
|
||||||
SwordState::Swordless => (154 + *counter / 8) * 4,
|
SwordState::Swordless => (154 + *counter / 8) * 4,
|
||||||
|
@ -943,12 +945,10 @@ impl SlimeData {
|
||||||
.set_tile_id((29 + self.sprite_offset / 16) * 4);
|
.set_tile_id((29 + self.sprite_offset / 16) * 4);
|
||||||
|
|
||||||
if (player.entity.position - entity.position).manhattan_distance() < 40.into() {
|
if (player.entity.position - entity.position).manhattan_distance() < 40.into() {
|
||||||
let direction = if player.entity.position.x > entity.position.x {
|
let direction = match player.entity.position.x.cmp(&entity.position.x) {
|
||||||
Tri::Positive
|
Ordering::Equal => Tri::Zero,
|
||||||
} else if player.entity.position.x < entity.position.x {
|
Ordering::Greater => Tri::Positive,
|
||||||
Tri::Negative
|
Ordering::Less => Tri::Negative,
|
||||||
} else {
|
|
||||||
Tri::Zero
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.slime_state = SlimeState::Chasing(direction);
|
self.slime_state = SlimeState::Chasing(direction);
|
||||||
|
@ -1200,14 +1200,18 @@ impl EmuData {
|
||||||
.signum();
|
.signum();
|
||||||
entity.velocity.x = velocity;
|
entity.velocity.x = velocity;
|
||||||
|
|
||||||
if velocity > 0.into() {
|
match velocity.cmp(&0.into()) {
|
||||||
entity.sprite.set_hflip(true);
|
Ordering::Greater => {
|
||||||
self.state = EmuState::Charging(Tri::Positive);
|
entity.sprite.set_hflip(true);
|
||||||
} else if velocity < 0.into() {
|
self.state = EmuState::Charging(Tri::Positive);
|
||||||
self.state = EmuState::Charging(Tri::Negative);
|
}
|
||||||
entity.sprite.set_hflip(false);
|
Ordering::Less => {
|
||||||
} else {
|
self.state = EmuState::Charging(Tri::Negative);
|
||||||
self.state = EmuState::Idle;
|
entity.sprite.set_hflip(false);
|
||||||
|
}
|
||||||
|
Ordering::Equal => {
|
||||||
|
self.state = EmuState::Idle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1916,13 +1920,12 @@ impl<'a> Game<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.input.update();
|
self.input.update();
|
||||||
match self.player.update(&self.input, &self.level, sfx) {
|
if let UpdateInstruction::CreateParticle(data, position) =
|
||||||
UpdateInstruction::CreateParticle(data, position) => {
|
self.player.update(&self.input, &self.level, sfx)
|
||||||
let new_particle = Particle::new(object_controller, data, position);
|
{
|
||||||
|
let new_particle = Particle::new(object_controller, data, position);
|
||||||
|
|
||||||
self.particles.insert(new_particle);
|
self.particles.insert(new_particle);
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut remove = Vec::with_capacity(10);
|
let mut remove = Vec::with_capacity(10);
|
||||||
|
|
Loading…
Reference in a new issue