diff --git a/client/src/arena.lisp b/client/src/arena.lisp index 2cca73f..eb73bd3 100644 --- a/client/src/arena.lisp +++ b/client/src/arena.lisp @@ -58,11 +58,13 @@ (defun shoot-ball (player) - (let ((pos (position-of player))) + (let ((pos (position-of player)) + (gaze (gaze-of player))) (run (>> (assembly-flow 'ball-model :owner player - :position (vec3 (+ (x pos) 1.0) 10.0 (- (y pos))) - :force (mult (gaze-of player) 20000)) + ;; fixme: translate by +x to center ball at mortar + :position (vec3 (x pos) 8.2 (- (y pos))) + :force (mult gaze 20000)) (-> ((mortar-combat)) (ball) (let ((group (find-node (root-of (scene-of *system*)) :ball-group))) (adopt group ball))))))) diff --git a/client/src/main.lisp b/client/src/main.lisp index e56dd5e..33a2a64 100644 --- a/client/src/main.lisp +++ b/client/src/main.lisp @@ -1,7 +1,7 @@ (in-package :mortar-combat) -(define-constant +framestep+ 0.017) +(define-constant +world-step+ 0.016) (defvar *main-latch* (mt:make-latch)) @@ -212,22 +212,27 @@ scenegraph-root)) (let ((board (find-node (root-of scene) :ui))) (make-ui board)) - (let ((accumulated-time 0) + (let ((accumulated-packet-time 0) + (accumulated-step-time 0) start looped-flow) (setf looped-flow (>> (instantly () (setf start (real-time-seconds)) (let ((*system* this)) (drain task-queue)) - (when (> accumulated-time 0.05) + (when (> accumulated-packet-time 0.05) (send-client-data this) (broadcast-arena-state this) - (setf accumulated-time 0))) + (setf accumulated-packet-time 0))) (-> ((physics)) () - (observe-universe +framestep+)) + (when (> accumulated-step-time (- +world-step+ 0.02)) + (observe-universe +world-step+) + (setf accumulated-step-time 0))) (scene-processing-flow scene) (instantly () - (incf accumulated-time (- (real-time-seconds) start)) + (let ((delta (- (real-time-seconds) start))) + (incf accumulated-packet-time delta) + (incf accumulated-step-time delta)) (when (enabledp this) (run looped-flow))))) (run looped-flow)))))))