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.

Revisions

  1. jellybob created this gist Dec 13, 2012.
    11 changes: 11 additions & 0 deletions callbacks.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    (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 ])
    10 changes: 10 additions & 0 deletions frontend.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    (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))))
    10 changes: 10 additions & 0 deletions main-menu.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    (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))