Project-Rekt / engine

Game Engine - Currently on version MASON
https://project-rekt.github.io/engine/index.html
Apache License 2.0
1 stars 3 forks source link

Create a class to manage sprite states #13

Closed elijah-t closed 4 years ago

elijah-t commented 4 years ago

Sprite states / animations

Sprites will have different animations paired with different states, as well as a fallback animation for default states (idle).

TODO:

  1. Constructor e.g. constructor(sprite, state)

  2. Create functions to set/get states in sprite objects: e.g. setState(state, animation) getState();

  3. Have an optional fallback state if no animation is set for a state

Squishy123 commented 4 years ago

Let's give an example of what the datastructure for the spritestate object would look like. maybe something like this?

export default {
    properties: {},
    states: {
        idle: {
            location: '/' + require('./assets/goku_idle.png').default, //location of sprites
            rps: 5, //refresh per second
            loop: true, //will continue to loop
            frames: [{
                x: 3, 
                y: 3,
                width: 48,
                height: 85
            }, {
                x: 55, 
                y: 3,
                width: 46,
                height: 86
            }, {
                x: 103, 
                y: 0,
                width: 45,
                height: 91
            }]
        },
        fight: {
            location: '/' + require('./assets/goku_fight.png').default, //location of sprites
            rps: 10, //refresh per second
            frames: [{
                x: 0, 
                y: 9,
                width: 59,
                height: 78
            }, {
                x: 69, 
                y: 10,
                width: 87,
                height: 77
            }, {
                x: 164, 
                y: 0,
                width: 51,
                height: 88
            }, {
                x: 226,
                y: 1,
                width: 80,
                height: 89
            }]
        }
    }
}
elijah-t commented 4 years ago

Yeah, the structure of the sprite state object would look similar to that I would imagine.

Squishy123 commented 4 years ago

what would the spriteActor class look like?

Squishy123 commented 4 years ago

resolved in #17