Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 01 19:53

    greenkeeper[bot] on bluebird-3.7.0

    (compare)

  • Oct 01 19:47

    greenkeeper[bot] on bluebird-3.6.0

    (compare)

  • Oct 01 19:46

    greenkeeper[bot] on bluebird-3.7.0

    chore(package): update bluebird… (compare)

  • Oct 01 19:35

    greenkeeper[bot] on bluebird-3.6.0

    chore(package): update bluebird… (compare)

  • Sep 29 14:55

    greenkeeper[bot] on mocha-6.2.1

    (compare)

  • Sep 29 14:02

    greenkeeper[bot] on mocha-6.2.1

    chore(package): update mocha to… (compare)

  • Sep 23 15:44
    greenkeeper[bot] commented #115
  • Sep 23 15:29

    greenkeeper[bot] on sinon-7.5.0

    chore(package): update sinon to… (compare)

  • Sep 15 10:31
    greenkeeper[bot] commented #117
  • Sep 15 10:27

    greenkeeper[bot] on stampit-pin-4.2.0

    chore: pin stampit to 4.2.0 (compare)

  • Sep 15 10:27
    greenkeeper[bot] labeled #117
  • Sep 15 10:27
    greenkeeper[bot] opened #117
  • Sep 15 10:25

    greenkeeper[bot] on stampit-4.3.0

    chore(package): update stampit … (compare)

  • Sep 02 12:38
    greenkeeper[bot] commented #115
  • Sep 02 12:25

    greenkeeper[bot] on sinon-7.4.2

    chore(package): update sinon to… (compare)

  • Aug 19 13:51
    greenkeeper[bot] commented #116
  • Aug 19 13:48

    greenkeeper[bot] on uuid-pin-3.3.2

    chore: pin uuid to 3.3.2 (compare)

  • Aug 19 13:48
    greenkeeper[bot] edited #116
  • Aug 19 13:48
    greenkeeper[bot] labeled #116
  • Aug 19 13:48
    greenkeeper[bot] opened #116
Vlad Știrbu
@vstirbu
Questions, feature requests or anything related to fsm-as-promised are welcome here
Johnny Hauser
@m59peacemaker
@vstirbu I've only been able to find one example of a finite state machine used for character movement, and I can't see how to apply it to any of the javascript state machines. I have a basic project setup where I'm messing around with this. I think it would be good to make a good demo of moving a character around / jumping, etc with the state machine. Could you give me some pointers?
When I get it down, I could make a nice repo that will hopefully help other people with the same questions.
I've got an update function for the game that ticks every frame:
function update() {
  hero.update();
  //etc
}
I'm not sure where to put my key/input checking logic and hero velocity and animation logic.
Johnny Hauser
@m59peacemaker
This message was deleted
Vlad Știrbu
@vstirbu

@m59peacemaker, an example of using the ism for controlling the movement of the character in the game would be really useful! I have not used it myself together with a game engine so I would well come an exam ole like this.

I have a quick look at the example you provided, and I think that the general approach in this case is to use the facilities of the game engine to handle the interaction and rendering, while controlling the state of the character using the state machine. At first glance, the example already provides the complete state machine definition including the states and the possible transitions. They can be mapped quite easily:

var sm = StateMachine.create({
    initial: 'standing',
    events: [
        { name: 'move', from: 'standing', to: 'running'},
        { name: 'jump', from: ['running', 'standing'], to: 'jumping' }
        // and so on with the rest as listed in the picture
    ],
    callbacks: {

    }
})
Vlad Știrbu
@vstirbu
then in the game engine interaction handlers you can check if that move is valid in the current state and trigger that change.
Johnny Hauser
@m59peacemaker
@vstirbu What kind of logic goes in the callbacks then? I thought the idea was to put the rendering logic in there... I get confused tying the game loop and fsm together... the character has to be updated in the game loop according to what state he is in
Johnny Hauser
@m59peacemaker
Maybe the callback onrunning should set hero.render = running ?
function running() {
  // logic for every frame
}
function update() { // game loop
  hero.render(); // set to "running" function when state is running
}
I did try something like that and it didn't work out, but if that's the way to do it, at least I can keep tinkering with that approach
Vlad Știrbu
@vstirbu
just a quick remark on using the library with a game engine. this library is intended for application scenarios where all transitions are potentially asynchronous, which can be challenging in gaming context where you need to complete operations within a strict time limit (e.g. ~16ms for 60 FPS). also, each transition is a sequence of promises which brings some overhead that might not be negligible
Johnny Hauser
@m59peacemaker
I'm finally making some progress, but I nixed fsm libs altogether. I just copied the lua code from that article and worked from it.
Johnny Hauser
@m59peacemaker
and this is the state-machine I ended up with from that example https://github.com/m59peacemaker/game/blob/master/src/state-machine.js
I still don't know how to do this with any of the fsm libs.
Younes
@younes200
hi
Gleb Feklistov
@glebfeklistov
Hello. Possible to convert callbacks name to camelCase?