Permalink
Browse files

Send game updates every couple of frames

  • Loading branch information...
borodust committed Apr 23, 2017
1 parent af8617a commit b681885e04b208c04403287f40d24617e37a45a4
Showing with 29 additions and 22 deletions.
  1. +11 −10 client/src/arena.lisp
  2. +18 −12 client/src/main.lisp
@@ -28,17 +28,18 @@
(with-slots (dudes player) this
(dolist (dude-state (getf state :player-list))
(with-instance-lock-held (this)
(let* ((dude-name (getf dude-state :name))
(dude (gethash dude-name dudes)))
(let* ((dude-name (getf dude-state :name)))
(unless (equal dude-name (name-of player))
(unless dude
(setf dude (make-instance 'proxy :name dude-name)
(gethash dude-name dudes) dude)
(post (make-player-added dude) (events)))
(update-proxy dude
(sequence->vec2 (getf dude-state :position))
(sequence->vec2(getf dude-state :rotation))
timestamp)))))))
(let ((dude (gethash dude-name dudes)))
(unless dude
(setf dude (make-instance 'proxy :name dude-name)
(gethash dude-name dudes) dude)
(post (make-player-added dude) (events)))
(update-proxy dude
(sequence->vec2 (getf dude-state :position))
(sequence->vec2(getf dude-state :rotation))
timestamp))))))))
(defun shoot-ball (player)
@@ -171,18 +171,24 @@
(make-rendering-pass))
scenegraph-root)))
(concurrently ()
(let (looped-flow)
(setf looped-flow (>> (instantly ()
(let ((*system* this))
(drain task-queue))
(send-client-data this)
(broadcast-arena-state this))
(-> ((physics)) ()
(observe-universe +framestep+))
(scene-processing-flow scene)
(instantly ()
(when (enabledp this)
(run looped-flow)))))
(let ((accumulated-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)
(send-client-data this)
(broadcast-arena-state this)
(setf accumulated-time 0)))
(-> ((physics)) ()
(observe-universe +framestep+))
(scene-processing-flow scene)
(instantly ()
(incf accumulated-time (- (real-time-seconds) start))
(when (enabledp this)
(run looped-flow)))))
(run looped-flow)))))))

0 comments on commit b681885

Please sign in to comment.