diff --git a/stoe-game.lisp b/stoe-game.lisp index 2414309..dd25738 100644 --- a/stoe-game.lisp +++ b/stoe-game.lisp @@ -21,18 +21,18 @@ (defun setup-input () (global-set-key :escape #'quit) - (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))) + (global-set-key (:e :continuous) (lambda () (move (component (main-camera) 'scene-object-component) :dz -0.1))) + (global-set-key (:j :continuous) (lambda () (move (component (main-camera) 'scene-object-component) :dz 0.1))) + (global-set-key (:q :continuous) (lambda () (move (component (main-camera) 'scene-object-component) :dx -0.1))) + (global-set-key (:k :continuous) (lambda () (move (component (main-camera) 'scene-object-component) :dx 0.1))) + (global-set-key (:o :continuous) (lambda () (rotate (component (main-camera) 'scene-object-component) :dz -2))) + (global-set-key (:u :continuous) (lambda () (rotate (component (main-camera) 'scene-object-component) :dz 2))) (let (freelook-mode) (flet ((set-freelook (enable) (setf freelook-mode enable)) (freelook-move (dx dy) (when freelook-mode - (rotate (get-first-component (main-camera (world)) :graph-node) :dx dx :dy dy)))) + (rotate (component (main-camera) 'scene-object-component) :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)))) @@ -40,7 +40,7 @@ (defun initialize (&optional argv) (declare (ignore argv)) (setup-input) - (create-world)) + (create-world "World")) (defun finalize ()) @@ -48,7 +48,8 @@ (declare (ignore delta-time)) (unless (null (world)) (locking-scene - (when (main-camera (world)) - (update-view (get-first-component (main-camera (world)) :camera)))))) + (with-components (camera-component scene-object-component) (main-camera) + (with-slots (position direction) scene-object-component + (update-view camera-component position direction)))))) (defmodule stoe-game :game)