Update with stoe's resource/entity/graph api
This commit is contained in:
parent
2dd58d0dc4
commit
7ce11ace97
1 changed files with 18 additions and 31 deletions
|
|
@ -8,42 +8,31 @@
|
|||
(in-package :stoe-game)
|
||||
|
||||
(defun load-cube ()
|
||||
(with-lock-held ((scene-lock (get-world)))
|
||||
(with-accessors ((scene world-scene) (camera world-camera) (scenes scenes)) (get-world)
|
||||
(push (import-graphic-assets #P"data/cube.dae") scenes)
|
||||
(setf scene (first scenes))
|
||||
(setf camera (make-camera 90 (/ 16 9) 1.0 1000.0)))))
|
||||
(locking-scene
|
||||
(create-model "cube" #P"data/cube.dae")))
|
||||
|
||||
(defun load-tie ()
|
||||
(with-lock-held ((scene-lock (get-world)))
|
||||
(with-accessors ((scene world-scene) (camera world-camera) (scenes scenes)) (get-world)
|
||||
(push (import-graphic-assets #P"data/TieFighter.dae") scenes)
|
||||
(setf scene (first scenes))
|
||||
(setf camera (make-camera 90 (/ 16 9) 1.0 1000.0)))))
|
||||
(locking-scene
|
||||
(create-model "tie fighter" #P"data/TypeFighter.dae")))
|
||||
|
||||
(defun load-levi ()
|
||||
(with-lock-held ((scene-lock (get-world)))
|
||||
(with-accessors ((scene world-scene) (camera world-camera) (scenes scenes)) (get-world)
|
||||
(push (import-graphic-assets #P"data/levi.dae") scenes)
|
||||
(setf scene (first scenes))
|
||||
(setf camera (make-camera 90 (/ 16 9) 1.0 1000.0))
|
||||
(move camera :dz -1.0 :dy -2.0)
|
||||
(rotate camera :dy -90.0))))
|
||||
(locking-scene
|
||||
(create-model "levi" #P"data/levi.dae")))
|
||||
|
||||
(defun setup-input ()
|
||||
(global-set-key :escape #'quit)
|
||||
(global-set-key (:e :continuous) (lambda () (move (get-current-camera) :dz -0.1)))
|
||||
(global-set-key (:j :continuous) (lambda () (move (get-current-camera) :dz 0.1)))
|
||||
(global-set-key (:q :continuous) (lambda () (move (get-current-camera) :dx -0.1)))
|
||||
(global-set-key (:k :continuous) (lambda () (move (get-current-camera) :dx 0.1)))
|
||||
(global-set-key (:o :continuous) (lambda () (rotate (get-current-camera) :dz -2)))
|
||||
(global-set-key (:u :continuous) (lambda () (rotate (get-current-camera) :dz 2)))
|
||||
(global-set-key (:e :continuous) (lambda () (move (get-first-component (main-camera (world)) :graph-node) :dz -0.1)))
|
||||
(global-set-key (:j :continuous) (lambda () (move (get-first-component (main-camera (world)) :graph-node) :dz 0.1)))
|
||||
(global-set-key (:q :continuous) (lambda () (move (get-first-component (main-camera (world)) :graph-node) :dx -0.1)))
|
||||
(global-set-key (:k :continuous) (lambda () (move (get-first-component (main-camera (world)) :graph-node) :dx 0.1)))
|
||||
(global-set-key (:o :continuous) (lambda () (rotate (get-first-component (main-camera (world)) :graph-node) :dz -2)))
|
||||
(global-set-key (:u :continuous) (lambda () (rotate (get-first-component (main-camera (world)) :graph-node) :dz 2)))
|
||||
(let (freelook-mode)
|
||||
(flet ((set-freelook (enable)
|
||||
(setf freelook-mode enable))
|
||||
(freelook-move (dx dy)
|
||||
(when freelook-mode
|
||||
(rotate (get-current-camera) :dx dx :dy dy))))
|
||||
(rotate (get-first-component (main-camera (world)) :graph-node) :dx dx :dy dy))))
|
||||
(global-set-key 3 #'set-freelook t)
|
||||
(global-set-key (3 :release) #'set-freelook nil)
|
||||
(global-set-motion #'freelook-move :dx :dy))))
|
||||
|
|
@ -51,17 +40,15 @@
|
|||
(defun initialize (&optional argv)
|
||||
(declare (ignore argv))
|
||||
(setup-input)
|
||||
(world-initialize)
|
||||
(load-cube))
|
||||
(create-world))
|
||||
|
||||
(defun finalize ())
|
||||
|
||||
(defun update (delta-time)
|
||||
(declare (ignore delta-time))
|
||||
(unless (null (get-world))
|
||||
(with-lock-held ((scene-lock (get-world)))
|
||||
(when (get-current-camera)
|
||||
(update-view (get-current-camera))))))
|
||||
(unless (null (world))
|
||||
(locking-scene
|
||||
(when (main-camera (world))
|
||||
(update-view (get-first-component (main-camera (world)) :camera))))))
|
||||
|
||||
(defmodule stoe-game :game)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue