aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--light-client/Cargo.toml1
-rw-r--r--light-client/assets/misc.ini2
-rw-r--r--light-client/makefile22
-rw-r--r--light-client/src/game.rs202
-rw-r--r--light-client/src/main.rs27
-rw-r--r--light-client/src/network.rs56
-rw-r--r--light-client/src/sprite_renderer.rs62
-rw-r--r--light-client/src/tilemap.rs19
-rw-r--r--light-client/tools/src/bin/tex_pack.rs2
-rw-r--r--server/protocol/src/lib.rs2
-rw-r--r--server/protocol/src/movement.rs (renamed from server/src/customer/movement.rs)25
-rw-r--r--server/src/customer/mod.rs6
-rw-r--r--server/src/customer/pathfinding.rs4
14 files changed, 368 insertions, 63 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 15385fb2..44d7b1a3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -998,6 +998,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"bincode",
+ "clap",
"env_logger",
"hurrycurry-protocol",
"log",
diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml
index ec8b75ec..d7cb336c 100644
--- a/light-client/Cargo.toml
+++ b/light-client/Cargo.toml
@@ -12,3 +12,4 @@ bincode = "2.0.0-rc.3"
log = "0.4.22"
env_logger = "0.11.3"
anyhow = "1.0.86"
+clap = { version = "4.5.9", features = ["derive"] }
diff --git a/light-client/assets/misc.ini b/light-client/assets/misc.ini
new file mode 100644
index 00000000..07052b90
--- /dev/null
+++ b/light-client/assets/misc.ini
@@ -0,0 +1,2 @@
+
+player=player
diff --git a/light-client/makefile b/light-client/makefile
index 4f900412..6a56fc62 100644
--- a/light-client/makefile
+++ b/light-client/makefile
@@ -14,20 +14,24 @@ tex_import: $(TEXTURES_IMPORT_PNG)
tex_export: $(TEXTURES_PNG) $(SPRITES_PNG) assets/atlas.png
clean:
rm -f $(PNG)
- rm -f $(SPRITES)
+ rm -fr assets/sprites
rm -f assets/atlas.ta assets/atlas.meta.csv
+
+IMPORT = ../target/release/tex_import
+EXPORT = ../target/release/tex_export
+PACK = ../target/release/tex_pack
+COMPOSE = ../target/release/tex_compose
+
%.ta: %.import.png
- ../target/release/tex_import $< $@
+ $(IMPORT) $< $@
%.png: %.ta
../target/release/tex_export $< $@
-assets/sprites/items/all: assets/items.ini $(TEXTURES)
- @mkdir -p assets/sprites/items
- ../target/release/tex_compose $< assets/textures assets/sprites/items
-assets/sprites/tiles/all: assets/tiles.ini $(TEXTURES)
- @mkdir -p assets/sprites/tiles
- ../target/release/tex_compose $< assets/textures assets/sprites/tiles
+assets/sprites/%/all: assets/%.ini $(TEXTURES)
+ @mkdir -p $(basename $@)
+ ../target/release/tex_compose $< assets/textures $(basename $@)
+ @touch $@
-assets/atlas.ta assets/atlas.meta.csv: assets/sprites/items/all assets/sprites/tiles/all
+assets/atlas.ta assets/atlas.meta.csv: assets/sprites/items/all assets/sprites/tiles/all assets/sprites/misc/all
../target/release/tex_pack assets/atlas.ta assets/atlas.meta.csv $(SPRITES)
diff --git a/light-client/src/game.rs b/light-client/src/game.rs
index ed1cb7fe..b35a15d7 100644
--- a/light-client/src/game.rs
+++ b/light-client/src/game.rs
@@ -15,25 +15,47 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-use crate::{sprite_renderer::SpriteRenderer, tilemap::Tilemap};
+use crate::{
+ sprite_renderer::{SpriteRect, SpriteRenderer},
+ tilemap::Tilemap,
+};
use hurrycurry_protocol::{
glam::{IVec2, Vec2},
- PacketC, PlayerID, TileIndex,
+ movement::MovementBase,
+ ClientGamedata, ItemIndex, ItemLocation, PacketC, PacketS, PlayerID, TileIndex,
+};
+use log::{info, warn};
+use sdl2::{
+ keyboard::{KeyboardState, Scancode},
+ rect::{FRect, Rect},
};
-use std::collections::HashMap;
+use std::collections::{HashMap, HashSet, VecDeque};
pub struct Game {
+ data: ClientGamedata,
tiles: HashMap<IVec2, Tile>,
tilemap: Tilemap,
+ collision_map: HashSet<IVec2>,
players: HashMap<PlayerID, Player>,
+ my_id: PlayerID,
+
+ item_sprites: Vec<SpriteRect>,
+ movement_send_cooldown: f32,
}
pub struct Tile {
kind: TileIndex,
+ item: Option<Item>,
}
pub struct Player {
+ movement: MovementBase,
+ item: Option<Item>,
+ name: String,
character: i32,
+}
+pub struct Item {
position: Vec2,
+ kind: ItemIndex,
}
impl Game {
@@ -42,13 +64,33 @@ impl Game {
tiles: HashMap::new(),
players: HashMap::new(),
tilemap: Tilemap::default(),
+ my_id: PlayerID(0),
+ data: ClientGamedata::default(),
+ collision_map: HashSet::new(),
+ movement_send_cooldown: 0.,
+ item_sprites: Vec::new(),
}
}
pub fn packet_in(&mut self, packet: PacketC, renderer: &mut SpriteRenderer) {
match packet {
+ PacketC::Init { id } => self.my_id = id,
PacketC::Data { data } => {
self.tilemap.init(&data.tile_names, renderer.metadata());
+ self.item_sprites = data
+ .item_names
+ .iter()
+ .map(|name| {
+ SpriteRect::new(
+ renderer
+ .metadata()
+ .get(&format!("{name}:a"))
+ .copied()
+ .unwrap_or(Rect::new(0, 0, 32, 24)),
+ )
+ })
+ .collect();
+ self.data = data;
}
PacketC::UpdateMap {
tile,
@@ -56,17 +98,167 @@ impl Game {
neighbors,
} => {
if let Some(kind) = kind {
- self.tiles.insert(tile, Tile { kind });
+ self.tiles.insert(tile, Tile { kind, item: None });
+ if self.data.tile_collide[kind.0] {
+ self.collision_map.remove(&tile);
+ } else {
+ self.collision_map.insert(tile);
+ }
} else {
self.tiles.remove(&tile);
+ self.collision_map.remove(&tile);
}
self.tilemap.set(tile, kind, neighbors);
}
+ PacketC::AddPlayer {
+ id,
+ position,
+ character,
+ name,
+ } => {
+ info!("add player {} {name:?}", id.0);
+ self.players.insert(
+ id,
+ Player {
+ character,
+ name,
+ item: None,
+ movement: MovementBase {
+ position,
+ facing: Vec2::X,
+ rotation: 0.,
+ velocity: Vec2::ZERO,
+ boosting: false,
+ stamina: 0.,
+ },
+ },
+ );
+ }
+ PacketC::RemovePlayer { id } => {
+ info!("remove player {}", id.0);
+ self.players.remove(&id);
+ }
+ PacketC::Position {
+ player,
+ pos,
+ rot,
+ boosting,
+ } => {
+ if player != self.my_id {
+ if let Some(p) = self.players.get_mut(&player) {
+ p.movement.position = pos;
+ p.movement.rotation = rot;
+ p.movement.boosting = boosting;
+ }
+ }
+ }
+ PacketC::MoveItem { from, to } => *self.get_item(to) = self.get_item(from).take(),
+ PacketC::SetItem { location, item } => {
+ *self.get_item(location) = item.map(|kind| Item {
+ kind,
+ position: Vec2::ZERO,
+ })
+ }
+ PacketC::SetProgress {
+ item,
+ progress,
+ warn,
+ } => (),
+ PacketC::Collide { player, force } => (),
+ PacketC::Communicate {
+ player,
+ message,
+ persist,
+ } => (),
+ PacketC::ServerMessage { text } => (),
+ PacketC::Score {
+ points,
+ demands_failed,
+ demands_completed,
+ time_remaining,
+ } => (),
+ PacketC::SetIngame { state, lobby } => (),
+ PacketC::Error { message } => {
+ warn!("server error: {message:?}")
+ }
_ => (),
}
}
+ pub fn get_item(&mut self, location: ItemLocation) -> &mut Option<Item> {
+ match location {
+ ItemLocation::Tile(pos) => &mut self.tiles.get_mut(&pos).unwrap().item,
+ ItemLocation::Player(pid) => &mut self.players.get_mut(&pid).unwrap().item,
+ }
+ }
+
+ pub fn tick(&mut self, dt: f32, keyboard: &KeyboardState, packet_out: &mut VecDeque<PacketS>) {
+ let direction = IVec2::new(
+ keyboard.is_scancode_pressed(Scancode::D) as i32
+ - keyboard.is_scancode_pressed(Scancode::A) as i32,
+ keyboard.is_scancode_pressed(Scancode::S) as i32
+ - keyboard.is_scancode_pressed(Scancode::W) as i32,
+ )
+ .as_vec2();
+ let boost = keyboard.is_scancode_pressed(Scancode::K);
+ let interact = keyboard.is_scancode_pressed(Scancode::Space)
+ | keyboard.is_scancode_pressed(Scancode::J);
+
+ self.movement_send_cooldown -= dt;
+ let send_movement = self.movement_send_cooldown < 0.;
+ if send_movement {
+ self.movement_send_cooldown += 0.04
+ }
+
+ for (pid, player) in &mut self.players {
+ if *pid == self.my_id {
+ let movement_packet =
+ player
+ .movement
+ .update(&self.collision_map, direction, boost, dt);
+
+ if send_movement {
+ packet_out.push_back(movement_packet);
+ }
+ }
+ if let Some(item) = &mut player.item {
+ item.position = player.movement.position
+ }
+ }
+ for (pos, tile) in &mut self.tiles {
+ if let Some(item) = &mut tile.item {
+ item.position = pos.as_vec2() + 0.5
+ }
+ }
+ }
+
pub fn draw(&self, ctx: &mut SpriteRenderer) {
- self.tilemap.draw(ctx)
+ self.tilemap.draw(ctx);
+
+ for p in self.players.values() {
+ let src = ctx.misc_textures().player;
+ let dst = FRect::new(
+ p.movement.position.x - src.width() as f32 / 32. / 2.,
+ p.movement.position.y + 0.3 - src.height() as f32 / 24.,
+ src.width() as f32 / 32.,
+ src.height() as f32 / 24.,
+ );
+ ctx.draw(dst.y + dst.h + 1., src, dst);
+ if let Some(item) = &p.item {
+ item.draw(ctx, &self.item_sprites)
+ }
+ }
+ for tile in self.tiles.values() {
+ if let Some(item) = &tile.item {
+ item.draw(ctx, &self.item_sprites)
+ }
+ }
+ }
+}
+
+impl Item {
+ pub fn draw(&self, ctx: &mut SpriteRenderer, item_sprites: &[SpriteRect]) {
+ eprintln!("item {} at {}", self.kind.0, self.position);
+ item_sprites[self.kind.0].draw_at(ctx, self.position)
}
}
diff --git a/light-client/src/main.rs b/light-client/src/main.rs
index 5e79aa85..b00ba734 100644
--- a/light-client/src/main.rs
+++ b/light-client/src/main.rs
@@ -1,5 +1,3 @@
-use std::time::Instant;
-
/*
Hurry Curry! - a game about cooking
Copyright 2024 metamuffin
@@ -19,8 +17,13 @@ use std::time::Instant;
*/
use game::Game;
use network::Network;
-use sdl2::{event::Event, keyboard::Keycode, pixels::Color};
+use sdl2::{
+ event::Event,
+ keyboard::{KeyboardState, Keycode},
+ pixels::Color,
+};
use sprite_renderer::SpriteRenderer;
+use std::time::{Duration, Instant};
pub mod game;
pub mod network;
@@ -28,6 +31,8 @@ pub mod sprite_renderer;
pub mod tilemap;
fn main() {
+ env_logger::init_from_env("LOG");
+
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let window = video_subsystem
@@ -50,6 +55,15 @@ fn main() {
let mut game = Game::new();
let mut renderer = SpriteRenderer::init(&texture_creator);
+ net.queue_out.push_back(hurrycurry_protocol::PacketS::Join {
+ name: "light".to_string(),
+ character: 0,
+ });
+
+ let mut events = sdl_context.event_pump().unwrap();
+
+ let mut last_tick = Instant::now();
+
'mainloop: loop {
net.poll();
@@ -57,6 +71,11 @@ fn main() {
game.packet_in(packet, &mut renderer);
}
+ let keyboard = KeyboardState::new(&events);
+ let dt = last_tick.elapsed().min(Duration::from_secs_f32(1. / 30.));
+ game.tick(dt.as_secs_f32(), &keyboard, &mut net.queue_out);
+ last_tick += dt;
+
game.draw(&mut renderer);
canvas.set_draw_color(Color::BLACK);
@@ -64,7 +83,7 @@ fn main() {
renderer.submit(&mut canvas);
canvas.present();
- for event in sdl_context.event_pump().unwrap().poll_iter() {
+ for event in events.poll_iter() {
match event {
Event::Quit { .. }
| Event::KeyDown {
diff --git a/light-client/src/network.rs b/light-client/src/network.rs
index 997a3344..ed160773 100644
--- a/light-client/src/network.rs
+++ b/light-client/src/network.rs
@@ -17,13 +17,14 @@
*/
use anyhow::Result;
use hurrycurry_protocol::{PacketC, PacketS, BINCODE_CONFIG};
-use log::warn;
+use log::{debug, warn};
use std::{collections::VecDeque, net::TcpStream};
use tungstenite::{
client::{uri_mode, IntoClientRequest},
client_tls_with_config,
handshake::client::Request,
stream::{MaybeTlsStream, Mode},
+ util::NonBlockingError,
Message, WebSocket,
};
@@ -74,34 +75,49 @@ impl Network {
})
}
pub fn poll(&mut self) {
- self.queue_in.extend(match self.sock.read() {
- Ok(Message::Text(packet)) => match serde_json::from_str(&packet) {
- Ok(p) => Some(p),
- Err(e) => {
- warn!("invalid json packet: {e:?}");
- None
- }
- },
- Ok(Message::Binary(packet)) => {
- match bincode::decode_from_slice(&packet, BINCODE_CONFIG) {
- Ok((p, _)) => Some(p),
+ loop {
+ self.queue_in.extend(match self.sock.read() {
+ Ok(Message::Text(packet)) => match serde_json::from_str(&packet) {
+ Ok(packet) => {
+ debug!("<- {packet:?}");
+ Some(packet)
+ }
Err(e) => {
- warn!("invalid bincode packet: {e:?}");
+ warn!("invalid json packet: {e:?}");
None
}
+ },
+ Ok(Message::Binary(packet)) => {
+ match bincode::decode_from_slice(&packet, BINCODE_CONFIG) {
+ Ok((packet, _)) => {
+ debug!("<- {packet:?}");
+ Some(packet)
+ }
+ Err(e) => {
+ warn!("invalid bincode packet: {e:?}");
+ None
+ }
+ }
}
- }
- Ok(_) => None,
- Err(e) => {
- warn!("{e:?}");
- None
- }
- });
+ Ok(_) => None,
+ Err(e) => {
+ if let Some(e) = e.into_non_blocking() {
+ warn!("{e:?}");
+ None
+ } else {
+ break;
+ }
+ }
+ });
+ }
for packet in self.queue_out.drain(..) {
+ debug!("-> {packet:?}");
self.sock
.write(Message::Text(serde_json::to_string(&packet).unwrap()))
.unwrap();
}
+
+ self.sock.flush().unwrap();
}
}
diff --git a/light-client/src/sprite_renderer.rs b/light-client/src/sprite_renderer.rs
index 64eef8f6..aadbfbe3 100644
--- a/light-client/src/sprite_renderer.rs
+++ b/light-client/src/sprite_renderer.rs
@@ -26,6 +26,8 @@ use std::collections::HashMap;
pub struct SpriteRenderer<'a> {
metadata: HashMap<String, Rect>,
+ misc_textures: MiscTextures,
+
texture: Texture<'a>,
view_scale: Vec2,
@@ -34,12 +36,22 @@ pub struct SpriteRenderer<'a> {
sprites: Vec<SpriteDraw>,
}
+pub struct MiscTextures {
+ pub player: Rect,
+}
+
pub struct SpriteDraw {
z_order: i32,
src: Rect,
dst: FRect,
}
+pub struct SpriteRect {
+ z_offset: f32,
+ src: Rect,
+ relative_dst: FRect,
+}
+
impl<'a> SpriteRenderer<'a> {
pub fn init(texture_creator: &'a TextureCreator<WindowContext>) -> Self {
let palette = include_str!("../assets/palette.csv")
@@ -101,27 +113,35 @@ impl<'a> SpriteRenderer<'a> {
.collect::<HashMap<_, _>>();
Self {
+ misc_textures: MiscTextures {
+ player: *metadata.get("player+a").unwrap(),
+ },
texture,
metadata,
sprites: vec![],
view_offset: Vec2::ZERO,
- view_scale: Vec2::splat(64.),
+ view_scale: Vec2::splat(3.),
}
}
+ #[inline]
pub fn metadata(&self) -> &HashMap<String, Rect> {
&self.metadata
}
+ #[inline]
+ pub fn misc_textures(&self) -> &MiscTextures {
+ &self.misc_textures
+ }
- pub fn draw(&mut self, z_order: i32, src: Rect, dst: FRect) {
+ pub fn draw(&mut self, z_order: f32, src: Rect, dst: FRect) {
self.sprites.push(SpriteDraw {
- z_order,
+ z_order: (z_order * 24.) as i32,
src,
dst: FRect::new(
- (dst.x + self.view_offset.x) * self.view_scale.x,
- (dst.y + self.view_offset.y) * self.view_scale.y,
- dst.w * self.view_scale.x,
- dst.h * self.view_scale.y,
+ ((dst.x + self.view_offset.x) * 32.).round() * self.view_scale.x,
+ ((dst.y + self.view_offset.y) * 24.).round() * self.view_scale.y,
+ (dst.w * 32.).round() * self.view_scale.x,
+ (dst.h * 24.).round() * self.view_scale.y,
),
})
}
@@ -150,3 +170,31 @@ impl PartialEq for SpriteDraw {
self.z_order == other.z_order && self.src == other.src && self.dst == other.dst
}
}
+
+impl SpriteRect {
+ pub fn draw_at(&self, ctx: &mut SpriteRenderer, pos: Vec2) {
+ ctx.draw(
+ self.z_offset + pos.y + 5.,
+ self.src,
+ FRect::new(
+ self.relative_dst.x + pos.x,
+ self.relative_dst.y + pos.y,
+ self.relative_dst.w,
+ self.relative_dst.h,
+ ),
+ )
+ }
+ pub fn new(src: Rect) -> Self {
+ let relative_dst = FRect::new(
+ 0.0 - src.width() as f32 / 32. / 2.,
+ 0.3 - src.height() as f32 / 24.,
+ src.width() as f32 / 32.,
+ src.height() as f32 / 24.,
+ );
+ Self {
+ z_offset: -relative_dst.h,
+ relative_dst,
+ src,
+ }
+ }
+}
diff --git a/light-client/src/tilemap.rs b/light-client/src/tilemap.rs
index cd0f13ac..e84db8b1 100644
--- a/light-client/src/tilemap.rs
+++ b/light-client/src/tilemap.rs
@@ -1,3 +1,20 @@
+/*
+ Hurry Curry! - a game about cooking
+ Copyright 2024 metamuffin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, version 3 of the License only.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+*/
use crate::sprite_renderer::SpriteRenderer;
use hurrycurry_protocol::{glam::IVec2, TileIndex};
use sdl2::rect::{FRect, Rect};
@@ -71,7 +88,7 @@ impl Tilemap {
pub fn draw(&self, ctx: &mut SpriteRenderer) {
for &(src, dst) in self.tiles.values() {
- ctx.draw(((dst.y + dst.h) * 32.) as i32, src, dst);
+ ctx.draw(dst.y + dst.h, src, dst);
}
}
}
diff --git a/light-client/tools/src/bin/tex_pack.rs b/light-client/tools/src/bin/tex_pack.rs
index e6d73ab3..1258b5bf 100644
--- a/light-client/tools/src/bin/tex_pack.rs
+++ b/light-client/tools/src/bin/tex_pack.rs
@@ -60,7 +60,7 @@ fn main() {
cursor_x = 0;
}
if cursor_y + height > atlas_size {
- panic!("texture too big or atlas full")
+ panic!("texture too big or atlas full");
}
row_height = row_height.max(atlas_size);
let texcoord = [cursor_x, cursor_y, width, height];
diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs
index 895af376..f2a6dd27 100644
--- a/server/protocol/src/lib.rs
+++ b/server/protocol/src/lib.rs
@@ -28,6 +28,8 @@ use std::{
pub use glam;
+pub mod movement;
+
pub const VERSION: (u32, u32) = (1, 0);
pub const BINCODE_CONFIG: Configuration<LittleEndian, Varint, Limit<4096>> =
diff --git a/server/src/customer/movement.rs b/server/protocol/src/movement.rs
index 34ed5b16..486da816 100644
--- a/server/src/customer/movement.rs
+++ b/server/protocol/src/movement.rs
@@ -16,7 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-use hurrycurry_protocol::{glam::{IVec2, Vec2}, PacketS};
+use crate::{
+ glam::{IVec2, Vec2},
+ PacketS,
+};
use std::collections::HashSet;
const PLAYER_SIZE: f32 = 0.4;
@@ -29,7 +32,8 @@ const BOOST_RESTORE: f32 = 0.5;
pub struct MovementBase {
pub position: Vec2,
pub facing: Vec2,
- pub vel: Vec2,
+ pub rotation: f32,
+ pub velocity: Vec2,
pub boosting: bool,
pub stamina: f32,
}
@@ -39,9 +43,10 @@ impl MovementBase {
Self {
position,
facing: Vec2::X,
- vel: Vec2::ZERO,
+ velocity: Vec2::ZERO,
boosting: false,
stamina: 0.,
+ rotation: 0.,
}
}
pub fn update(
@@ -55,7 +60,7 @@ impl MovementBase {
if direction.length() > 0.1 {
self.facing = direction + (self.facing - direction) * (-dt * 10.).exp();
}
- let rot = self.facing.x.atan2(self.facing.y);
+ self.rotation = self.facing.x.atan2(self.facing.y);
boost &= direction.length() > 0.1;
self.boosting = boost && (self.boosting || self.stamina >= 1.) && self.stamina > 0.;
self.stamina += if self.boosting {
@@ -65,15 +70,15 @@ impl MovementBase {
};
self.stamina = self.stamina.max(0.).min(1.);
let speed = PLAYER_SPEED * if self.boosting { BOOST_FACTOR } else { 1. };
- self.vel += direction * dt * speed;
- self.position += self.vel * dt;
- self.vel = self.vel * (-dt * PLAYER_FRICTION).exp();
+ self.velocity += direction * dt * speed;
+ self.position += self.velocity * dt;
+ self.velocity = self.velocity * (-dt * PLAYER_FRICTION).exp();
collide_player(self, map);
PacketS::Position {
pos: self.position,
- boosting: false,
- rot,
+ boosting: self.boosting,
+ rot: self.rotation,
}
}
}
@@ -98,7 +103,7 @@ pub fn collide_player(p: &mut MovementBase, map: &HashSet<IVec2>) {
let grad = (Vec2::new(d_sample_x, d_sample_y) - d) / h;
p.position += (PLAYER_SIZE - d) * grad;
- p.vel -= grad * grad.dot(p.vel);
+ p.velocity -= grad * grad.dot(p.velocity);
}
}
}
diff --git a/server/src/customer/mod.rs b/server/src/customer/mod.rs
index aeaa7ae1..bf385927 100644
--- a/server/src/customer/mod.rs
+++ b/server/src/customer/mod.rs
@@ -15,15 +15,15 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-pub mod movement;
mod pathfinding;
use crate::{data::Gamedata, game::Tile};
use anyhow::{anyhow, Result};
use fake::{faker, Fake};
-use hurrycurry_protocol::{glam::IVec2, DemandIndex, Message, PacketS, PlayerID};
+use hurrycurry_protocol::{
+ glam::IVec2, movement::MovementBase, DemandIndex, Message, PacketS, PlayerID,
+};
use log::info;
-use movement::MovementBase;
use pathfinding::{find_path, Path};
use rand::{random, thread_rng};
use std::{
diff --git a/server/src/customer/pathfinding.rs b/server/src/customer/pathfinding.rs
index 2b9f98f4..d1e1e997 100644
--- a/server/src/customer/pathfinding.rs
+++ b/server/src/customer/pathfinding.rs
@@ -15,10 +15,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-use super::movement::MovementBase;
use hurrycurry_protocol::{
- glam::{IVec2, Vec2},
- PacketS,
+ glam::{IVec2, Vec2}, movement::MovementBase, PacketS
};
use log::trace;
use std::{