doc/kishna.tex
author saiam
Tue, 09 Dec 2008 02:26:42 +0000
changeset 348 3ebcccc7ee44
parent 347 94fbc2bd6641
child 349 ad6759185781
permissions -rw-r--r--
Simplified the architecture description a bit
333
50ec1ab32d2d Minor fixes to documentation
saiam
parents: 331
diff changeset
     1
\documentclass[a4paper,12pt]{article}
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
     2
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
     3
\usepackage[utf8]{inputenc}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
     4
\usepackage[english]{babel}
331
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
     5
\usepackage{amsmath}
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
     6
\usepackage{listings} % For listing code
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
     7
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
     8
% Fancy headers
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
     9
\usepackage{fancyhdr}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    10
\fancypagestyle{plain} {
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    11
    \fancyhf{}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    12
    \renewcommand{\headrulewidth}{0.4pt}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    13
    \lhead{\textbf{Group 66}}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    14
    \chead{\textbf{Kishna Glista - liero clone}}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    15
    \rhead{\textsl{AS-0.1102}}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    16
    \cfoot{\thepage}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    17
}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    18
\pagestyle{plain}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    19
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    20
% Paragraph formatting
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    21
\frenchspacing
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    22
\setlength{\parindent}{0pt} 
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    23
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    24
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    25
% Title information
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    26
\title{Kishna Glista - Liero Clone}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    27
\author{\normalsize{\begin{tabular}{lll}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    28
Atle Kivelä & 79171V & atle.kivela@tkk.fi \\
269
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
    29
Eric Malmi & 80351A & eric.malmi@tkk.fi \\
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    30
Tero Marttila & 79849E & tjmartti@cc.hut.fi \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    31
Marko Rasa & 78726L & morasa@cc.hut.fi \\
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    32
\end{tabular}}}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    33
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    34
% The document begins
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    35
\begin{document}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    36
\maketitle
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    37
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
    38
\section{Instructions for compiling and use}
293
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    39
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    40
\subsection{Configuring CMake}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    41
You must first generate the project's CMake configuration inside of \textsl{build}. A simple script is provided to do
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    42
so with some default settings. It will configure the install path as \textsl{~/opt}.
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    43
293
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    44
\begin{itemize}
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    45
\item \textsl{cd build}
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    46
\item \textsl{./mkcmake.sh}
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    47
\end{itemize}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    48
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    49
\subsection{Compiling and Installing}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    50
Once you have the CMake scripts in place, compiling should be as simple as running make:
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    51
\begin{itemize}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    52
\item \textsl{make}
293
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    53
\item \textsl{make install}
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    54
\end{itemize}
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    55
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    56
This will build the binary, and then copy the binary and data files to the install path configured above.
293
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    57
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    58
\subsection{Command-line Arguments}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    59
Running the game is done using command-line arguments to the executable
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    60
\begin{center}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    61
\begin{tabular}{l|l|l|l|l}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    62
\textbf{Short} & \textbf{Long} & \textbf{Value} & \textbf{Description} & \textbf{Default} \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    63
\hline
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    64
-p & \verb|--port| & PORT & Set server TCP/UDP port & 9338 \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    65
-s & \verb|--server| &  & Run as a network server & false \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    66
-c & \verb|--client| & SERVERHOST & Run as a network client on given server & false \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    67
-g & \verb|--graphics| & & Enable graphics rendering & * \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    68
\end{tabular}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    69
\end{center}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    70
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    71
* = true, except false when --server is given
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    72
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    73
The options \verb|--server| and \verb|--client| are mutually exclusive, and both cannot be selected at the same time.
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    74
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    75
\subsection{Keyboard Controls}
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    76
The default controls are identical to the origional Liero default controls, with some additions.
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    77
293
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    78
\begin{center}
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    79
\begin{tabular}{l|l}
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    80
\textbf{Action} & \textbf{Default key(s)} \\
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    81
\hline
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    82
Move Left & Arrow Left \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    83
Move Right & Arrow Right \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    84
Aim Up & Arrow Up \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    85
Aim Down & Arror Down \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    86
Dig & Move Left + Move Right \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    87
Shoot & Right Control \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    88
Jump & Right Shift \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    89
Change Weapon & Enter + Arrow Left / Arrow Right \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    90
Throw Rope & Change Weapon + Jump \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    91
Release Rope & Jump \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    92
Change Rope Length & Change Weapon + Aim Up / Aim Down \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    93
Suicide & Left Control + K \\
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    94
Exit Game & Esc \\
293
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    95
\end{tabular}
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    96
\end{center}
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
    97
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
    98
\subsection{Running the game}
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
    99
To simple start a local singleplayer game, just run \verb|kg| without any arguments.
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   100
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   101
To start a network server on the default port, run \verb|kg --server|
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   102
(\verb|kg -s|). You may optionally also specify the \verb|--graphics|
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   103
argument to have the server passively draw the graphics.
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   104
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   105
To start a network client, connecting to a server running on the
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   106
default port, run \verb|kg --client=ADDRESS| (\verb|kg -c <address>|).
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   107
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   108
To use a non-default port, simply specify \verb|--port=PORT|
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   109
(\verb|-p <port>|) on both client and server.
293
d40fbf8ba13b Added some text to documentation.
saiam
parents: 278
diff changeset
   110
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   111
\subsection{Configuration}
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   112
All global game constants are defined in \textit{src/Config.hh}, and may be
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   113
experimented with. Weapon parameters are defined in \textit{src/Weapons.cc}.
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   114
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   115
\section{Program architecture}
348
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   116
The program consists of four main parts: Graphics\&Input, GameState,
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   117
Network and Physics. Each part contains various classes the relations
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   118
show up in the doxygen generated documentation of the program.
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   119
348
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   120
The program starts from Application class and it then starts Engine
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   121
which creates GameState, Graphics and different network related
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   122
things. Physics simulation is started when GameState is created.
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   123
348
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   124
GameState contains PhysicsWorld which inherits from Terrain and
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   125
contains a list of PhysicsObjects. GameState also contains Player and
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   126
Projectile objects which inherit from PhysicsObject (and are contained
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   127
in PhysicsWorld).
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   128
348
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   129
Player objects have a list of Weapon objects which they can use to
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   130
create Projectiles. Every Player also has a Rope object, which is a
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   131
separate PhysicsObject, and is either folded away, being thrown or
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   132
attached to the terrain.
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   133
348
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   134
Graphics and input are handled in their own classes. Graphics has an
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   135
Input object which contains InputHandler objects for various classes
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   136
of input. One such object is PlayerInput which affects the GameState's
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   137
LocalPlayer. Other object is GuiInput which just modifies what the GUI
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   138
look like on the client side.
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   139
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   140
The network code is a bit complicated and has several layers.
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   141
3ebcccc7ee44 Simplified the architecture description a bit
saiam
parents: 347
diff changeset
   142
% Are these necessary? Can they be simplified.
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   143
NetworkAddress and NetworkSocket are ClanLib's Socket/IPAddress
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   144
types. NetworkPackets provide a mechanism to read/write values from/to
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   145
a byte buffer, and NetworkBuffer is used for buffering socket I/O.
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   146
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   147
NetworkUDP is an UDP socket. NetworkTCPServer is a listen() socket,
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   148
which spawns NetworkTCPTransports when clients
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   149
connect. NetworkTCPClient is itself a NetworkTCPTransport with a
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   150
connect()'d socket.
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   151
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   152
NetworkSession can have a NetworkTCPServer socket, and both client and
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   153
server NetworkUDP sockets. Connected clients are represented as
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   154
NetworkNodes.
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   155
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   156
NetworkObjectControllers can be attached to a NetworkSession on a
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   157
specific NetworkChannelID, and they then manage instances of
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   158
NetworkObjects, which have NetworkObjectIDs that can be sent across
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   159
the network. NetworkObjects can be used to send messages with a
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   160
specific NetworkMessageID.
344
a1ac08c37f0f reorganize section 1 of documentation, and write a lot of really hard-to-read text in section 2
terom
parents: 340
diff changeset
   161
347
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   162
NetworkServer then has a NetworkSession and
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   163
NetworkObject\_ServerController, and then creates NetworkServerPlayer
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   164
and NetworkServerProjectile objects (that are
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   165
NetworkObject\_Server's).
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   166
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   167
NetworkClient then has a NetworkSession and a specialized
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   168
NetworkClientController (NetworkObject\_ClientController) that creates
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   169
NetworkClientLocalPlayer/NetworkClientRemotePlayer/NetworkClientProjectile
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   170
objects when they are received from the server.
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   171
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   172
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   173
TODO: Replace the above with some nice diagram, and make the text more
94fbc2bd6641 Minor fixes to documentation.
saiam
parents: 345
diff changeset
   174
brief
278
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   175
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   176
\section{Data structures and algorithms}
269
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   177
301
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   178
278
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   179
\subsection{Basic data structures}
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   180
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   181
\begin{itemize}
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   182
\item Vector
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   183
\item List
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   184
\end{itemize}
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   185
269
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   186
\subsection{World and Objects}
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   187
301
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   188
% COMMENT: I think these should be in a very basic level and they
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   189
% shouldn't discuss too much about the game itself. The idea is just
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   190
% to explain different kinds of structures and algorithms.
269
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   191
301
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   192
% Terrain
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   193
The terrain is an important part of our game. We represent our terrain
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   194
as a large array. Each shell of the array has a type that tells what
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   195
is in that position. Currently, possible terrain types are EMPTY, DIRT
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   196
and ROCK. 
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   197
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   198
% Usually, in side view 2D-games, the terrain is representated as a
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   199
% polygon. This allows us to implement collision detection and
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   200
% bouncing rather easily, and it is also a very compact way of storing
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   201
% the map. In our opinion Liero, however, is fundamentally a pixel
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   202
% based game and therefore we represent the terrain as a large array
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   203
% of pixels. These pixels are, however, abstract pixels, i.e. they are
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   204
% not necessarily in the same scale than the physical resolution. In
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   205
% other words, the server has an abstract resolution, which is the
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   206
% same for all clients, and the clients can visualize this abstract
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   207
% array of pixels in any resolution they wish.
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   208
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   209
% Objects
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   210
In our physics simulation the shapes of the different elements in the
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   211
game are represented as polygons. A polygon is a vector of points that
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   212
define the edges of the shape.
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   213
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   214
% On top of the terrain, the world also includes a list of all objects
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   215
% in it (players, projectiles and ropes). The objects have a polygon
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   216
% shape which is used in the collision detection between the objects
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   217
% and the terrain and the objects with each other.
269
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   218
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   219
\subsection{Collision Detection}
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   220
278
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   221
\begin{itemize}
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   222
\item Polygon collision detection
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   223
\item Pixel collision detection
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   224
\end{itemize}
269
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   225
301
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   226
Collision detection algorithms check if objects in the physics
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   227
simulation are colliding with eachother. Because our terrain is
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   228
represented as an array and objects are represented as polygons we
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   229
have two different kinds collision detection algorithms.
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   230
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   231
The pixel based collision detection used to check collisions with the
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   232
terrain is quite simple. It ``draws'' a line between two points A and
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   233
B. The algorithm iterates over the line from point A to B and on each
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   234
iteration it checks if theres a collision (i.e. the type of the
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   235
current point is ROCK or DIRT).
02ad02d28245 Some documentation
saiam
parents: 293
diff changeset
   236
324
3daa94b111e4 Cleaned up documentation a little bit
saiam
parents: 323
diff changeset
   237
In order to implement bouncing from the terrain we have to have a way
3daa94b111e4 Cleaned up documentation a little bit
saiam
parents: 323
diff changeset
   238
of calculating a normal for the slope of the terrain in the collision
3daa94b111e4 Cleaned up documentation a little bit
saiam
parents: 323
diff changeset
   239
point. We came up with the following algorithm for calculating the
278
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   240
approximation for the normal. Take the collision point and the point
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   241
before the collision and consider a 3x3 array of pixels which has the
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   242
collision point in the middle of it. Then, do sort of an bredth-first
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   243
search from the previous point to get all the empty pixels. Take the
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   244
vectors from the collision point to the empty point and sum these
2b856bc88e6d Added random stuff to documentation. Time to go to sleep.
saiam
parents: 269
diff changeset
   245
vectors. The resulting vector will point approximately along the
324
3daa94b111e4 Cleaned up documentation a little bit
saiam
parents: 323
diff changeset
   246
normal. % Picture would explain this a lot. 
269
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   247
9024e805b4e2 Some algorithms.
ekku
parents: 238
diff changeset
   248
\subsection{Physics}
310
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   249
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   250
The fourth-order Runge-Kutta method is a numerical method for
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   251
approximating the solution of an ordinary differential equation. In
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   252
our game the Runge-Kutta method is used to calculate positions and
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   253
velocities of physics objects when we apply forces to them.
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   254
331
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   255
The mathematical formulation of the Runge-Kutta method:
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   256
If we have an initial value problem of the form
333
50ec1ab32d2d Minor fixes to documentation
saiam
parents: 331
diff changeset
   257
\begin{equation*}
331
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   258
y' = f(t, y), \quad y(t_0) = y_0.
333
50ec1ab32d2d Minor fixes to documentation
saiam
parents: 331
diff changeset
   259
\end{equation*}
331
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   260
The we can describe the RK4 method for this problem by equations
333
50ec1ab32d2d Minor fixes to documentation
saiam
parents: 331
diff changeset
   261
\begin{align*}
331
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   262
y_{n+1} &= y_n + \tfrac{1}{6}h\left(k_1 + 2k_2 + 2k_3 + k_4 \right) \\
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   263
t_{n+1} &= t_n + h \\
333
50ec1ab32d2d Minor fixes to documentation
saiam
parents: 331
diff changeset
   264
\end{align*}
331
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   265
where $y_{n+1}$ is the RK4 approximation of $y(t_{n+1})$, and
333
50ec1ab32d2d Minor fixes to documentation
saiam
parents: 331
diff changeset
   266
\begin{align*}
331
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   267
k_1 &= f(t_n, y_n) \\
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   268
k_2 &= f(t_n + \tfrac{1}{2}h, y_n + \tfrac{1}{2}h k_1) \\
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   269
k_3 &= f(t_n + \tfrac{1}{2}h, y_n + \tfrac{1}{2}h k_2) \\
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   270
k_4 &= f(t_n + h, y_n + h k_3) \\
333
50ec1ab32d2d Minor fixes to documentation
saiam
parents: 331
diff changeset
   271
\end{align*}
331
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   272
The next value $(y_n+1)$ is determined by the present value $(y_n)$,
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   273
the product of the interval $(h)$ and an estimated slope that is
65e104a2db8f Added rungen kutta to documentation
saiam
parents: 324
diff changeset
   274
defined as $\frac{1}{6}h\left(k_1+2k_2+2k_3+k_4\right)$.
310
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   275
333
50ec1ab32d2d Minor fixes to documentation
saiam
parents: 331
diff changeset
   276
% TODO: something network related?
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   277
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   278
\section{Known bugs}
340
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   279
\begin{enumerate}
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   280
\item If player dies while rope is attached the rope will still be
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   281
  attached when the player spawns.
345
bea1c1513692 1 bug documented
nireco
parents: 344
diff changeset
   282
\item If rope is thrown without releasing it first, rope will pull worm
bea1c1513692 1 bug documented
nireco
parents: 344
diff changeset
   283
  when midair
340
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   284
\item Collisions with the terrain are only tested for the edgepoints
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   285
  of the polygon.
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   286
\end{enumerate}
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   287
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   288
\section{Tasks sharing and schedule}
340
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   289
We could have followed the schedule a lot better. Now we basically
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   290
forgot the whole schedule and did things always when we had some spare
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   291
time. And still we were late of the schedule. The good thing was that
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   292
almost always all team members were doing things at the same time and
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   293
communicating, either we were at the same place or everyone was on
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   294
IRC.
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   295
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   296
Tasks sharing worked pretty much as planned. Tero did all the network
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   297
code and everyone else did everything that had something to do with
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   298
physics and graphics. Most of our eye candy is done by Marko who was
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   299
the responsible person for graphics. Marko, Eric and Atle made
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   300
basically everything physics related. Most of the time every team
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   301
member was working together so most of the code has been written as is
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   302
as a result of a common agreement.
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   303
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   304
We feel that the workload was shared quite even. % Or does someone disagree with this?
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   305
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   306
\section{Differences to the original plan}
340
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   307
The original plan was quite loose and it let us make decisions during
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   308
development, which was a good thing. The basic structure of the
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   309
program is pretty much as the one we thought about while
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   310
planning. Though, many parts of the game have many levels of
7cbd6395038f Something to the doc.
saiam
parents: 333
diff changeset
   311
abstraction (of course).
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   312
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   313
% References
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   314
\begin{thebibliography}{99}
310
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   315
\bibitem{gaffer} Gaffer on games. Game
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   316
  Physics. 2006. http://gafferongames.wordpress.com/game-physics/
7e0cfc5f0944 Wrote something to documentation
saiam
parents: 301
diff changeset
   317
  (read: 2008-12-08)
323
a17043af6995 Moved one link from source to documentation.
saiam
parents: 310
diff changeset
   318
\bibitem{fractal} Terrain texture generation.  http://www.gameprogrammer.com/fractal.html
238
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   319
\end{thebibliography}
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   320
15193c2bbe2f Added documentation draft. It is done in tex. Hopefully everyone is okay with that.
saiam
parents:
diff changeset
   321
\end{document}