Skip to content

Instantly share code, notes, and snippets.

@jellybob
Created December 13, 2012 23:52
Show Gist options
  • Save jellybob/4281222 to your computer and use it in GitHub Desktop.
Save jellybob/4281222 to your computer and use it in GitHub Desktop.
(ns media-mogul.frontend.callbacks)
(defmulti renderer (fn [ state container graphics ] (:view state) ))
(defmethod renderer :default
[ state container graphics ]
(doto graphics
(.drawString "Using default renderer", 30, 30)))
(defmulti updater (fn [ state container delta ] (:view state) ))
(defmethod updater :default
[ state container delta ])
(def state
ref { :view :main-menu })
(def application-proxy
(proxy [ BasicGame ] [ "Media Mogul" ]
(init [ container ])
(render [ container graphics ]
(renderer @state container graphics))
(update [ container delta ]
(updater @state container delta))))
(ns media-mogul.frontend.main-menu
[ :use [ media-mogul.frontend [ callbacks :only [ updater renderer ] ] ] ])
(defmethod updater :main-menu
[ state container delta ]
(.setTitle container "Main menu"))
(defmethod renderer :main-menu
[ state container graphics ]
(.drawString graphics "Hello, world!" 30 30))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment