Code Monkey home page Code Monkey logo

bevy-wgpu-2d's Introduction

Bevy and WGPU Framework/Learning

Sprite rendering is done using WEBGPU. Supports sprite strip animation.

bevy-wgpu-2d's People

Contributors

rishflab avatar nishad-sharma avatar

Watchers

 avatar  avatar  avatar

bevy-wgpu-2d's Issues

Design/implement file format for assets

Currently we load sprite data by specifying the anim timeline, anim strips and views like so:

    let player_sprite = sprite_registry.insert(SpriteData::load_from_anim_strips(
        "player",
        vec!["assets/huntress/idle.png", "assets/huntress/run.png", "assets/huntress/attack1.png"],
        View {
            x: 55,
            y: 53,
            width: 40,
            height: 50,
        },
    ));
...
    let anim_timeline = load_anim_timeline("assets/huntress/keyframes.json");

All of this information can be moved to a file. It doesn't make sense to load the anim_timeline from a seperate file from the View and anim strip list.

The new API would be a lot simpler:

let animated_player_sprite = sprite_registry.insert(SpriteData::load_from_file("assets/huntress.json")

where "huntress.json" contains all the information.

current_frame takes in redundant argument strip

   pub fn current_frame(&self, strip: Range<usize>, length: f32, elapsed: f32) -> u8 {
        let dt = elapsed % length;
        let mut frame = 0;
        for f in self.0[strip].iter().rev() {
            if dt > f.time {
                frame = f.index;
                break;
            }
        }
        frame
    }

If we reformat our how our animation keyframes are stored, we don't need to supply frame ranges (strip) to specify which animation

`current_frame()` takes in redundant argument `length`

   pub fn current_frame(&self, strip: Range<usize>, length: f32, elapsed: f32) -> u8 {
        let dt = elapsed % length;
        let mut frame = 0;
        for f in self.0[strip].iter().rev() {
            if dt > f.time {
                frame = f.index;
                break;
            }
        }
        frame
    }

length is the last value in strip. does not need to be passed as an arg. extract length from strip.last or something

Run left

Currently we only play the run right animation for running both left and right.

Flip the sprite when running left

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.