Skip to content
Permalink
Browse files

Register when server player is hit

  • Loading branch information
borodust committed Apr 24, 2017
1 parent 9179e6b commit 11eab867ee9370daed87b273302f94d9971abb6d
Showing with 39 additions and 13 deletions.
  1. +32 −10 client/src/dude.lisp
  2. +7 −3 client/src/main.lisp
@@ -183,18 +183,22 @@
(mortar-model)))))


(defun move-body (body player)
(let* ((p-pos (position-of player))
(pos (mult *model-matrix* (add *dude-bounds-initial-position*
(vec4 (x p-pos) 0.0 (- (y p-pos))))))
(w (w pos)))
(flet ((w/ (v)
(/ v w)))
(setf (position-of body) (vec3 (w/ (x pos))
(w/ (y pos))
(w/ (z pos)))))))


(defmethod scene-pass ((this dude-model) (pass simulation-pass) input)
(with-slots (body player) this
(let* ((p-pos (position-of player))
(pos (mult *model-matrix* (add *dude-bounds-initial-position*
(vec4 (x p-pos) 0.0 (- (y p-pos))))))
(w (w pos)))
(flet ((w/ (v)
(/ v w)))
(setf (position-of body) (vec3 (w/ (x pos))
(w/ (y pos))
(w/ (z pos)))))))
(call-next-method))
(move-body body player)
(call-next-method)))


(defmethod scene-pass ((this dude-model) pass input)
@@ -205,3 +209,21 @@
(translation-mat4 (x pos) 0.0 (- (y pos)))
(euler-angles->mat4 (vec3 0.0 (y rot) 0.0)))))
(call-next-method))))


;;
(defclass player-node (scene-node)
((body :initform nil)
(player :initarg :player)))


(defmethod initialization-flow ((this player-node) &key)
(with-slots (body player) this
(>> (-> ((physics)) ()
(setf body (make-instance 'dude-body :owner player)))
(call-next-method))))


(defmethod scene-pass ((this player-node) pass input)
(with-slots (body player) this
(move-body body player)))
@@ -49,10 +49,12 @@
(server (make-game-server new-arena)))
(run (>> (register-game-stream server (server-identity-id identity))
(create-arena remote-server name)
(-> ((mortar-combat)) ()
(assembly-flow 'player-node :player (player-of new-arena))
(-> ((mortar-combat)) (player)
(setf arena new-arena
game-server server)
(update-player-camera scene arena))
(update-player-camera scene arena)
(adopt (find-node (root-of scene) :dude-group) player))
(-> ((host)) ()
(lock-cursor)))))))

@@ -67,10 +69,12 @@
(client (make-game-client new-arena)))
(run (>> (register-game-stream client (server-identity-id identity))
(join-arena remote-server name)
(-> ((mortar-combat)) ()
(assembly-flow 'player-node :player (player-of new-arena))
(-> ((mortar-combat)) (player)
(setf arena new-arena
game-client client)
(update-player-camera scene arena)
(adopt (find-node (root-of scene) :dude-group) player)
(register-player client (server-identity-name identity)))
(-> ((host)) ()
(lock-cursor)))))))

0 comments on commit 11eab86

Please sign in to comment.
You can’t perform that action at this time.