Giter VIP home page Giter VIP logo

seldom_pixel's People

Contributors

larsonjj avatar marcotoniut avatar seldom-se avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

seldom_pixel's Issues

Finish Bevy 0.12 updates

  • Update to new bevy_ecs_tilemap release, when that's available
  • Fix particle feature
  • Fix state example

WASM Compatibility

I've been trying to compile this crate in a new bevy project to WASM using trunk the provided text example, but am running into issues. The main error I'm seeing in the browser console is as follows:

panicked at 'Resource requested by seldom_pixel::screen::update_screen_palette does not exist: seldom_pixel::palette::Palette', C:\Users\jakej\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.10.1\src\system\system_param.rs:460:17

Any chance there is a way to resolve this issue? Or is WASM not a supported target?

Panic when trying to spawn text as a child of a node bundle

Hi, while attempting to incorporate bitmap fonts into my code I came across this plugin. Unfortunately, creating a pixel perfect UI in bevy is a hassle, right now I'm simply trying to add the PxTextBundle as a child to NodeBundle. Here's the code:

use bevy::prelude::*;
use seldom_pixel::prelude::*;

use crate::ui::{
    menu_handler::MenuHandlerPlugin, seldom_ui::SeldomUiPlugin,
    ui_pixel_perfect::UiPixelPerfectPlugin,
};

use self::{common::InGameCamera, seldom_ui::Layer};

mod bounty;
mod common;
mod inventory;
mod menu_handler;
mod seldom_ui;
mod ui_pixel_perfect;

#[derive(Component)]
///Struct for main menu component
pub struct MainMenuComponent;

/// Struct to define the UI plugin
pub struct UiPlugin;

impl Plugin for UiPlugin {
    fn build(&self, app: &mut App) {
        info!("Building UI plugin...");
        app.add_systems(Startup, init_ui);
        app.add_plugins(SeldomUiPlugin);
        //app.add_plugins(MenuHandlerPlugin);
    }
}

fn init_ui(
    mut commands: Commands,
    query: Query<Entity, With<InGameCamera>>,
    mut typefaces: PxAssets<PxTypeface>,
) {
    let camera_entity = query.get_single().expect("No InGameCamera");

    commands
        .spawn((
            NodeBundle {
                style: Style {
                    flex_direction: FlexDirection::Column,
                    justify_content: JustifyContent::SpaceBetween,
                    align_items: AlignItems::Stretch,
                    width: Val::Percent(100.),
                    height: Val::Percent(100.),
                    padding: UiRect {
                        left: Val::Px(10.),
                        right: Val::Px(10.),
                        top: Val::Px(10.),
                        bottom: Val::Px(10.),
                    },
                    ..Default::default()
                },
                background_color: Color::BISQUE.into(),
                ..Default::default()
            },
            MainMenuComponent,
            TargetCamera(camera_entity),
        ))
        .with_children(|builder| {
            builder.spawn(PxTextBundle::<Layer> {
                text: "Testing".into(),
                typeface: typefaces.load(
                    "typefaces/3x5spaceremoved.png",
                    &"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~".chars().rev().collect::<String>(),
                    [(' ', 3)]),
                rect: IRect::new(0, 0, 64, 64).into(),
                ..default()
            });
        });
}

The SeldomUI Plugin i made

use bevy::prelude::*;
use seldom_pixel::prelude::*;

use super::common::InGameCamera;

pub struct SeldomUiPlugin;

impl Plugin for SeldomUiPlugin {
    fn build(&self, app: &mut App) {
        info!("Building Seldom UI plugin...");
        app.add_plugins(PxPlugin::<Layer>::new(
            UVec2::new(480, 270),
            "palettes/palette_1.png".into(),
        ));
        app.insert_resource(ClearColor(Color::BLACK));
        app.add_systems(PreStartup, init);
    }
}

fn init(mut commands: Commands) {
    commands.spawn((Camera2dBundle::default(), InGameCamera));
}

#[px_layer]
pub struct Layer;

Here's the panic:

thread '<unnamed>' panicked at dreambound_lib/src/ui/mod.rs:39:44:
No InGameCamera: NoEntities("bevy_ecs::query::state::QueryState<bevy_ecs::entity::Entity, bevy_ecs::query::filter::With<dreambound_lib::ui::common::InGameCamera>>")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `dreambound_lib::ui::init_ui`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
thread 'main' panicked at /Users/brandonwand/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/macos/app_state.rs:387:33:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.