You just have to include the following item under :dependencies in your 
project.clj:

[com.badlogic.gdx/gdx "0.9.9-SNAPSHOT"]
[com.badlogic.gdx/gdx-backend-lwjgl "0.9.9-SNAPSHOT"]

If you want to use another backend, you have to change the second entry 
accordingly. The following code is the main namespace for a game prototype 
of mine. Maybe, it can help you a little.

(ns unfinished-game.core
  (:gen-class)
  (:require [clojure.java.io :as io]
            [unfinished-game.input :as input]
            [unfinished-game.logic :as logic]
            [unfinished-game.util.geometry :refer (vec2d)])
  (:import (com.badlogic.gdx ApplicationAdapter Gdx InputAdapter)
     (com.badlogic.gdx.graphics GL10 Mesh OrthographicCamera Texture)
           (com.badlogic.gdx.graphics.g2d SpriteBatch)
           (com.badlogic.gdx.backends.lwjgl LwjglApplication)))

(def images {})

(defn draw! [^SpriteBatch batch {:keys [type image position anchor]}]
  (let [image-object ^Texture (images image)
        x (float (- (:x position) (* (.getWidth image-object) (case (:x 
anchor)
                                                                :center 0.5
                                                                :right 1
                                                                0))))
        y (float (- (:y position) (* (.getHeight image-object) (case (:y 
anchor)
                                                                 :bottom 0
                                                                 :center 0.5
                                                                 1))))]
    (cond (= type :image) (.draw batch image-object x y))))

(def image-names #{"player"
                   "block1"
                   "cross"
                   "MetalBlock"})

(def game-state (atom {}))

(defn app-adapter []
  (let [batch (atom nil)
        keys-down (atom #{})]
    (proxy [ApplicationAdapter] []
      (create []
        (println "Init.")
        (doseq [image-name image-names]
          (def images
            (conj images
                  [(keyword image-name)
                   (Texture.
                     (.internal Gdx/files (str "images/" image-name 
".png")))])))
        (reset! game-state (logic/initial-game-state))
        (reset! batch (SpriteBatch.))
        (.setInputProcessor Gdx/input
                            (proxy [InputAdapter] []
                              (keyDown [keycode]
                                (when-let [key-keyword 
(input/libgdx-key-map keycode)]
                                  (swap! keys-down #(conj % key-keyword)))
                                true)
                              (keyUp [keycode]
                                (when-let [key-keyword 
(input/libgdx-key-map keycode)]
                                  (swap! keys-down #(disj % key-keyword)))
                                true))))
      (render []
        (let [canvas-dims (vec2d (.getWidth Gdx/graphics) (.getHeight 
Gdx/graphics))
              delta-in-s (.getDeltaTime Gdx/graphics)]
          (swap! game-state logic/advance-game-state canvas-dims @keys-down 
delta-in-s))
        (let [things-to-draw (logic/rendering-commands
                               @game-state)]
          (.glClear (Gdx/gl) GL10/GL_COLOR_BUFFER_BIT)
          (.enableBlending @batch)
          (.begin @batch)
          (doseq [thing-to-draw things-to-draw]
            (draw! @batch thing-to-draw))
          (.end @batch))))))

(defn App []
  (LwjglApplication. (app-adapter) "Unfinished Game" 800 600 false))

(defn -main
  [& args]
  (App))

Greetings
Stephen


On Sunday, May 26, 2013 4:02:07 AM UTC+2, JvJ wrote:
>
> I am more or less terrible at Maven, but I'm OK with Leiningen.  Given 
> that I have some information about a Maven repository (
> https://code.google.com/p/libgdx/wiki/MavenProjectSetup#Maven_Archetype), 
> how do I use it with Leiningen?
>
> Thanks
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to