add jump to demo 9
This commit is contained in:
parent
55b7a44af3
commit
b27abeffb5
3 changed files with 92 additions and 70 deletions
|
|
@ -4,20 +4,20 @@
|
|||
(var angle-x 0)
|
||||
(var angle-y 0)
|
||||
(var angle-z 0)
|
||||
(var auto-rotate true)
|
||||
(var orthographic true)
|
||||
(var wireframe true)
|
||||
(var auto-rotate? true)
|
||||
(var orthographic? true)
|
||||
(var wireframe? true)
|
||||
(var time 0)
|
||||
(var zoom 5.0)
|
||||
(var texture-id nil)
|
||||
(var use-texture false)
|
||||
(var affine false)
|
||||
(var use-texture? false)
|
||||
(var affine? false)
|
||||
(var cam-x 0)
|
||||
(var cam-y 2)
|
||||
(var cam-z 12)
|
||||
(var cam-yaw 0)
|
||||
(var cam-pitch -0.2)
|
||||
(var show-debug-ui false)
|
||||
(var show-debug-ui? false)
|
||||
(var fps 0)
|
||||
(var fps-accumulator 0)
|
||||
(var fps-frame-count 0)
|
||||
|
|
@ -26,19 +26,19 @@
|
|||
(set angle-x 0)
|
||||
(set angle-y 0)
|
||||
(set angle-z 0)
|
||||
(set auto-rotate true)
|
||||
(set orthographic true)
|
||||
(set wireframe true)
|
||||
(set auto-rotate? true)
|
||||
(set orthographic? true)
|
||||
(set wireframe? true)
|
||||
(set time 0)
|
||||
(set zoom 5.0)
|
||||
(set use-texture false)
|
||||
(set affine false)
|
||||
(set use-texture? false)
|
||||
(set affine? false)
|
||||
(set cam-x 0)
|
||||
(set cam-y 2)
|
||||
(set cam-z 12)
|
||||
(set cam-yaw 0)
|
||||
(set cam-pitch -0.2)
|
||||
(set show-debug-ui false)
|
||||
(set show-debug-ui? false)
|
||||
(set fps 0)
|
||||
(set fps-accumulator 0)
|
||||
(set fps-frame-count 0)
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
|
||||
(let [wheel-y (pxl8.mouse_wheel_y)]
|
||||
(when (and (not= wheel-y 0) (not (pxl8.ui_has_mouse_focus)))
|
||||
(if orthographic
|
||||
(if orthographic?
|
||||
(set zoom (math.max 0.5 (math.min (- zoom (* wheel-y 0.2)) 10.0)))
|
||||
(let [zoom-speed 0.5
|
||||
forward-x (* (math.sin cam-yaw) wheel-y zoom-speed)
|
||||
|
|
@ -103,7 +103,7 @@
|
|||
right-x (* (math.cos cam-yaw) move-speed dt)
|
||||
right-z (* (- (math.sin cam-yaw)) move-speed dt)]
|
||||
|
||||
(if orthographic
|
||||
(if orthographic?
|
||||
(do
|
||||
(when (pxl8.key_down "w")
|
||||
(set zoom (math.max 0.5 (- zoom (* zoom-speed dt)))))
|
||||
|
|
@ -149,20 +149,20 @@
|
|||
(set cam-pitch (math.max -1.5 (math.min cam-pitch 1.5))))
|
||||
|
||||
(when (pxl8.key_pressed " ")
|
||||
(set wireframe (not wireframe)))
|
||||
(set wireframe? (not wireframe?)))
|
||||
(when (pxl8.key_pressed "f")
|
||||
(set affine (not affine)))
|
||||
(set affine? (not affine?)))
|
||||
(when (pxl8.key_pressed "p")
|
||||
(set orthographic (not orthographic)))
|
||||
(set orthographic? (not orthographic?)))
|
||||
(when (pxl8.key_pressed "r")
|
||||
(set auto-rotate (not auto-rotate)))
|
||||
(set auto-rotate? (not auto-rotate?)))
|
||||
(when (pxl8.key_pressed "t")
|
||||
(set use-texture (not use-texture)))
|
||||
(set use-texture? (not use-texture?)))
|
||||
(when (pxl8.key_pressed "F8")
|
||||
(set show-debug-ui (not show-debug-ui))
|
||||
(pxl8.ui_window_set_open "Debug Menu (F8)" show-debug-ui))
|
||||
(set show-debug-ui? (not show-debug-ui?))
|
||||
(pxl8.ui_window_set_open "Debug Menu (F8)" show-debug-ui?))
|
||||
|
||||
(when auto-rotate
|
||||
(when auto-rotate?
|
||||
(set angle-x (+ angle-x (* dt 0.7)))
|
||||
(set angle-y (+ angle-y (* dt 0.5)))
|
||||
(set angle-z (+ angle-z (* dt 0.3)))))
|
||||
|
|
@ -178,7 +178,7 @@
|
|||
(pxl8.set_model model))
|
||||
|
||||
(let [vertices (make-cube-vertices)]
|
||||
(if (and use-texture texture-id)
|
||||
(if (and use-texture? texture-id)
|
||||
(let [faces (make-cube-faces-with-uvs)]
|
||||
(each [_i face-data (ipairs faces)]
|
||||
(let [tri-indices face-data.tri
|
||||
|
|
@ -206,11 +206,11 @@
|
|||
(pxl8.clr 0)
|
||||
|
||||
(pxl8.clear_zbuffer)
|
||||
(pxl8.set_affine_textures affine)
|
||||
(pxl8.set_affine_textures affine?)
|
||||
(pxl8.set_backface_culling true)
|
||||
(pxl8.set_wireframe wireframe)
|
||||
(pxl8.set_wireframe wireframe?)
|
||||
|
||||
(if orthographic
|
||||
(if orthographic?
|
||||
(let [size zoom
|
||||
aspect (/ (pxl8.get_width) (pxl8.get_height))
|
||||
w (* size aspect)
|
||||
|
|
@ -233,19 +233,19 @@
|
|||
(draw-cube [3 1 -7] 0.9 1.2)
|
||||
(draw-cube [0 -2 -10] 1.1 -0.7)
|
||||
|
||||
(let [new-state (debug-ui.render {:show-debug-ui show-debug-ui
|
||||
(let [new-state (debug-ui.render {:show-debug-ui show-debug-ui?
|
||||
:fps fps
|
||||
:wireframe wireframe
|
||||
:auto-rotate auto-rotate
|
||||
:orthographic orthographic
|
||||
:use-texture use-texture
|
||||
:affine affine})]
|
||||
(when (not= new-state.show-debug-ui nil) (set show-debug-ui new-state.show-debug-ui))
|
||||
(when (not= new-state.wireframe nil) (set wireframe new-state.wireframe))
|
||||
(when (not= new-state.auto-rotate nil) (set auto-rotate new-state.auto-rotate))
|
||||
(when (not= new-state.orthographic nil) (set orthographic new-state.orthographic))
|
||||
(when (not= new-state.use-texture nil) (set use-texture new-state.use-texture))
|
||||
(when (not= new-state.affine nil) (set affine new-state.affine))))
|
||||
:wireframe wireframe?
|
||||
:auto-rotate auto-rotate?
|
||||
:orthographic orthographic?
|
||||
:use-texture use-texture?
|
||||
:affine affine?})]
|
||||
(when (not= new-state.show-debug-ui nil) (set show-debug-ui? new-state.show-debug-ui))
|
||||
(when (not= new-state.wireframe nil) (set wireframe? new-state.wireframe))
|
||||
(when (not= new-state.auto-rotate nil) (set auto-rotate? new-state.auto-rotate))
|
||||
(when (not= new-state.orthographic nil) (set orthographic? new-state.orthographic))
|
||||
(when (not= new-state.use-texture nil) (set use-texture? new-state.use-texture))
|
||||
(when (not= new-state.affine nil) (set affine? new-state.affine))))
|
||||
|
||||
{:init init
|
||||
:update update
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue