author | saiam |
Tue, 09 Dec 2008 02:26:42 +0000 | |
changeset 348 | 3ebcccc7ee44 |
parent 347 | 94fbc2bd6641 |
child 349 | ad6759185781 |
permissions | -rw-r--r-- |
333 | 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 | 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 | 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 | 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 | 44 |
\begin{itemize} |
45 |
\item \textsl{cd build} |
|
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 | 53 |
\item \textsl{make install} |
54 |
\end{itemize} |
|
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 | 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 | 78 |
\begin{center} |
79 |
\begin{tabular}{l|l} |
|
80 |
\textbf{Action} & \textbf{Default key(s)} \\ |
|
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 | 95 |
\end{tabular} |
96 |
\end{center} |
|
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 | 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 | 101 |
To start a network server on the default port, run \verb|kg --server| |
102 |
(\verb|kg -s|). You may optionally also specify the \verb|--graphics| |
|
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 | 105 |
To start a network client, connecting to a server running on the |
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 | 108 |
To use a non-default port, simply specify \verb|--port=PORT| |
109 |
(\verb|-p <port>|) on both client and server. |
|
293 | 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 | 112 |
All global game constants are defined in \textit{src/Config.hh}, and may be |
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 | 116 |
The program consists of four main parts: Graphics\&Input, GameState, |
117 |
Network and Physics. Each part contains various classes the relations |
|
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 | 120 |
The program starts from Application class and it then starts Engine |
121 |
which creates GameState, Graphics and different network related |
|
122 |
things. Physics simulation is started when GameState is created. |
|
347 | 123 |
|
348 | 124 |
GameState contains PhysicsWorld which inherits from Terrain and |
125 |
contains a list of PhysicsObjects. GameState also contains Player and |
|
126 |
Projectile objects which inherit from PhysicsObject (and are contained |
|
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 | 129 |
Player objects have a list of Weapon objects which they can use to |
130 |
create Projectiles. Every Player also has a Rope object, which is a |
|
131 |
separate PhysicsObject, and is either folded away, being thrown or |
|
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 | 134 |
Graphics and input are handled in their own classes. Graphics has an |
135 |
Input object which contains InputHandler objects for various classes |
|
136 |
of input. One such object is PlayerInput which affects the GameState's |
|
137 |
LocalPlayer. Other object is GuiInput which just modifies what the GUI |
|
138 |
look like on the client side. |
|
139 |
||
140 |
The network code is a bit complicated and has several layers. |
|
141 |
||
142 |
% Are these necessary? Can they be simplified. |
|
347 | 143 |
NetworkAddress and NetworkSocket are ClanLib's Socket/IPAddress |
144 |
types. NetworkPackets provide a mechanism to read/write values from/to |
|
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 | 147 |
NetworkUDP is an UDP socket. NetworkTCPServer is a listen() socket, |
148 |
which spawns NetworkTCPTransports when clients |
|
149 |
connect. NetworkTCPClient is itself a NetworkTCPTransport with a |
|
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 | 152 |
NetworkSession can have a NetworkTCPServer socket, and both client and |
153 |
server NetworkUDP sockets. Connected clients are represented as |
|
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 | 156 |
NetworkObjectControllers can be attached to a NetworkSession on a |
157 |
specific NetworkChannelID, and they then manage instances of |
|
158 |
NetworkObjects, which have NetworkObjectIDs that can be sent across |
|
159 |
the network. NetworkObjects can be used to send messages with a |
|
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 | 162 |
NetworkServer then has a NetworkSession and |
163 |
NetworkObject\_ServerController, and then creates NetworkServerPlayer |
|
164 |
and NetworkServerProjectile objects (that are |
|
165 |
NetworkObject\_Server's). |
|
166 |
||
167 |
NetworkClient then has a NetworkSession and a specialized |
|
168 |
NetworkClientController (NetworkObject\_ClientController) that creates |
|
169 |
NetworkClientLocalPlayer/NetworkClientRemotePlayer/NetworkClientProjectile |
|
170 |
objects when they are received from the server. |
|
171 |
||
172 |
||
173 |
TODO: Replace the above with some nice diagram, and make the text more |
|
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 | 177 |
|
301 | 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 | 186 |
\subsection{World and Objects} |
187 |
||
301 | 188 |
% COMMENT: I think these should be in a very basic level and they |
189 |
% shouldn't discuss too much about the game itself. The idea is just |
|
190 |
% to explain different kinds of structures and algorithms. |
|
269 | 191 |
|
301 | 192 |
% Terrain |
193 |
The terrain is an important part of our game. We represent our terrain |
|
194 |
as a large array. Each shell of the array has a type that tells what |
|
195 |
is in that position. Currently, possible terrain types are EMPTY, DIRT |
|
196 |
and ROCK. |
|
197 |
||
198 |
% Usually, in side view 2D-games, the terrain is representated as a |
|
199 |
% polygon. This allows us to implement collision detection and |
|
200 |
% bouncing rather easily, and it is also a very compact way of storing |
|
201 |
% the map. In our opinion Liero, however, is fundamentally a pixel |
|
202 |
% based game and therefore we represent the terrain as a large array |
|
203 |
% of pixels. These pixels are, however, abstract pixels, i.e. they are |
|
204 |
% not necessarily in the same scale than the physical resolution. In |
|
205 |
% other words, the server has an abstract resolution, which is the |
|
206 |
% same for all clients, and the clients can visualize this abstract |
|
207 |
% array of pixels in any resolution they wish. |
|
208 |
||
209 |
% Objects |
|
210 |
In our physics simulation the shapes of the different elements in the |
|
211 |
game are represented as polygons. A polygon is a vector of points that |
|
212 |
define the edges of the shape. |
|
213 |
||
214 |
% On top of the terrain, the world also includes a list of all objects |
|
215 |
% in it (players, projectiles and ropes). The objects have a polygon |
|
216 |
% shape which is used in the collision detection between the objects |
|
217 |
% and the terrain and the objects with each other. |
|
269 | 218 |
|
219 |
\subsection{Collision Detection} |
|
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 | 225 |
|
301 | 226 |
Collision detection algorithms check if objects in the physics |
227 |
simulation are colliding with eachother. Because our terrain is |
|
228 |
represented as an array and objects are represented as polygons we |
|
229 |
have two different kinds collision detection algorithms. |
|
230 |
||
231 |
The pixel based collision detection used to check collisions with the |
|
232 |
terrain is quite simple. It ``draws'' a line between two points A and |
|
233 |
B. The algorithm iterates over the line from point A to B and on each |
|
234 |
iteration it checks if theres a collision (i.e. the type of the |
|
235 |
current point is ROCK or DIRT). |
|
236 |
||
324 | 237 |
In order to implement bouncing from the terrain we have to have a way |
238 |
of calculating a normal for the slope of the terrain in the collision |
|
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 | 246 |
normal. % Picture would explain this a lot. |
269 | 247 |
|
248 |
\subsection{Physics} |
|
310 | 249 |
|
250 |
The fourth-order Runge-Kutta method is a numerical method for |
|
251 |
approximating the solution of an ordinary differential equation. In |
|
252 |
our game the Runge-Kutta method is used to calculate positions and |
|
253 |
velocities of physics objects when we apply forces to them. |
|
254 |
||
331 | 255 |
The mathematical formulation of the Runge-Kutta method: |
256 |
If we have an initial value problem of the form |
|
333 | 257 |
\begin{equation*} |
331 | 258 |
y' = f(t, y), \quad y(t_0) = y_0. |
333 | 259 |
\end{equation*} |
331 | 260 |
The we can describe the RK4 method for this problem by equations |
333 | 261 |
\begin{align*} |
331 | 262 |
y_{n+1} &= y_n + \tfrac{1}{6}h\left(k_1 + 2k_2 + 2k_3 + k_4 \right) \\ |
263 |
t_{n+1} &= t_n + h \\ |
|
333 | 264 |
\end{align*} |
331 | 265 |
where $y_{n+1}$ is the RK4 approximation of $y(t_{n+1})$, and |
333 | 266 |
\begin{align*} |
331 | 267 |
k_1 &= f(t_n, y_n) \\ |
268 |
k_2 &= f(t_n + \tfrac{1}{2}h, y_n + \tfrac{1}{2}h k_1) \\ |
|
269 |
k_3 &= f(t_n + \tfrac{1}{2}h, y_n + \tfrac{1}{2}h k_2) \\ |
|
270 |
k_4 &= f(t_n + h, y_n + h k_3) \\ |
|
333 | 271 |
\end{align*} |
331 | 272 |
The next value $(y_n+1)$ is determined by the present value $(y_n)$, |
273 |
the product of the interval $(h)$ and an estimated slope that is |
|
274 |
defined as $\frac{1}{6}h\left(k_1+2k_2+2k_3+k_4\right)$. |
|
310 | 275 |
|
333 | 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 | 279 |
\begin{enumerate} |
280 |
\item If player dies while rope is attached the rope will still be |
|
281 |
attached when the player spawns. |
|
345 | 282 |
\item If rope is thrown without releasing it first, rope will pull worm |
283 |
when midair |
|
340 | 284 |
\item Collisions with the terrain are only tested for the edgepoints |
285 |
of the polygon. |
|
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 | 289 |
We could have followed the schedule a lot better. Now we basically |
290 |
forgot the whole schedule and did things always when we had some spare |
|
291 |
time. And still we were late of the schedule. The good thing was that |
|
292 |
almost always all team members were doing things at the same time and |
|
293 |
communicating, either we were at the same place or everyone was on |
|
294 |
IRC. |
|
295 |
||
296 |
Tasks sharing worked pretty much as planned. Tero did all the network |
|
297 |
code and everyone else did everything that had something to do with |
|
298 |
physics and graphics. Most of our eye candy is done by Marko who was |
|
299 |
the responsible person for graphics. Marko, Eric and Atle made |
|
300 |
basically everything physics related. Most of the time every team |
|
301 |
member was working together so most of the code has been written as is |
|
302 |
as a result of a common agreement. |
|
303 |
||
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 | 307 |
The original plan was quite loose and it let us make decisions during |
308 |
development, which was a good thing. The basic structure of the |
|
309 |
program is pretty much as the one we thought about while |
|
310 |
planning. Though, many parts of the game have many levels of |
|
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 | 315 |
\bibitem{gaffer} Gaffer on games. Game |
316 |
Physics. 2006. http://gafferongames.wordpress.com/game-physics/ |
|
317 |
(read: 2008-12-08) |
|
323 | 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} |