aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock30
-rw-r--r--client/makefile15
-rw-r--r--data/makefile5
-rw-r--r--makefile37
-rw-r--r--pixel-client/Cargo.toml2
-rw-r--r--pixel-client/makefile51
-rw-r--r--pixel-client/src/game.rs56
-rw-r--r--pixel-client/src/helper.rs30
-rw-r--r--pixel-client/src/render/misc.rs17
-rw-r--r--pixel-client/src/render/sprite.rs21
-rw-r--r--pixel-client/tools/Cargo.toml2
-rw-r--r--readme.md47
-rw-r--r--server/makefile28
-rw-r--r--test-client/makefile22
14 files changed, 304 insertions, 59 deletions
diff --git a/Cargo.lock b/Cargo.lock
index fb31b8bc..d48a3b6d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -993,21 +993,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e281a65eeba3d4503a2839252f86374528f9ceafe6fed97c1d3b52e1fb625c1"
[[package]]
-name = "light-client"
-version = "0.1.0"
-dependencies = [
- "anyhow",
- "bincode",
- "clap",
- "env_logger",
- "hurrycurry-protocol",
- "log",
- "sdl2",
- "serde_json",
- "tungstenite",
-]
-
-[[package]]
name = "linux-raw-sys"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1232,6 +1217,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
+name = "pixelcurry"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "bincode",
+ "clap",
+ "env_logger",
+ "hurrycurry-protocol",
+ "log",
+ "sdl2",
+ "serde_json",
+ "tungstenite",
+]
+
+[[package]]
name = "pkg-config"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/client/makefile b/client/makefile
index e448e5ac..bacb7f6d 100644
--- a/client/makefile
+++ b/client/makefile
@@ -1,3 +1,18 @@
+# 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/>.
+#
.PHONY: assets clean all
all: assets
assets: menu/book/book_1.webp
diff --git a/data/makefile b/data/makefile
index c9d0ee8a..95dc953a 100644
--- a/data/makefile
+++ b/data/makefile
@@ -17,10 +17,13 @@ all: $(patsubst %.ts,%.yaml,$(wildcard recipes/*.ts))
graphs: $(patsubst %.ts,%.svg,$(wildcard recipes/*.ts))
recipes/%.yaml: recipes/%.ts
- deno run $< > $@
+ DENO_NO_UPDATE_CHECK=1 deno run $< > $@
recipes/%.gv.txt: recipes/%.yaml
{ cd .. && cargo +nightly run --release --bin graph $(patsubst recipes/%.yaml,%,$<); } > $@
recipes/%.svg: recipes/%.gv.txt
dot -Tsvg -Kdot >$@<$<
+
+clean:
+ rm -fr recipes/*.{yaml,gv.txt,svg}
diff --git a/makefile b/makefile
index 873063aa..5bacd060 100644
--- a/makefile
+++ b/makefile
@@ -1,7 +1,36 @@
-.PHONY: all client light-client
-all: client light-client
+# 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/>.
+#
+.PHONY: all client pixel-client test-client server clean data
+all: data server client pixel-client test-client
+data:
+ make -C data all
+server: data
+ make -C server all
client:
make -C client all
-light-client:
- make -C light-client all
+pixel-client:
+ make -C pixel-client all
+test-client:
+ make -C test-client all
+
+clean:
+ make -C data clean
+ make -C server clean
+ make -C client clean
+ make -C pixel-client clean
+ make -C test-client clean
+ cargo clean
diff --git a/pixel-client/Cargo.toml b/pixel-client/Cargo.toml
index d7cb336c..4ffec449 100644
--- a/pixel-client/Cargo.toml
+++ b/pixel-client/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "light-client"
+name = "pixelcurry"
version = "0.1.0"
edition = "2021"
diff --git a/pixel-client/makefile b/pixel-client/makefile
index 6a56fc62..6aa891d3 100644
--- a/pixel-client/makefile
+++ b/pixel-client/makefile
@@ -1,4 +1,18 @@
-
+# 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/>.
+#
SPRITES = $(shell find assets/sprites -name '*.ta')
SPRITES_PNG = $(patsubst %.ta,%.png,$(SPRITES))
@@ -8,7 +22,16 @@ TEXTURES_IMPORT_PNG = $(patsubst %.import.png,%.ta,$(shell find assets/textures
PNG = $(shell find assets/textures -name '*.png')
-.PHONY: tex_pack tex_export tex_import clean
+CLIENT_DEPS = assets/atlas.meta.csv assets/atlas.ta assets/connect.csv assets/palette.csv
+
+IMPORT = ../target/release/tex_import
+EXPORT = ../target/release/tex_export
+PACK = ../target/release/tex_pack
+COMPOSE = ../target/release/tex_compose
+CLIENT = ../target/release/pixelcurry
+
+.PHONY: all tex_pack tex_export tex_import clean
+all: $(CLIENT)
tex_pack: assets/atlas.ta
tex_import: $(TEXTURES_IMPORT_PNG)
tex_export: $(TEXTURES_PNG) $(SPRITES_PNG) assets/atlas.png
@@ -17,21 +40,21 @@ clean:
rm -fr assets/sprites
rm -f assets/atlas.ta assets/atlas.meta.csv
+$(CLIENT): $(shell find src -type f) $(CLIENT_DEPS)
+ cargo build --release --bin pixelcurry
+$(IMPORT) $(EXPORT) $(PACK) $(COMPOSE): $(shell find tools/src -type f)
+ { cd tools; cargo build --release; }
-IMPORT = ../target/release/tex_import
-EXPORT = ../target/release/tex_export
-PACK = ../target/release/tex_pack
-COMPOSE = ../target/release/tex_compose
-
-%.ta: %.import.png
+%.ta: %.import.png $(IMPORT)
$(IMPORT) $< $@
-%.png: %.ta
- ../target/release/tex_export $< $@
+%.png: %.ta $(EXPORT)
+ $(EXPORT) $< $@
-assets/sprites/%/all: assets/%.ini $(TEXTURES)
+assets/sprites/%/all: assets/%.ini $(TEXTURES) $(COMPOSE)
@mkdir -p $(basename $@)
- ../target/release/tex_compose $< assets/textures $(basename $@)
+ $(COMPOSE) $< assets/textures $(basename $@)
@touch $@
-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)
+assets/atlas.ta assets/atlas.meta.csv: assets/sprites/items/all assets/sprites/tiles/all assets/sprites/misc/all $(PACK)
+ @echo $(PACK) assets/atlas.ta assets/atlas.meta.csv ...
+ @$(PACK) assets/atlas.ta assets/atlas.meta.csv $(SPRITES)
diff --git a/pixel-client/src/game.rs b/pixel-client/src/game.rs
index 7d8e466a..170e6a6e 100644
--- a/pixel-client/src/game.rs
+++ b/pixel-client/src/game.rs
@@ -16,7 +16,7 @@
*/
use crate::{
- helper::Vec2InterpolateExt,
+ helper::InterpolateExt,
render::{
misc::MiscTextures,
sprite::{Sprite, SpriteDraw},
@@ -42,6 +42,7 @@ pub struct Game {
tilemap: Tilemap,
collision_map: HashSet<IVec2>,
players: HashMap<PlayerID, Player>,
+ items_removed: Vec<Item>,
my_id: PlayerID,
camera_center: Vec2,
@@ -74,7 +75,9 @@ pub struct Player {
pub struct Item {
position: Vec2,
+ parent_position: Vec2,
kind: ItemIndex,
+ alive: f32,
progress: Option<(f32, bool)>,
}
@@ -90,6 +93,7 @@ impl Game {
movement_send_cooldown: 0.,
misc_textures: MiscTextures::init(layout),
item_sprites: Vec::new(),
+ items_removed: Vec::new(),
interacting: false,
score: Score::default(),
camera_center: Vec2::ZERO,
@@ -187,11 +191,25 @@ impl Game {
}
}
}
- PacketC::MoveItem { from, to } => *self.get_item(to) = self.get_item(from).take(),
+ PacketC::MoveItem { from, to } => {
+ let mut item = self.get_item(from).take();
+ if let Some(item) = &mut item {
+ item.parent_position = self.get_location_position(to);
+ }
+ *self.get_item(to) = item;
+ }
PacketC::SetItem { location, item } => {
- *self.get_item(location) = item.map(|kind| Item {
+ let position = self.get_location_position(location);
+ let slot = match location {
+ ItemLocation::Tile(pos) => &mut self.tiles.get_mut(&pos).unwrap().item,
+ ItemLocation::Player(pid) => &mut self.players.get_mut(&pid).unwrap().item,
+ };
+ self.items_removed.extend(slot.take());
+ *slot = item.map(|kind| Item {
kind,
- position: Vec2::ZERO,
+ parent_position: position,
+ alive: 0.,
+ position,
progress: None,
})
}
@@ -239,6 +257,12 @@ impl Game {
ItemLocation::Player(pid) => &mut self.players.get_mut(&pid).unwrap().item,
}
}
+ pub fn get_location_position(&self, location: ItemLocation) -> Vec2 {
+ match location {
+ ItemLocation::Tile(pos) => pos.as_vec2() + 0.5,
+ ItemLocation::Player(p) => self.players[&p].movement.position,
+ }
+ }
pub fn tick(&mut self, dt: f32, keyboard: &KeyboardState, packet_out: &mut VecDeque<PacketS>) {
let mut direction = IVec2::new(
@@ -289,14 +313,19 @@ impl Game {
for (_pid, player) in &mut self.players {
if let Some(item) = &mut player.item {
- item.position = player.movement.position
+ item.parent_position = player.movement.position;
+ item.tick(1., dt);
}
}
- for (pos, tile) in &mut self.tiles {
+ for (_pos, tile) in &mut self.tiles {
if let Some(item) = &mut tile.item {
- item.position = pos.as_vec2() + 0.5
+ item.tick(1., dt)
}
}
+ self.items_removed.retain_mut(|i| {
+ i.tick(0., dt);
+ i.alive > 0.01
+ })
}
pub fn draw(&self, ctx: &mut SpriteRenderer) {
@@ -315,12 +344,23 @@ impl Game {
item.draw(ctx, &self.item_sprites, &self.misc_textures)
}
}
+ for item in &self.items_removed {
+ item.draw(ctx, &self.item_sprites, &self.misc_textures)
+ }
}
}
impl Item {
+ pub fn tick(&mut self, alive: f32, dt: f32) {
+ self.position.exp_to(self.parent_position, dt * 20.);
+ self.alive.exp_to(alive, dt * 20.)
+ }
pub fn draw(&self, ctx: &mut SpriteRenderer, item_sprites: &[Sprite], misc: &MiscTextures) {
- ctx.draw_world(item_sprites[self.kind.0].at(self.position));
+ ctx.draw_world(
+ item_sprites[self.kind.0]
+ .at(self.position)
+ .alpha(self.alive),
+ );
if let Some((progress, warn)) = self.progress {
let (bg, fg) = if warn {
([100, 0, 0, 200], [255, 0, 0, 200])
diff --git a/pixel-client/src/helper.rs b/pixel-client/src/helper.rs
index 9654f519..168e580f 100644
--- a/pixel-client/src/helper.rs
+++ b/pixel-client/src/helper.rs
@@ -1,11 +1,33 @@
+/*
+ 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 hurrycurry_protocol::glam::Vec2;
-pub trait Vec2InterpolateExt {
- fn exp_to(&mut self, target: Vec2, dt: f32);
+pub trait InterpolateExt {
+ fn exp_to(&mut self, target: Self, dt: f32);
}
-impl Vec2InterpolateExt for Vec2 {
- fn exp_to(&mut self, target: Vec2, dt: f32) {
+impl InterpolateExt for Vec2 {
+ fn exp_to(&mut self, target: Self, dt: f32) {
self.x = target.x + (self.x - target.x) * (-dt).exp();
self.y = target.y + (self.y - target.y) * (-dt).exp();
}
}
+impl InterpolateExt for f32 {
+ fn exp_to(&mut self, target: Self, dt: f32) {
+ *self = target + (*self - target) * (-dt).exp();
+ }
+}
diff --git a/pixel-client/src/render/misc.rs b/pixel-client/src/render/misc.rs
index 9f866568..5b9e43d4 100644
--- a/pixel-client/src/render/misc.rs
+++ b/pixel-client/src/render/misc.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 super::{sprite::Sprite, AtlasLayout};
use hurrycurry_protocol::glam::Vec2;
use sdl2::rect::Rect;
diff --git a/pixel-client/src/render/sprite.rs b/pixel-client/src/render/sprite.rs
index 711f45bf..580146b1 100644
--- a/pixel-client/src/render/sprite.rs
+++ b/pixel-client/src/render/sprite.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 hurrycurry_protocol::glam::Vec2;
use sdl2::rect::{FRect, Rect};
@@ -56,6 +73,10 @@ impl SpriteDraw {
z_order: i32::MAX,
}
}
+ pub fn alpha(mut self, alpha: f32) -> Self {
+ self.tint[3] = (alpha.clamp(0., 1.) * 255.) as u8;
+ self
+ }
}
impl Ord for SpriteDraw {
diff --git a/pixel-client/tools/Cargo.toml b/pixel-client/tools/Cargo.toml
index f3075594..3392352b 100644
--- a/pixel-client/tools/Cargo.toml
+++ b/pixel-client/tools/Cargo.toml
@@ -9,4 +9,4 @@ anyhow = "1.0.86"
log = "0.4.22"
env_logger = "0.11.3"
clap = { version = "4.5.9", features = ["derive"] }
-sdl2 = "0.37.0"
+sdl2 = { version = "0.37.0", features = ["image", "ttf"] }
diff --git a/readme.md b/readme.md
index e153ae74..3b289a61 100644
--- a/readme.md
+++ b/readme.md
@@ -5,8 +5,8 @@ A cooperative multiplayer game about cooking.
The protocol is documented in [protocol.md](protocol.md).
If you happen to be using pacman you can add or manually download pre-built
-packages https://pkg.metamuffin.org/. These also include documentation and a
-systemd service.
+packages from https://pkg.metamuffin.org/. These also include documentation,
+systemd services and .desktop files.
## Client
@@ -14,13 +14,16 @@ systemd service.
- Requirements:
- Godot 4.2
-- `make client-assets`
-- `cd client`
-- Import all assets: `godot --import .`
+ - cURL
+
+```
+make client
+godot --import client/project.godot
+```
### Usage
-- `godot .`
+- `godot client/project.godot`
## Server
@@ -29,8 +32,10 @@ systemd service.
- Requirements:
- Nightly rust toolchain
- Deno
-- Build game data: `make -C data`
-- Build the server program: `cargo +nightly build --release`
+
+```
+make test-client
+```
### Usage
@@ -39,14 +44,34 @@ systemd service.
server in the source folder should work.
- Run the server: `./target/release/hurrycurry-server`
+## Pixel Client
+
+### Building
+
+- Requirements:
+ - Nightly rust toolchain
+ - SDL2 development libraries
+
+```
+make pixel-client
+```
+
+### Usage
+
+```
+cargo run --bin pixel-client
+```
+
## Test Client
### Building
-- Requirements: `esbuild`
+- Requirements:
+ - esbuild
-- Compile typescript:
- `esbuild test-client/main.ts --bundle --outdir=test-client --target=esnext --format=esm`
+```
+make test-client
+```
### Usage
diff --git a/server/makefile b/server/makefile
new file mode 100644
index 00000000..b80ff3b8
--- /dev/null
+++ b/server/makefile
@@ -0,0 +1,28 @@
+# 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/>.
+#
+
+SERVER = ../target/release/hurrycurry-server
+REPLAYTOOL = ../target/release/hurrycurry-replaytool
+
+.PHONY: all
+all: $(SERVER) $(REPLAYTOOL)
+clean:
+
+$(SERVER): $(shell find protocol src -type f)
+ cargo build --release
+$(REPLAYTOOL): $(shell find protocol replaytool -type f)
+ { cd replaytool; cargo build --release; }
+
diff --git a/test-client/makefile b/test-client/makefile
new file mode 100644
index 00000000..2a83f5d0
--- /dev/null
+++ b/test-client/makefile
@@ -0,0 +1,22 @@
+# 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/>.
+#
+.PHONY: all clean
+all: main.js
+clean:
+ rm main.js
+
+main.js: main.ts $(wildcard *.ts)
+ esbuild $< --bundle --outfile=$@ --target=esnext --format=esm