Decaying Instance Variables

  • I am almost ready to dive into "webstorage" which intimidates me a bit. Before I do I want to ask about creating a state of decay for my Tree which has 5 instance variables with different values.

    My tree has 3 animation states and over a browser session (lets say 10 minutes) I want my tree to decay instance variables at random in increments (some -3 some -1)

    My tree is set to 55 total instance variables when it falls below 34 it takes its second animation.

    How would I go about setting up this sequence of events?

    Obviously in the future I want to make my decay state longer and associated with the Player and webstorage so when Player returns to a session the tree is in its previous state.

    Thanks in advance.

    One footnote I have to say this is the most badass peice of software and community that I have ever seen. I am extremely impressed!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Web storage is simple. You're just storing pairs of keys and value. The keys are strings, the values are strings or numbers.

    For example, to store the player score:

    WebStorage: Set local key "score" to 500

    Then when you want to get that value from web storage you do:

    Set variable to WebStorage.LocalValue("score")

    You can easily save an entire array or dictionary to webstorage by saving it as JSON.

    WebStorage: Set local key "savedArray" to Array.AsJSON

    Array: Load from JSON string WebStorage.LocalValue("savedArray")

    For your tree I suppose you could do something like

    System: Every x seconds

    System: Compare two values floor(random(100)) < n

       -> Tree: Subtract floor(random(a, b)) from var

       

    (Every x seconds there is a n% chance to subtract a value from a to b-1)

  • magical... and great detail on the webstorage. I appreciate it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)