Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns cljgame.core
- (:use rosado.processing)
- (:import (javax.swing JFrame))
- (:import (processing.core PApplet))
- (:gen-class))
- (defprotocol Drawable
- "A protocol for drawable objects"
- (draw [this] "The method to override for drawing."))
- (defrecord Circle [position radius]
- Drawable
- (draw [_] (ellipse (first position) (second position) (* radius 2) (* radius 2))))
- (def my-circle (Circle. [20 20] 15))
- (defn draw-background [r g b]
- "Draw the background"
- (background-float r g b))
- (def applet
- (proxy [PApplet] []
- (setup []
- (binding [*applet* this]
- (size 200 200)
- (smooth)
- (no-stroke)
- (fill 226)
- (framerate 10)))
- (draw []
- (binding [*applet* this]
- (draw-background 0 0 0)
- (draw my-circle)))))
- (def swing-frame (JFrame. "CljGame"))
- (defn -main [& args]
- (.init applet)
- (doto swing-frame
- (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
- (.setSize 200 200)
- (.add applet)
- (.pack)
- (.show)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement