revert app_root_dir usages in examples. re-org example asset files

ultimately, cargo workspaces are kind of weird. you can do things like
`cargo run` from the top-level cargo.toml file and run an individual
sub-module via `--bin`, or you can go to that sub-module's directory
where it's own cargo.toml is, and `cargo run` directly from there.

the current working directory will be different in each case, and this
difference can be very annoying when you want to do seemingly-logical
things like organize sub-module "asset" files (e.g. images, and other
types of data files that aren't code) within that sub-module's
directory. in this case, how do you write code in that sub-module that
can load those asset files in a way that will work in BOTH of the
aforementioned scenarios for `cargo run`?

you can't really! some people use the `CARGO_MANIFEST_DIR` environment
variable that cargo sets when running any given cargo module, but this
is only a valid method for obtaining the module's root directory when
running from a cargo command ... which you won't be doing when running
within a debugger! likely you or your IDE invoked the debugger process
against the already built executable directly, so `CARGO_MANIFEST_DIR`
will not be set and you're back to square one!

super annoying!

as such, i am now giving up and am just doing what it seems like most
other cargo projects that utilize workspaces do ... place all the
assets for all sub-modules together in the same directory, relative
to the workspace root.

why go with this approach?

because it works under the most common scenarios (but NOT all!):
- running via `cargo run --bin` from the workspace root
- debugging via gdb/lldb etc using the workspace root as the cwd

these seem to be the most common ways to do each type of task from
any rust-equipped editor/IDE that i've seen so far.
This commit is contained in:
Gered 2024-09-05 22:35:20 -04:00
parent 4d359f3e3c
commit c7d6bd8aef
36 changed files with 31 additions and 52 deletions

View file

@ -58,11 +58,11 @@ fn main() -> Result<()> {
let mut volume = 1.0;
let sounds = [
load_and_convert_wav(system.app_root_dir.join("./assets/pickup-coin.wav"), system.res.audio.spec())?,
load_and_convert_wav(system.app_root_dir.join("./assets/powerup.wav"), system.res.audio.spec())?,
load_and_convert_wav(system.app_root_dir.join("./assets/explosion.wav"), system.res.audio.spec())?,
load_and_convert_wav(system.app_root_dir.join("./assets/jump.wav"), system.res.audio.spec())?,
load_and_convert_wav(system.app_root_dir.join("./assets/laser-shoot.wav"), system.res.audio.spec())?,
load_and_convert_wav("./assets/pickup-coin.wav", system.res.audio.spec())?,
load_and_convert_wav("./assets/powerup.wav", system.res.audio.spec())?,
load_and_convert_wav("./assets/explosion.wav", system.res.audio.spec())?,
load_and_convert_wav("./assets/jump.wav", system.res.audio.spec())?,
load_and_convert_wav("./assets/laser-shoot.wav", system.res.audio.spec())?,
];
let mut statuses = [AudioChannelStatus { size: 0, position: 0, playing: false }; NUM_CHANNELS];

View file

@ -24,7 +24,7 @@ fn main() -> Result<()> {
let font = BitmaskFont::new_vga_font()?;
let (balls_bmp, balls_palette) = IndexedBitmap::load_pcx_file(system.app_root_dir.join("./assets/balls.pcx"))?;
let (balls_bmp, balls_palette) = IndexedBitmap::load_pcx_file("./assets/balls.pcx")?;
system.res.palette = balls_palette.clone();
let mut sprites = Vec::<IndexedBitmap>::new();

Binary file not shown.

View file

@ -25,7 +25,7 @@ impl Game {
pub fn new(mut system: System<DosLike>) -> Result<Self> {
let font = BitmaskFont::new_vga_font()?;
let (balls_bmp, balls_palette) = IndexedBitmap::load_pcx_file(system.app_root_dir.join("./assets/balls.pcx"))?;
let (balls_bmp, balls_palette) = IndexedBitmap::load_pcx_file("./assets/balls.pcx")?;
system.res.palette = balls_palette.clone();
let mut sprites = Vec::new();

View file

@ -90,17 +90,17 @@ impl AppContext<Standard> for GameContext {
impl GameContext {
pub fn new(system: System<Standard>) -> Result<Self> {
let palette = load_palette(system.app_root_dir.join("./assets/db16.pal"))?;
let palette = load_palette("./assets/db16.pal")?;
let font = load_font(system.app_root_dir.join("./assets/dp.fnt"))?;
let small_font = load_font(system.app_root_dir.join("./assets/small.fnt"))?;
let font = load_font("./assets/dp.fnt")?;
let small_font = load_font("./assets/small.fnt")?;
let tiles = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/tiles.pcx"))?);
let green_slime = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/green_slime.pcx"))?);
let blue_slime = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/blue_slime.pcx"))?);
let orange_slime = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/orange_slime.pcx"))?);
let tiles = Rc::new(load_bitmap_atlas_autogrid("./assets/tiles.pcx")?);
let green_slime = Rc::new(load_bitmap_atlas_autogrid("./assets/green_slime.pcx")?);
let blue_slime = Rc::new(load_bitmap_atlas_autogrid("./assets/blue_slime.pcx")?);
let orange_slime = Rc::new(load_bitmap_atlas_autogrid("./assets/orange_slime.pcx")?);
let tilemap = TileMap::load_from(system.app_root_dir.join("./assets/arena.map.json"))?;
let tilemap = TileMap::load_from("./assets/arena.map.json")?;
let entities = Entities::new();
let component_systems = ComponentSystems::new();

View file

@ -1,9 +0,0 @@
{
"width":40,
"height":30,
"layers":[
[96,96,96,96,96,96,96,96,96,96,96,96,16,17,16,16,16,16,16,17,17,32,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,33,16,16,96,96,96,96,96,96,96,96,96,96,96,16,17,17,17,32,17,32,16,16,32,16,16,32,16,16,16,16,16,16,32,16,33,16,16,16,16,16,16,16,96,96,96,96,96,96,96,96,96,96,181,178,178,178,178,183,32,16,17,181,178,178,178,178,178,178,178,178,178,178,178,183,16,16,16,16,16,16,16,32,96,96,96,96,96,96,96,96,96,181,195,16,32,17,17,193,178,178,178,195,16,16,16,16,16,16,32,16,16,16,16,193,178,183,16,32,16,16,16,16,96,96,96,96,96,96,96,181,178,195,16,16,16,32,17,17,17,17,32,16,16,16,33,16,16,16,16,16,16,16,16,16,16,193,183,16,16,16,33,16,96,96,96,96,96,96,181,195,32,16,16,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,16,193,183,16,16,16,16,16,17,16,16,96,181,195,16,16,33,16,16,16,16,16,32,16,16,16,16,16,32,16,16,16,16,48,48,48,48,16,16,16,16,16,196,16,16,16,16,32,16,17,16,181,195,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,48,48,48,48,48,48,48,48,16,16,32,193,183,16,32,16,8,8,8,181,195,16,16,16,16,17,32,16,16,16,16,16,16,16,16,16,16,16,16,48,48,48,48,48,48,48,48,48,48,16,16,16,196,16,16,16,7,7,7,196,16,32,16,32,17,17,17,16,16,16,16,33,16,16,16,16,16,16,48,48,48,48,48,48,48,48,48,48,48,48,16,16,193,183,16,32,7,7,181,195,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,32,16,16,16,48,48,48,48,48,48,48,48,48,48,48,48,32,16,196,32,16,7,7,196,16,16,32,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,48,48,48,48,48,48,48,48,48,16,16,16,196,16,16,7,7,196,8,8,16,16,16,16,16,16,32,16,16,16,16,32,16,16,16,16,16,16,16,16,48,48,48,48,48,48,48,48,16,16,16,16,196,17,16,7,7,196,7,7,16,16,16,16,16,16,16,16,16,33,16,16,16,16,16,16,16,16,16,32,16,16,48,48,48,48,48,16,16,16,16,16,196,17,16,7,7,196,7,7,16,16,16,16,16,33,16,16,16,16,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,196,17,16,16,16,196,16,33,16,16,16,16,16,16,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,196,32,16,16,16,196,16,16,16,16,16,32,16,16,16,16,32,16,16,16,32,16,16,16,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,196,16,16,16,16,196,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,16,16,16,16,16,16,16,33,16,16,16,16,16,32,16,196,16,33,32,16,196,16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,33,16,16,16,16,16,16,16,16,16,16,16,16,16,196,32,16,16,16,196,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,16,16,16,16,16,196,16,16,16,16,193,183,16,16,48,48,48,48,48,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,196,32,16,32,16,33,196,48,48,48,48,48,48,48,48,16,16,16,16,16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,196,16,16,16,16,16,193,183,48,48,48,48,48,48,48,48,16,16,32,16,16,16,16,16,16,16,16,33,16,16,16,16,16,16,16,16,16,16,16,16,196,16,16,16,32,16,16,196,48,48,48,48,48,48,48,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,16,196,16,16,16,16,16,16,193,183,48,48,48,48,48,48,48,48,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,181,195,16,16,16,16,16,16,16,193,183,48,48,48,48,48,48,48,48,48,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,196,16,16,16,16,16,16,16,16,16,193,178,178,183,48,48,48,48,48,48,48,48,16,16,16,16,16,32,16,16,16,16,32,16,16,16,16,16,16,181,195,16,16,16,32,16,16,33,16,32,16,16,16,193,178,178,178,178,178,178,178,178,183,16,32,16,16,16,16,16,33,16,16,16,16,16,16,181,178,195,32,16,16,16,16,16,16,16,16,16,16,32,16,16,16,16,16,16,16,33,32,17,193,178,178,178,178,178,178,178,178,178,178,178,178,178,178,195,16,16,16,16,16,48,16,16,32,16,16,16,16,16,16,16,16,16,16,32,16,16,16,16,32,16,16,32,16,16,16,32,16,16,16,33,16,16,32,16,16,16,16,16,48,48],
[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,87,-1,104,108,108,108,105,-1,-1,-1,-1,-1,80,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,98,105,-1,-1,-1,26,-1,26,80,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,27,-1,-1,-1,80,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,80,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,80,-1,-1,-1,-1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1,0,1,1,0,1,1,0,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -107,30 +107,30 @@ impl AppContext<DosLike> for Game {
impl Game {
pub fn new(mut system: System<DosLike>) -> Result<Self> {
let palette = load_palette(system.app_root_dir.join("./assets/db16.pal"))?;
let palette = load_palette("./assets/db16.pal")?;
system.res.palette = palette.clone();
let font = load_font(system.app_root_dir.join("./assets/dp.fnt"))?;
let font = load_font("./assets/dp.fnt")?;
let tiles = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/tiles.pcx"))?);
let hero_male = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/hero_male.pcx"))?);
let hero_female = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/hero_female.pcx"))?);
let green_slime = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/green_slime.pcx"))?);
let blue_slime = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/blue_slime.pcx"))?);
let orange_slime = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/orange_slime.pcx"))?);
let fist = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/fist.pcx"))?);
let sword = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/sword.pcx"))?);
let particles = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/particles.pcx"))?);
let items = Rc::new(load_bitmap_atlas_autogrid(system.app_root_dir.join("./assets/items.pcx"))?);
let tiles = Rc::new(load_bitmap_atlas_autogrid("./assets/tiles.pcx")?);
let hero_male = Rc::new(load_bitmap_atlas_autogrid("./assets/hero_male.pcx")?);
let hero_female = Rc::new(load_bitmap_atlas_autogrid("./assets/hero_female.pcx")?);
let green_slime = Rc::new(load_bitmap_atlas_autogrid("./assets/green_slime.pcx")?);
let blue_slime = Rc::new(load_bitmap_atlas_autogrid("./assets/blue_slime.pcx")?);
let orange_slime = Rc::new(load_bitmap_atlas_autogrid("./assets/orange_slime.pcx")?);
let fist = Rc::new(load_bitmap_atlas_autogrid("./assets/fist.pcx")?);
let sword = Rc::new(load_bitmap_atlas_autogrid("./assets/sword.pcx")?);
let particles = Rc::new(load_bitmap_atlas_autogrid("./assets/particles.pcx")?);
let items = Rc::new(load_bitmap_atlas_autogrid("./assets/items.pcx")?);
let mut ui = load_bitmap_atlas(system.app_root_dir.join("./assets/ui.pcx"))?;
let mut ui = load_bitmap_atlas("./assets/ui.pcx")?;
ui.add(Rect::new(0, 0, 16, 16))?;
ui.add(Rect::new(16, 0, 16, 16))?;
for i in 0..8 {
ui.add(Rect::new(i * 8, 16, 8, 8))?;
}
let tilemap = TileMap::load_from(system.app_root_dir.join("./assets/title_screen.map.json"))?;
let tilemap = TileMap::load_from("./assets/title_screen.map.json")?;
let entities = Entities::new();
let component_systems = ComponentSystems::new();

View file

@ -86,13 +86,7 @@ impl AppState<Game> for MainMenuState {
fn state_change(&mut self, new_state: State, old_state: State, context: &mut Game) {
match new_state {
State::Pending | State::Resume => {
init_everything(
context,
context.core.system.app_root_dir.join("./assets/title_screen.map.json"),
0.2,
1.0,
32,
);
init_everything(context, "./assets/title_screen.map.json", 0.2, 1.0, 32);
}
State::TransitionIn => {
self.fade = 0.0;
@ -223,13 +217,7 @@ impl AppState<Game> for GamePlayState {
fn state_change(&mut self, new_state: State, old_state: State, context: &mut Game) {
match new_state {
State::Pending => {
init_everything(
context,
context.core.system.app_root_dir.join("./assets/arena.map.json"),
0.5,
2.0,
100,
);
init_everything(context, "./assets/arena.map.json", 0.5, 2.0, 100);
spawn_player_randomly(&mut context.core);
}
State::TransitionIn => {