generated from bbarker/bevy_game_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
60 lines (51 loc) · 1.71 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
extern crate embed_resource;
#[path = "src/build_common.rs"]
mod build_common;
use build_common::*;
use image::{imageops, RgbaImage};
use std::env;
use std::fs;
fn main() {
let file_names = [
"nothing.png",
"grass_top.png",
"dirt.png",
"water.png",
"grass1.png",
"grass_tan.png",
"grass_brown.png",
"wheat_side.png",
"wheat_top.png",
"wheat_sprouts.png",
]; // Example filenames
// Load the first image to get width and height
let source_path = asset_source_path();
let target_size = 32;
let mut concatenated_image = RgbaImage::new(target_size, target_size * file_names.len() as u32);
file_names.iter().enumerate().for_each(|(ii, file_name)| {
let image_path = source_path.join(file_name);
let image = image::open(image_path)
.expect("Failed to load image")
.resize_exact(target_size, target_size, imageops::FilterType::Nearest);
image::imageops::overlay(
&mut concatenated_image,
&image,
0,
ii as i64 * (target_size as i64),
);
});
let dest_file = tile_texture_pack_path();
fs::create_dir_all(asset_texture_path()).expect("Failed to create destination directory");
concatenated_image
.save(dest_file.clone())
.expect("Failed to save concatenated image");
println!(
"Tile texture assembly complete: {}",
dest_file.as_path().to_str().unwrap_or("")
);
let target = env::var("TARGET").unwrap();
if target.contains("windows") {
// on windows we will set our game icon as icon for the executable
embed_resource::compile("build/windows/icon.rc");
}
}