EngineeringSoftwareDesign
Disconnectedfromgame

Description

This is a LaTeX document that uses the TikZ package to draw a sequence diagram for a multiplayer game server. The diagram shows interactions between three components: "Player A", "Player B", and the "Server".

The diagram starts with "Player A" calling the "move-player" operation on the "Server", which then returns an "update-players" message to both "Player A" and "Player B".

Then, "Player B" calls the "shoot-bullet" operation on the "Server", which returns a "bullets-update" message to both "Player A" and "Player B". The "Server" then sends a "player-hit" message to "Player A".

Next, "Player A" initiates a "disconnect" operation with the "Server", which returns another "update-players" message to "Player B".

The commented out sections of the code suggest that there may have been further interactions and features planned for this game, but are not currently in use.

Keywords

tikz, tikzscale, pgfdeclarelayer, pgfsetlayers, tikz-uml, babel, umlseqdiag, umlactor, umlmulti, umlcall, umlcallself, umlfragment.

Source Code

EngineeringSoftwareDesign

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikzscale}
\pgfdeclarelayer{background,foreground}
\pgfsetlayers{background,main,foreground}
\usepackage{tikz-uml}
\usepackage[english]{babel}  % load this package so tikz-uml loads, it may be due to my japanesse localle lol.
 
\begin{document}
\begin{tikzpicture}
	\begin{umlseqdiag}
		\umlactor{Player A}
		%\umlobject{Server}
		\umlmulti{Server}
		\umlactor{Player B}
		
		% Player spawns, no other player on the map
		\begin{umlcall}[op=move-player,return=update-players]{Player A}{Server}
		
		\begin{umlcall}[type=return,op=update-players]{Server}{Player B} 
		\end{umlcall} 
		\end{umlcall}
		
		% Player B shoots a bullet
		\begin{umlcall}[op=shoot-bullet,return=bullets-update]{Player B}{Server}
				\begin{umlcallself}[op=ServerGameLoop]{Server}
		\end{umlcallself}
		\begin{umlcall}[type=return,op=bullets-update]{Server}{Player A} 
		\end{umlcall} 
		\end{umlcall}
		\begin{umlcall}[type=return,op=player-hit]{Server}{Player A} 
		\end{umlcall} 
		
		\begin{umlcall}[op=disconnect,type = synchron]{Player A}{Server}
		\end{umlcall}
		\begin{umlcall}[type=return,op=update-players]{Server}{Player B} 
		\end{umlcall} 
		% Player A Moves
%		\begin{umlcall}[op=move-player,return=update-players]{Player B}{Server}
%		\begin{umlcall}[type=return,op=update-players]{Server}{Player A} 
%		\end{umlcall} 
%		\end{umlcall}
		
		%% Game Loop
%		\begin{umlfragment}[type=loop]
%		\begin{umlcallself}[dt=5,op=ServerGameLoop]{Server}
%		\begin{umlcallself}[op=spawnHealthPacks]{Server}
%		\end{umlcallself}
%		% Update hearts, mini-ships on both sides
%		\begin{umlcall}[type=return,op=healthPack-update]{Server}{Player A} 
%		\end{umlcall} 
%		\begin{umlcall}[type=return,op=healthPack-update]{Server}{Player B}
%		\begin{umlcall}[type=return,op=bullet-update]{Server}{Player A} 
%		\end{umlcall}  
%		\begin{umlcall}[type=return,op=bullet-update]{Server}{Player B} 
%		\end{umlcall}  
%		\end{umlcall} 
%				\end{umlcallself}
%		\end{umlfragment}
	\end{umlseqdiag}
\end{tikzpicture}
 
 
\end{document}
Deploy to Overleaf