nightshade 0.8.0

A cross-platform data-oriented game engine.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::ecs::world::{Entity, World};
use nalgebra_glm::Vec2;

pub fn spawn_sprite(world: &mut World, position: Vec2, size: Vec2) -> Entity {
    let entities = world.spawn_entities(crate::ecs::SPRITE | crate::ecs::VISIBILITY, 1);
    let entity = entities[0];

    if let Some(sprite) = world.get_sprite_mut(entity) {
        sprite.position = position;
        sprite.size = size;
    }

    if let Some(visibility) = world.get_visibility_mut(entity) {
        visibility.visible = true;
    }

    entity
}