diff options
author | Thomas Letan <contact@thomasletan.fr> | 2018-07-02 22:34:18 +0200 |
---|---|---|
committer | Thomas Letan <contact@thomasletan.fr> | 2018-07-02 22:34:18 +0200 |
commit | 3c6f4c67cf020710b2c5b13a670d9f31da35c10b (patch) | |
tree | b84950060ab87f228309b3e31da5e5eab5e8a51c | |
parent | fix: Use the new push-action macro and gamekit:push-action API (diff) |
refactor: Renaming push-action into in-game-loop, refactoring camera
-rw-r--r-- | lykanc/client.lisp | 8 | ||||
-rw-r--r-- | lykanc/message.lisp | 24 |
2 files changed, 16 insertions, 16 deletions
diff --git a/lykanc/client.lisp b/lykanc/client.lisp index 77583c8..fbb3a99 100644 --- a/lykanc/client.lisp +++ b/lykanc/client.lisp @@ -114,7 +114,7 @@ (look-at (get-puppet app (main-puppet app)) alpha)) (fairy:goto (fairy:get-child (fairy:get-child app :ui) :cursor) cursor - 100))) + 200))) (defmethod update-camera ((app client)) (when (map-ready? app) @@ -215,12 +215,12 @@ (defmethod gamekit:act ((app client)) (let* ((new-time (get-internal-real-time)) (dt (/ (* (- new-time (last-frame app)) 1000) - internal-time-units-per-second))) + internal-time-units-per-second))) (fairy:update app dt) - (setf (last-frame app) new-time))) + (setf (last-frame app) new-time)) + (update-camera app)) (defmethod gamekit:draw ((app client)) - (update-camera app) (gamekit:with-pushed-canvas () (gamekit:scale-canvas *scale* *scale*) (fairy:draw app))) diff --git a/lykanc/message.lisp b/lykanc/message.lisp index e39a1b7..7db8f50 100644 --- a/lykanc/message.lisp +++ b/lykanc/message.lisp @@ -1,16 +1,16 @@ (cl:in-package :lykanc) -(defmacro push-action (&rest body) +(defmacro in-game-loop (&body body) `(gamekit:push-action (lambda () ,@body))) ;; ATTRIBUTE_PUPPET (defun handle-attribute-puppet (message app) - (push-action (attribute-puppet app (jsown:val message "puppet_key")))) + (in-game-loop (attribute-puppet app (jsown:val message "puppet_key")))) ;; INSTANCE_DIGEST (defun handle-instance-digest (message app) - (push-action + (in-game-loop (let ((map-key (jsown:val (jsown:val message "map") "map_key")) (puppets (jsown:val message "puppets"))) (init-map app map-key) @@ -21,14 +21,14 @@ ;; PUPPET ENTERS (defun handle-puppet-enters (message app) - (push-action + (in-game-loop (let* ((key (jsown:val message "puppet_key")) (digest (jsown:val message "digest"))) (add-puppet app key (jsown:val digest "x") (jsown:val digest "y"))))) ;; PUPPET MOVES (defun handle-puppet-moves (message app) - (push-action + (in-game-loop (let* ((key (jsown:val message "puppet_key")) (position (jsown:val message "position"))) (puppet-moves app key (jsown:val position "x") (jsown:val position "y"))))) @@ -36,19 +36,19 @@ ;; PUPPET LEAVES (defun handle-puppet-leaves (message app) - (push-action (remove-puppet app (jsown:val message "puppet_key")))) + (in-game-loop (remove-puppet app (jsown:val message "puppet_key")))) ;; PUPPET STARTS (defun handle-puppet-starts (message app) - (push-action (puppet-starts-moving app (jsown:val message "puppet_key")))) + (in-game-loop (puppet-starts-moving app (jsown:val message "puppet_key")))) ;; PUPPET STOPS (defun handle-puppet-stops (message app) - (push-action (puppet-stops-moving app (jsown:val message "puppet_key")))) + (in-game-loop (puppet-stops-moving app (jsown:val message "puppet_key")))) ;; PUPPET DIRECTION (defun handle-puppet-direction (message app) - (push-action + (in-game-loop (let* ((str-dir (jsown:val message "direction")) (dir (cond ((string= str-dir "down") :down) @@ -61,15 +61,15 @@ ;; PUPPET STARTS ATTACKING (defun handle-puppet-attacks (message app) - (push-action (puppet-attacks app (jsown:val message "puppet_key")))) + (in-game-loop (puppet-attacks app (jsown:val message "puppet_key")))) ;; PUPPET STOPS ATTACKING (defun handle-puppet-stops-attack (message app) - (push-action (puppet-stop-attack app (jsown:val message "puppet_key")))) + (in-game-loop (puppet-stop-attack app (jsown:val message "puppet_key")))) ;; PUPPET HURTED (defun handle-puppet-hurted (message app) - (push-action (puppet-hurted app (jsown:val message "puppet_key")))) + (in-game-loop (puppet-hurted app (jsown:val message "puppet_key")))) ;; Unknown message (defun unknown-message (opcode cmd app) |