summaryrefslogtreecommitdiff
path: root/src/npc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/npc.rs')
-rw-r--r--src/npc.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/npc.rs b/src/npc.rs
index 729aecd..bc95b6f 100644
--- a/src/npc.rs
+++ b/src/npc.rs
@@ -1,6 +1,6 @@
use ggez::graphics::spritebatch::SpriteBatch;
-use ggez::nalgebra::{distance, Point2};
use ggez::Context;
+use glam::*;
use rand::Rng;
use std::f32::consts::PI;
use std::time::Instant;
@@ -57,7 +57,7 @@ impl NPC {
character: Character,
context: &mut Context,
tileset: &Tileset,
- spawn: Point2<f32>,
+ spawn: glam::Vec2,
map_dimensions: (f32, f32),
) -> NPC {
NPC {
@@ -69,10 +69,10 @@ impl NPC {
}
}
- fn move_torwards(&mut self, destination: Point2<f32>) {
+ fn move_torwards(&mut self, destination: glam::Vec2) {
let position = self.entity.position;
- if distance(&position, &destination) < constants::INTERACT_DISTANCE {
+ if glam::f32::Vec2::distance(position, destination) < constants::INTERACT_DISTANCE {
self.entity.action = Action::IdleRight;
self.behavior = Behavior::Waiting(Instant::now());
} else if (position.x - destination.x).abs() < constants::INTERACT_DISTANCE {
@@ -149,11 +149,11 @@ impl NPC {
enum Behavior {
Talking,
Waiting(Instant),
- Wandering(Point2<f32>),
+ Wandering(glam::Vec2),
}
-pub fn random_nearby_point(origin: Point2<f32>, within_radius: f32) -> Point2<f32> {
+pub fn random_nearby_point(origin: glam::Vec2, within_radius: f32) -> glam::Vec2 {
let w = within_radius * rand::thread_rng().gen_range(0.0, 1.0);
let t = 2.0 * PI * rand::thread_rng().gen_range(0.0, 1.0);
- Point2::new(origin.x + w * t.cos(), origin.y + w * t.sin())
+ glam::Vec2::new(origin.x + w * t.cos(), origin.y + w * t.sin())
}