Skip to content

Instantly share code, notes, and snippets.

@timsgardner
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save timsgardner/10da9d05c4923ed06efb to your computer and use it in GitHub Desktop.

Select an option

Save timsgardner/10da9d05c4923ed06efb to your computer and use it in GitHub Desktop.
mappy late-bound component logic idea
(defcomponent ProtagonistDriver [logic]
(Update [this]
(when-let [f (:update logic)]
(f this)))
(OnCollisionEnter [this that]
(when-let [f (:on-collision-enter logic)]
(f this that))))
@timsgardner

Copy link
Copy Markdown
Author

Thinking about ways to enable extremely malleable GameObject behavior, readily manipulable as persistent data. For things like the main character, which one wants to make very few assumptions about, and probably tweak the behavior of incrementally as the game progresses. Other ways of doing this, here's one.

@nasser

nasser commented Jul 20, 2015

Copy link
Copy Markdown

I like this a lot. What would the updating API be like? I guess you could

(set! (.. protagonist logic) new-map)

but a more map/record like interface would be awesome. Like

(assoc! protagonist :update new-fn)

The next question is where does state go? Is there a separate map? Do we just use fields?

I like where this is going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment