Web App Inspired State Management in My Godot Game

Поділитися
Вставка
  • Опубліковано 26 гру 2020
  • Purchase Sword Slinger: store.steampowered.com/app/13...
    firebelley.itch.io/sword-slinger
    Godot Redux: github.com/glumpyfish/godot_r...
    Redux: redux.js.org/
    Follow me on Twitter! / firebelley
    Steam - store.steampowered.com/search...
    Itch.io - firebelley.itch.io/
    Website - firebelley.com
    #Godot #GameDev
  • Ігри

КОМЕНТАРІ • 13

  • @lumenwrites
    @lumenwrites 3 роки тому +9

    This is a great idea! I'd love a more detailed tutorial, this seems extremely useful.

  • @stefanobettinelli5782
    @stefanobettinelli5782 3 роки тому +3

    Thanks for the video, as a professional frontend developer I see only positive thing in implementing such a system into a complex game

  • @IsraelRuizGodot
    @IsraelRuizGodot 3 роки тому +3

    This design is beautiful. Thank you for the help. ^^

  • @TackerTacker
    @TackerTacker 3 роки тому +5

    A good video like always, but with this one I really don't understand why I should use it, it all looks so cumbersome to me and I don't understand the benefit of it.
    It looks like a more restricted and complicated version of the singleton pattern cross bred with something similar to resource files?!
    In the linked GitHub page there is also this example code:
    const GAME_PAUSE = 'GAME_PAUSE'
    const GAME_UNPAUSE = 'GAME_UNPAUSE'
    const PLAYER_MOVE_START = 'PLAYER_MOVE_START'
    const PLAYER_MOVE_UPDATE = 'PLAYER_MOVE_UPDATE'
    const PLAYER_MOVE_END = 'PLAYER_MOVE_END'
    const TIMER_START = 'TIMER_START'
    const TIMER_STOP = 'TIMER_STOP'
    with a big game this list will be miles and miles long, no?

    • @IsraelRuizGodot
      @IsraelRuizGodot 3 роки тому +2

      Most computers can handle this kind of load so it shouldn't effect FPS. The benefits of using this is it organizes how you access the singletons variables and when it notifys other nodes.
      What is described at the end is this: save variable first, then notify nodes, have those nodes access the data from the singleton.
      To me this appears to be the main benefit. Have a reusable structure. Up until now I've been doing something similar but having this gives me a cleaner, more organized why of doing things.
      It my seem restrictive, but you could say the same thing about road laws. I'll definitely be making a tutorial on how to build this. So hopefully it will make it easier to understand. ^^

    • @FirebelleyGames
      @FirebelleyGames  3 роки тому +3

      Thanks, and good questions! Firstly let me say that I could have talked more about all the pros and cons but that would have been an exceedingly long video. So there are definitely gaps in this video that are best explained by the other resources I linked.
      You are correct in a sense that this system is more restrictive, and that is by design. The one-way data flow and order of operations are important to making this solution predictable. Having to dispatch an action with certain data ensures that the state cannot be modified from just anywhere and on a whim. Modification of state has to be very intentional. And the are other benefits, like ease of saving, that I believe are particularly desirable in a game development context.
      In Godot, the Redux-like state management does indeed become a singleton, but the stores within that singleton are structured like described in the video and thus guard against (imo) easily bloated traditional singletons.
      With all that said, I do agree that the examples you see on godot_redux are a little convoluted. I am certainly NOT storing all details of the game state in the store. I only store the data that must be accessed by 2 or more disparate systems within the game (like UI and enemy logic). I don't personally believe that a Redux-like solution is a great way for managing the state of individual instances within the game.
      Anyway, again great questions! I'm certainly not advocating that everyone should be using this, but I thought it would be interesting exposure to people that may have not seen this sort of thing before. It's another tool in your toolbox to use if you ever encounter a situation where something like this would be helpful!

  • @scoopydevy
    @scoopydevy 3 роки тому

    how do u make that gun rotation so well? ive been searching that type of rotation for ages could u please make a tutorial? thanks!

  • @falling12
    @falling12 Рік тому

    How do you deal with wanting to store a superclass's variable (ie. storing the position of a scene that extends Node2D)? If another action changes the position, how do you update it locally?

  • @nathanieladams6286
    @nathanieladams6286 3 роки тому +2

    Thanks for the video! I understand how an ammo UI could be singularly updated. But if I have a list of items in my inventory and wanted to add/delete a single item, how can I deploy that change to my inventory UI without having to re-initialize every other item in the UI? It seems, at least with godot redux, a subscription only allows you to discern your reducer but not the specific updates to the store.

    • @FirebelleyGames
      @FirebelleyGames  3 роки тому +3

      Your point is a good one, and this is for sure a weakness in this approach. However, for the case you mentioned, I'd probably solve that by passing additional data along with the inventory change action like which index was removed. Then you could access that index in your subscription to determine which parts of the UI need to change.
      I don't know for sure if action data is available in Godot Redux, or if only store data is available, but I made it available in my own solution. I hope that makes sense!

  • @gitee
    @gitee 2 місяці тому

    How can I use webview inside godot

  • @DevJeremi
    @DevJeremi Рік тому +1

    Nice grate idea!
    But I wouldn't called called function that modifies var a `Reducer` as it is misleading as it sounds like it can only reduce the value of the variable and suggests that it needs a separate Adder function.
    So I would call it `Mod` or `Set` and a calculator would support simple operations given as a string on the value of the selected variable.

    • @ChrisDRimmer
      @ChrisDRimmer 10 місяців тому +1

      The naming actually makes sense given the origins of the term "reducer" in programming. It comes from functional programming, not counting, where a reducer is any function that takes multiple inputs and collapses them into one output. It reduces the number of parameters going through it.
      Here, it's called a reducer because it takes two things as inputs (an action and the existing state) and outputs just one thing, a new state that represents the effect the action had on the old state.
      You can of course name your reducer function whatever you want in the code. But if you ever dig into someone's codebase looking for the function that takes an action and an old state and uses them to generate a new state, you're going to look for something with "reducer" in its name, so it's polite to name your reducer functions accordingly.