Auto stash before merge of "level/tiled" and "origin/level/tiled"
This commit is contained in:
parent
ae75f99bc2
commit
1a94016a11
4
game/assets/levels_tmx/abwsx3mzcgs21.tsx
Normal file
4
game/assets/levels_tmx/abwsx3mzcgs21.tsx
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.5" tiledversion="1.7.2" name="abwsx3mzcgs21" tilewidth="32" tileheight="32" tilecount="864" columns="36">
|
||||
<image source="../../../../../../Downloads/abwsx3mzcgs21.png" width="1152" height="768"/>
|
||||
</tileset>
|
9
game/assets/levels_tmx/test_map.tmx
Normal file
9
game/assets/levels_tmx/test_map.tmx
Normal file
File diff suppressed because one or more lines are too long
@ -3,7 +3,7 @@ use std::{io::Write, path::Path};
|
||||
use raylib::{texture::Texture2D, RaylibHandle, RaylibThread};
|
||||
use tempfile::{tempdir, NamedTempFile};
|
||||
use tracing::debug;
|
||||
|
||||
use tiled::*;
|
||||
/// Contains all game assets.
|
||||
///
|
||||
/// This uses macro magic to automatically embed the contents of `game/assets/` into the executable
|
||||
@ -65,3 +65,24 @@ pub fn load_texture_from_internal_data(
|
||||
|
||||
Ok(texture)
|
||||
}
|
||||
|
||||
// Loading specific to level files.
|
||||
pub fn load_map_from_internal_data(path: &str) -> Result<Map, ResourceLoadError> {
|
||||
|
||||
let temp_dir = tempdir()?;
|
||||
let tmp_path = temp_dir.path().join(Path::new(path).filename().unwrap());
|
||||
|
||||
std::fs::write(&tmp_path,
|
||||
&StaticGameData::get(path)
|
||||
.ok_or(ResourceLoadError::AssetNotFound(path.to_string()))?
|
||||
.data,
|
||||
)?;
|
||||
|
||||
|
||||
let map_file = File::open(tmp_path.to_str())?;
|
||||
let level = parse(map_file).unwrap();
|
||||
|
||||
temp_dir.close()?;
|
||||
|
||||
Ok(level);
|
||||
}
|
||||
|
Reference in New Issue
Block a user