Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
move stuff into app/
Browse files Browse the repository at this point in the history
  • Loading branch information
ztellman committed Dec 31, 2009
1 parent a50c7bf commit 1b3f592
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 249 deletions.
10 changes: 4 additions & 6 deletions example/game/asteroids.clj
Expand Up @@ -9,8 +9,6 @@
(ns example.game.asteroids
(:use [penumbra opengl geometry])
(:require [penumbra.app :as app])
(:require [penumbra.input :as input])
(:require [penumbra.window :as window])
(:use [clojure.contrib.seq-utils :only (separate)]))

;;;
Expand Down Expand Up @@ -154,7 +152,7 @@
15 0.25 [0 0 1] 2)))))

(defn emit-flame [state]
(if (input/key-pressed? :up)
(if (app/key-pressed? :up)
(let [ship (:spaceship state)
theta (+ 180 (:theta ship) (- (rand 20) 10))
particles (:particles state)
Expand All @@ -168,11 +166,11 @@
(let [p (:position ship)
v (:velocity ship)
theta (:theta ship)
theta (condp (fn [x _] (input/key-pressed? x)) nil
theta (condp (fn [x _] (app/key-pressed? x)) nil
:left (rem (+ theta (* 360 dt)) 360)
:right (rem (- theta (* 360 dt)) 360)
theta)
a (if (input/key-pressed? :up)
a (if (app/key-pressed? :up)
(map (partial * 3) (cartesian theta))
[0 0])
v (map + v (map * a (repeat dt)))
Expand Down Expand Up @@ -284,7 +282,7 @@

(defn init [state]
(app/set-title "Asteroids")
(window/vsync true)
(app/vsync true)
(init-asteroids)
(init-particles)
(init-spaceship)
Expand Down
5 changes: 2 additions & 3 deletions example/game/tetris.clj
Expand Up @@ -9,7 +9,6 @@
(ns example.game.tetris
(:use [penumbra opengl])
(:require [penumbra.app :as app])
(:require [penumbra.input :as input])
(:use [clojure.contrib.seq-utils :only (indexed)])
(:use [clojure.contrib.def :only (defn-memo)])
(:use [clojure.contrib.pprint]))
Expand Down Expand Up @@ -182,11 +181,11 @@
(app/start-update-loop
2
(fn [state]
(if (input/key-pressed? :down)
(if (app/key-pressed? :down)
(app/frequency! 10)
(app/frequency! 2))
(descend state)))
(input/key-repeat true)
(app/key-repeat true)
state)

(defn reshape [[x y w h] state]
Expand Down
5 changes: 3 additions & 2 deletions example/opengl/gears.clj
Expand Up @@ -9,7 +9,7 @@
(ns example.opengl.gears
(:use [penumbra opengl geometry])
(:require [penumbra.app :as app])
(:require [penumbra.window :as window]))
(:require [penumbra.text :as text]))

;;;;;;;;;;;;;;;;;;;;;;;;;
;;Gear building functions
Expand Down Expand Up @@ -85,6 +85,7 @@

(defn init [state]
(app/set-title "Gears")
(disable :multisample)
(enable :depth-test)
(enable :lighting)
(enable :light0)
Expand All @@ -105,7 +106,7 @@
:rot-y (+ (:rot-y state) dx)))

(defn display [[delta time] state]
(write-to-screen (format "%d fps" (int (/ 1 delta))) 0 0)
(text/write-to-screen (format "%d fps" (int (/ 1 delta))) 0 0)
(rotate (:rot-x state) 1 0 0)
(rotate (:rot-y state) 0 1 0)
(rotate (* 20. (rem time 360)) 0 0 1)
Expand Down
2 changes: 0 additions & 2 deletions example/opengl/marble.clj
Expand Up @@ -9,7 +9,6 @@
(ns example.opengl.marble
(:use [penumbra opengl geometry])
(:require [penumbra.app :as app])
(:require [penumbra.window :as window])
(:use [penumbra.glsl.effects]))

;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -68,7 +67,6 @@
(enable :depth-test)
(enable :lighting)
(enable :light0)
(window/vsync true)
(assoc state
:sphere (sphere-geometry 100)
:program (create-program declarations vertex-shader fragment-shader)))
Expand Down
7 changes: 3 additions & 4 deletions example/opengl/render_to_texture.clj
Expand Up @@ -8,8 +8,7 @@

(ns example.opengl.render-to-texture
(:use [penumbra opengl])
(:require [penumbra.app :as app])
(:require [penumbra.window :as window]))
(:require [penumbra.app :as app]))

(defn textured-quad []
(push-matrix
Expand Down Expand Up @@ -65,7 +64,7 @@
state)

(defn mouse-drag [[dx dy] [x y] button state]
(let [[w h] (window/dimensions)]
(let [[w h] (app/dimensions)]
(if (< x (int (/ w 2)))
(let [[lx ly] (:left state)]
(assoc state :left [(+ lx dy) (+ ly dx)]))
Expand All @@ -77,7 +76,7 @@
[rx ry] (:right state)
checkers (:checkers state)
view (:view state)
[w h] (window/dimensions)]
[w h] (app/dimensions)]

(light 0
:position [-1 -1 1 0])
Expand Down
1 change: 0 additions & 1 deletion example/opengl/sierpinski.clj
Expand Up @@ -48,7 +48,6 @@
(app/set-title "Sierpinski Pyramid")
(enable :normalize)
(enable :depth-test)
(enable :multisample)
(enable :cull-face)
(enable :lighting)
(enable :light0)
Expand Down

0 comments on commit 1b3f592

Please sign in to comment.