Crates.io | quad_bevy |
lib.rs | quad_bevy |
version | 0.0.1 |
source | src |
created_at | 2024-08-02 09:01:21.135394 |
updated_at | 2024-08-02 09:01:21.135394 |
description | bevy_ecs for miniquad/macroquad without wasm-bindgen |
homepage | |
repository | https://github.com/yui-915/quad_bevy |
max_upload_size | |
id | 1322947 |
size | 15,335 |
IDK, less bloat & faster compiles ?
By patching bevy crates to remove functionality or chage implementation. as of 0.14.0 , the changes include:
bevy_ecs
bevy_app
bevy_time
usage in bevy_app
bevy_utils
to use miniquad::date::now()
instead of web-time
By adding the following lines to .cargo/config.toml
[patch.crates-io]
bevy_ecs = { git = "https://github.com/yui-915/quad_bevy", branch = "bevy_ecs@0.14.0" }
bevy_app = { git = "https://github.com/yui-915/quad_bevy", branch = "bevy_app@0.14.0" }
bevy_utils = { git = "https://github.com/yui-915/quad_bevy", branch = "bevy_utils@0.14.0" }
You can build it for web just like any other macroquad project and it'll work without any extra setup
use bevy_app::prelude::*;
use bevy_ecs::prelude::*;
use macroquad::prelude::*;
fn main() {
App::new()
.add_plugins(MacroquadRunner("Hello, world!"))
.add_systems(Startup, spawn_squares)
.add_systems(Update, (move_squares, bg, draw_squares).chain())
.run();
}
#[derive(Component)]
struct Position(f32, f32);
fn spawn_squares(mut cmds: Commands) {
cmds.spawn(Position(0.0, 100.0));
cmds.spawn(Position(450.0, 500.0));
}
fn bg() {
clear_background(ORANGE);
}
fn move_squares(mut query: Query<&mut Position>) {
for mut position in &mut query {
position.0 += 10.0;
if position.0 > screen_width() {
position.0 = 0.0;
}
}
}
fn draw_squares(query: Query<&Position>) {
for position in &query {
draw_rectangle(position.0, position.1, 100.0, 100.0, BLACK);
}
}
// Example bevy runner plugin for macroquad
pub struct MacroquadRunner(pub &'static str);
impl Plugin for MacroquadRunner {
fn build(&self, app: &mut App) {
let window_title = self.0;
app.set_runner(|mut app| {
macroquad::Window::new(window_title, async move {
loop {
app.update();
next_frame().await;
}
});
bevy_app::AppExit::Success
});
}
}
Probably not, this project is highly experimental, and might break your code due to incompatible changes or different miniquad version
Just so it shows up on crates.io, otherwise it does nothing. you can used the patched bevy crates without download this crate.
I'll keep the "MIT or Apache 2.0" licence from the original bevy crates