Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns dinjin.core
- (:import [com.badlogic.gdx Game Gdx Graphics Screen]
- [com.badlogic.gdx.graphics Color GL20 Texture]
- [com.badlogic.gdx.graphics.g2d BitmapFont SpriteBatch]
- [com.badlogic.gdx.scenes.scene2d Stage]
- [com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle]))
- (gen-class
- :name dinjin.core.Game
- :extends com.badlogic.gdx.Game)
- (def texture-state (atom {:sprite nil :texture nil}))
- (defn render
- ""
- [delta]
- (.glClearColor (Gdx/gl) 0 0 0 0)
- (.glClear (Gdx/gl) GL20/GL_COLOR_BUFFER_BIT)
- ;; This works, but instantiates every loop
- ;; (doto (SpriteBatch.)
- ;; (.begin)
- ;; (.draw (Texture. "clojure.png") 50.5 50.5)
- ;; (.end))
- ;; Throws: No matching method found: draw for class com.badlogic.gdx.graphics.g2d.SpriteBatch
- (doto (:sprite @texture-state)
- (.begin)
- (.draw (:texture @texture-state) 50.5 50.5)
- (.end)))
- (defn main-screen
- []
- (proxy [Screen] []
- (show [])
- (render [delta]
- ;; Call render loop
- (render delta))
- (dispose[])
- (hide [])
- (pause [])
- (resize [w h])
- (resume [])))
- (defn -create [^Game this]
- ;; Create SpriteBatch and Texture
- (let [sprite (SpriteBatch.)
- texture (Texture. "clojure.png")]
- (swap! texture-state #(assoc % :sprite sprite :texture texture))
- (.setScreen this (main-screen))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement