Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Register when server player is hit
  • Loading branch information
borodust committed Apr 24, 2017
1 parent 9179e6b commit 11eab86
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
42 changes: 32 additions & 10 deletions client/src/dude.lisp
Expand Up @@ -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)
Expand All @@ -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)))
10 changes: 7 additions & 3 deletions client/src/main.lisp
Expand Up @@ -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)))))))

Expand All @@ -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)))))))
Expand Down

0 comments on commit 11eab86

Please sign in to comment.