EngineeringSoftwareDesign
Seqdiagramreport

Description

This code generates a UML sequence diagram using the TikZ-UML package. The diagram depicts a server-client game where players can spawn, move, and shoot bullets. The diagram shows the interactions between the two players and the server through various calls.

The actors in the sequence diagram are "Player A" and "Player B," and the object is the "Server." The first call in the diagram represents the spawning of a new player. If a player spawns after another player, then an update is made to both players.

The second call depicts Player B shooting a bullet and updating both players with the changes. The third call represents Player A moving, with the server updating both players again. The fourth call, which is inside a loop fragment, depicts the server's continuous game loop where it spawns health packs and updates both players with the changes.

The code uses TikZ to create the diagram, and the tikz-uml package to generate UML-specific syntax, such as actors, objects, and calls. The code also creates three layers, the foreground, main, and background, for styling and ordering purposes.

Keywords

tikz, tikz-uml, umlseqdiag, actor, object, call, fragment, loop, op, return, type, dt.

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}
		\umlactor{Player B}
		
		% Player spawns, no other player on the map
		\begin{umlcall}[op=new-player,return=update-players]{Player A}{Server}
		\end{umlcall}
		
		% Player spawns after player A, update both
		\begin{umlcall}[dt=7.5,op=new-player,return=update-players]{Player B}{Server}
		
		\begin{umlcall}[type=return,op=update-players]{Server}{Player A} 
		\end{umlcall} 
		\end{umlcall}
		
		% Player B shoots a bullet
		\begin{umlcall}[op=shoot-bullet,return=bullets-update]{Player B}{Server}
		\begin{umlcall}[type=return,op=bullets-update]{Server}{Player A} 
		\end{umlcall} 
		\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}
		\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