Permalink
Browse files

Cap physics step

  • Loading branch information...
borodust committed Apr 24, 2017
1 parent 11eab86 commit f5dda2963b2b000cc72933b41cb80ad7eebd82ac
Showing with 16 additions and 9 deletions.
  1. +5 −3 client/src/arena.lisp
  2. +11 −6 client/src/main.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)))))))
@@ -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)))))))

0 comments on commit f5dda29

Please sign in to comment.