Code Monkey home page Code Monkey logo

calico's Introduction

calico

A simple reverse inheritance state machine library for gamemaker

calico logo image thing

It has a simple api to create simple state machines:

state = calico_create()

calico_mutate_state(state, "addition")
calico_mutate_on(state, "addition", "run", function () {
   frame++
})

calico_mutate_state(state, "subtract")
calico_mutate_on(state, "subtract", "run", function () {
   frame--
})

calico_change(state, "addition")
calico_run(state, "run")

calico_change(state, "subtract")
calico_run(state, "run")

Alternatively, create a template:

template = calico_template()
.init("addition")
.state("addition").add({
   run: function() {
      frame++
   },
})
.state("subtract").add({
   run: function() {
      frame++
   },
})

state = calico_create(template)

And if you need it, utilize the unique reverse inheritance model:

template = calico_template()
.state("top").add({
   run: function (_) {
      calico_child(_) // delegates to a child
      show_debug_message("top")
   },
})
   .child("bottom").add({
      run: function () {
         show_debug_message("bottom")
      },
   })

state = calico_create(template)

calico_change(state, "top")
calico_run(state, "run") // only prints "top"

calico_change(state, "bottom")
calico_run(state, "run") // prints "bottom", then "top"

Check the documentation for more details.

calico's People

Contributors

wainggan avatar

Stargazers

 avatar Michael Schultz avatar Buckmonster avatar

Watchers

Buckmonster avatar  avatar

calico's Issues

time tracking

A way to check how long a state has been visited.

calico_time(machine) // returns total frames the machine has been running
calico_time_state(machine) // returns total frames the state has been running

sequence states

A way to sequence a timeline of state changes.

api idea:

timeline = calico_timeline()
   .next("state1")
   .next("state2", 20) // timer
   .run(function () {})
   .next("state3")

calico_change(machine, timeline)

history

A way to track the last few states that have been visited.

calico_mutate_history_enable(machine, bool)
calico_mutate_history_length(machine, length)
calico_mutate_history(machine, index, replacement)
calico_get_history(machine)

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.