Compare commits

..

No commits in common. "ec796ff97444467dbd8154c41ce4dcb808c0141a" and "67123efa6c1eac17af9debc486000b91c7da39c2" have entirely different histories.

12 changed files with 32 additions and 249 deletions

182
Cargo.lock generated
View File

@ -84,54 +84,6 @@ dependencies = [
"libc",
]
[[package]]
name = "anstream"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
[[package]]
name = "anstyle-parse"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
dependencies = [
"anstyle",
"windows-sys 0.52.0",
]
[[package]]
name = "anyhow"
version = "1.0.76"
@ -315,46 +267,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "clap"
version = "4.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.42",
]
[[package]]
name = "clap_lex"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
[[package]]
name = "codespan-reporting"
version = "0.11.1"
@ -371,12 +283,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "com-rs"
version = "0.2.1"
@ -716,18 +622,14 @@ name = "galactica"
version = "0.0.0"
dependencies = [
"anyhow",
"clap",
"galactica-content",
"galactica-packer",
"galactica-playeragent",
"galactica-render",
"galactica-system",
"galactica-util",
"image",
"nalgebra",
"pollster",
"rand",
"walkdir",
"wgpu",
"winit",
]
@ -973,12 +875,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hexf-parse"
version = "0.2.1"
@ -2007,12 +1903,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "svg_fmt"
version = "0.4.1"
@ -2263,12 +2153,6 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "utf8parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "vec_map"
version = "0.8.2"
@ -2638,15 +2522,6 @@ dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.0",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
@ -2677,21 +2552,6 @@ dependencies = [
"windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.52.0",
"windows_aarch64_msvc 0.52.0",
"windows_i686_gnu 0.52.0",
"windows_i686_msvc 0.52.0",
"windows_x86_64_gnu 0.52.0",
"windows_x86_64_gnullvm 0.52.0",
"windows_x86_64_msvc 0.52.0",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
@ -2704,12 +2564,6 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
@ -2722,12 +2576,6 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
@ -2740,12 +2588,6 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
@ -2758,12 +2600,6 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
@ -2776,12 +2612,6 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
@ -2794,12 +2624,6 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
@ -2812,12 +2636,6 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "winit"
version = "0.28.7"

View File

@ -71,4 +71,3 @@ walkdir = "2.4.0"
toml = "0.8.8"
glyphon = "0.4.1"
lazy_static = "1.4.0"
clap = { version = "4.4.18", features = ["derive"] }

View File

@ -3,7 +3,6 @@
## Currently working on:
- first: remove object array
- first: sticky particles
- first: rework timings
- clickable buttons
- planet outfitter
@ -44,7 +43,7 @@
- User config file
- 🌟 Document content
- 🌟 Clean up content: one ship per file, autodetect
- CLI: content location, logs, etc
- CLI: pack sprites(?), check content, content location, logs, etc
- Better WGSL preprocessor?
- Projectile performance
- Starfield clusters, shader instead of an array?

2
assets

@ -1 +1 @@
Subproject commit e51b880b91e712214db025d97c9fbb3ccb3df7c3
Subproject commit f749d99ae63bcdefb4a62774d21f30a7eebc20d3

View File

@ -26,7 +26,6 @@ galactica-render = { workspace = true }
galactica-util = { workspace = true }
galactica-system = { workspace = true }
galactica-playeragent = { workspace = true }
galactica-packer = { workspace = true }
rand = { workspace = true }
winit = { workspace = true }
@ -34,6 +33,3 @@ wgpu = { workspace = true }
pollster = { workspace = true }
anyhow = { workspace = true }
nalgebra = { workspace = true }
clap = { workspace = true }
walkdir = { workspace = true }
image = { workspace = true }

View File

@ -1 +0,0 @@
pub mod packer;

View File

@ -1,7 +1,6 @@
mod game;
use anyhow::{bail, Result};
use clap::Parser;
use galactica_content::{Content, SystemHandle};
use galactica_playeragent::{PlayerAgent, PlayerStatus};
use galactica_render::RenderInput;
@ -21,38 +20,7 @@ use winit::{
window::WindowBuilder,
};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Run the asset packer
#[arg(long, action, group = "run")]
pack: bool,
/// Check content in the default directory
#[arg(long, action, group = "run")]
check_content: bool,
}
mod cli;
fn main() -> Result<()> {
let args = Args::parse();
let cache_dir = Path::new(ASSET_CACHE);
fs::create_dir_all(cache_dir)?;
if args.pack {
cli::packer::run(Path::new("./assets/render"), cache_dir)?;
} else if args.check_content {
let atlas_index = cache_dir.join("spriteatlas.toml");
let _ = Content::load_dir(
PathBuf::from("./content"),
PathBuf::from("./assets"),
atlas_index.clone(),
)?;
println!("Content was loaded without errors.")
} else {
// Run game
fn main() {
if let Err(err) = try_main() {
eprintln!("Galactica failed with an error");
@ -63,9 +31,6 @@ fn main() -> Result<()> {
}
std::process::exit(1);
}
}
return Ok(());
}
fn try_main() -> Result<()> {
@ -78,11 +43,11 @@ fn try_main() -> Result<()> {
bail!("Could not find sprite atlas!");
}
// TODO: pretty error if missing (also in cli)
// TODO: pretty error if missing
let content = Content::load_dir(
PathBuf::from("./content"),
PathBuf::from("./assets"),
atlas_index,
atlas_index.clone(),
)?;
let event_loop = EventLoop::new();

View File

@ -1,3 +1,7 @@
[[bin]]
name = "galactica-packer"
path = "src/main.rs"
[package]
name = "galactica-packer"
description = "Galactica's sprite packer"

View File

@ -1,5 +1,5 @@
use crate::{SpriteAtlas, SpriteAtlasImage};
use anyhow::{bail, Context, Result};
use galactica_packer::{SpriteAtlas, SpriteAtlasImage};
use image::{imageops, GenericImageView, ImageBuffer, Rgba, RgbaImage};
use std::{
fs::File,
@ -16,7 +16,6 @@ use std::{
// image: a single file
// sprite: a possibly animated texture
/// Builds a set of atlas textures from input image files
pub struct AtlasSet {
/// The width of each atlas
texture_width: u32,
@ -57,7 +56,6 @@ pub struct AtlasSet {
}
impl AtlasSet {
/// Make a new AtlasSet
pub fn new(
texture_width: u32,
texture_height: u32,
@ -225,7 +223,6 @@ impl AtlasSet {
return Ok(atlas_idx);
}
/// Save the index and all atlas files
pub fn save_files<F>(mut self, atlas_path: F, index_path: &Path) -> Result<()>
where
F: Fn(usize) -> PathBuf,
@ -268,7 +265,6 @@ impl AtlasSet {
}
*/
/// Get the current packing efficiency of this set, over all atlases.
pub fn get_efficiency(&self) -> f64 {
self.used_area
/ (self.texture_height as f64

View File

@ -2,9 +2,6 @@
//! This crate creates texture atlases from an asset tree.
mod atlasset;
pub use atlasset::*;
use std::{
collections::HashMap,
num::NonZeroU32,

View File

@ -1,7 +1,10 @@
mod atlasset;
use atlasset::AtlasSet;
use anyhow::{bail, Context, Result};
use galactica_packer::AtlasSet;
use image::io::Reader;
use std::path::Path;
use std::path::{Path, PathBuf};
use walkdir::WalkDir;
// TODO: warning when images have extra transparency
@ -10,9 +13,11 @@ use walkdir::WalkDir;
// TODO: randomly assign sprites to textures, for efficiency
// TODO: group images by use case (dynamic loading algorithm)
pub fn run(asset_root: &Path, cache_target: &Path) -> Result<()> {
fn main() -> Result<()> {
let mut files = Vec::new();
let asset_root = Path::new("./assets/render");
// Total number of pixels we want to add
let mut total_dim = 0f64;
@ -83,8 +88,8 @@ pub fn run(asset_root: &Path, cache_target: &Path) -> Result<()> {
println!("Saving files...");
atlas_set.save_files(
|x| cache_target.join(format!("atlas-{x:0.2}.bmp")),
&cache_target.join("spriteatlas.toml"),
|x| PathBuf::from(format!("cache/atlas-{x:0.2}.bmp")),
&PathBuf::from("cache/spriteatlas.toml"),
)?;
return Ok(());

View File

@ -66,6 +66,8 @@ impl PhysEffect {
parent_angle + effect.angle + rng.gen_range(-effect.angle_rng..=effect.angle_rng)
};
println!("{:?}", effect.angvel_rng);
let rb = RigidBodyBuilder::new(RigidBodyType::KinematicVelocityBased)
.position(pos.into())
.rotation(angle)
@ -75,12 +77,15 @@ impl PhysEffect {
PhysEffect {
anim: SpriteAutomaton::new(ct, effect.sprite),
rigid_body: wrapper.insert_rigid_body(rb.build()),
lifetime: 0f32
.max(effect.lifetime + rng.gen_range(-effect.lifetime_rng..=effect.lifetime_rng)),
// Make sure size isn't negative. This check should be on EVERY rng!
size: 0f32.max(effect.size + rng.gen_range(-effect.size_rng..=effect.size_rng)),
fade: 0f32.max(effect.fade + rng.gen_range(-effect.fade_rng..=effect.fade_rng)),
is_destroyed: false,
}
}