sarkahn / bevy_ascii_terminal

A simple terminal for rendering ascii in bevy.
MIT License
86 stars 10 forks source link

Multiple terminals with different materials #6

Closed matthemsteger closed 1 year ago

matthemsteger commented 1 year ago

It seems like you cannot assign two different materials to two different terminals. I am trying to create a "typical" UI where the left part of the screen is the main map/game area and the right part (fixed width of 30 tiles) is the UI. What I want to do is assign a tileset of e.g. 8x16 to the UI and 16x16 for the regular UI.

When I do that, it seems like the first texture assigned is the one that is used.

Maybe this will work in the next release, since it looks like updating the font has been made easier?

Here is an example of how I am changing the font

fn load_ui_tileset_system(
    asset_server: Res<AssetServer>,
    mut materials: ResMut<Assets<TerminalMaterial>>,
    mut q_term: Query<&mut Handle<TerminalMaterial>, With<GameUiTerminal>>,
) {
    for mut material_handle in q_term.iter_mut() {
        let mut material = materials
            .get_mut(&*material_handle)
            .expect("Could not get material from terminal");

        let tileset: Handle<Image> = asset_server.get_handle("tilesets/VGA8x16.png");

        material.texture = Some(tileset);
        *material_handle = material_handle.clone();
    }
}
sarkahn commented 1 year ago

I was using the same material for all terminals, fixed for the next release. Thanks for the report!