Popularity
0.8
Stable
Activity
0.0
Stable
8
3
2

Description

2D sprite rendering extension for the Specs ECS system.

All sprites are loaded onto a big array on the heap.

Programming language: Rust
License: GNU General Public License v3.0 only
Tags: Engine     Graphics     Gamedev     Image     Game development     Ecs     Entity-component     Sprite     Blitting    
Latest version: v0.5.1

specs-blit alternatives and similar packages

Based on the "Game development" category.
Alternatively, view specs-blit alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of specs-blit or a related project?

Add another 'Game development' Package

README

specs-blit

2D sprite rendering extension for the Specs ECS system.

CI

All sprites are loaded onto a big array on the heap.

Example

// Setup the specs world
let mut world = specs::World::new();

// Load the blit components into the world
world.register::<specs_blit::Sprite>();

// Add the pixel buffer as a resource so it can be accessed from the RenderSystem later
const WIDTH: usize = 800;
const HEIGHT: usize = 600;
world.insert(specs_blit::PixelBuffer::new(WIDTH, HEIGHT));

let sprite_ref = {
    // Load the image using the image crate
    let img = image::open("examples/smiley.png")?;
    // Create a sprite from it
    const MASK_COLOR: u32 = 0xFF00FF;
    let sprite = blit::blit_buffer(&img, blit::Color::from_u32(MASK_COLOR));

    // Move the sprite to the render system with 4 rotations
    specs_blit::load(sprite, 4)?
};

// Create a new sprite entity in the ECS system
world.create_entity()
    .with(specs_blit::Sprite::new(sprite_ref))
    .build();

// Setup the dispatcher with the blit system
let mut dispatcher = specs::DispatcherBuilder::new()
    .with_thread_local(specs_blit::RenderSystem)
    .build();

// Enter the render loop that should be called every frame
while render_frame() {
    // Update specs
    dispatcher.dispatch(&mut world);

    // Add/remove entities added in dispatch through `LazyUpdate`
    world.maintain();

    // Get the pixel buffer resource to render it
    let buffer = world.read_resource::<specs_blit::PixelBuffer>();
    // Render the pixel buffer
    window.update_with_buffer(&buffer.pixels(), buffer.width(), buffer.height())?;
}


*Note that all licence references and agreements mentioned in the specs-blit README section above are relevant to that project's source code only.