mirror of
https://github.com/kuhyx/engineer-thesis-WUT.git
synced 2026-07-04 13:23:09 +02:00
feat: added constants secftion
This commit is contained in:
parent
03c3c0d353
commit
5b89acd621
@ -122,8 +122,24 @@
|
|||||||
}
|
}
|
||||||
{\endtrivlist}
|
{\endtrivlist}
|
||||||
|
|
||||||
|
\usepackage{listings}
|
||||||
|
\usepackage{xcolor}
|
||||||
|
\lstdefinestyle{C++Style}{
|
||||||
|
language=C++,
|
||||||
|
basicstyle=\footnotesize\ttfamily,
|
||||||
|
keywordstyle=\color{blue},
|
||||||
|
commentstyle=\color{gray},
|
||||||
|
stringstyle=\color{red},
|
||||||
|
numbers=left,
|
||||||
|
numberstyle=\tiny,
|
||||||
|
frame=single,
|
||||||
|
keepspaces=true,
|
||||||
|
showspaces=false,
|
||||||
|
showtabs=false,
|
||||||
|
tabsize=2,
|
||||||
|
breaklines=true,
|
||||||
|
breakatwhitespace=true
|
||||||
|
}
|
||||||
|
|
||||||
\newfontfamily{\adagio}{Adagio_Slab}
|
\newfontfamily{\adagio}{Adagio_Slab}
|
||||||
\newfontfamily{\adagioLight}{Adagio Slab Light}
|
\newfontfamily{\adagioLight}{Adagio Slab Light}
|
||||||
@ -956,7 +972,7 @@ For our Match Three game engine, we aimed to create a simple core, capable of en
|
|||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item Platform Independence: Core engine functionalities independent of any specific platform, allowing for easy porting across Windows, MacOS, and GNU/Linux.
|
\item Platform Independence: Core engine functionalities independent of any specific platform, allowing for easy porting across Windows, MacOS, and GNU/Linux.
|
||||||
|
|
||||||
\item Simplicity: There are no more than 2500 lines of code in the entire engine
|
\item Simplicity: There are no more than 1500 lines of code in the entire engine
|
||||||
|
|
||||||
\item Good coding style: When writing code, popular coding styles of cpplint and clang-tidy were used
|
\item Good coding style: When writing code, popular coding styles of cpplint and clang-tidy were used
|
||||||
|
|
||||||
@ -1013,7 +1029,6 @@ The engine's architecture is segmented into modules:
|
|||||||
.3 post\_processing.vs.
|
.3 post\_processing.vs.
|
||||||
.3 post\_processor.cpp.
|
.3 post\_processor.cpp.
|
||||||
.3 post\_processor.h.
|
.3 post\_processor.h.
|
||||||
.3 power\_up.h.
|
|
||||||
.3 resource\_manager.cpp\DTcomment{For loading assets}.
|
.3 resource\_manager.cpp\DTcomment{For loading assets}.
|
||||||
.3 resource\_manager.h.
|
.3 resource\_manager.h.
|
||||||
.3 shader.cpp.
|
.3 shader.cpp.
|
||||||
@ -1039,8 +1054,8 @@ The engine's architecture is segmented into modules:
|
|||||||
.2 CmakLists.txt\DTcomment{Holds instructions for how to build the engine}.
|
.2 CmakLists.txt\DTcomment{Holds instructions for how to build the engine}.
|
||||||
}
|
}
|
||||||
|
|
||||||
\section{Main game loop}
|
\subsection{Main function}
|
||||||
\begin{figure}[htp]
|
\begin{figure}[H]
|
||||||
\centering
|
\centering
|
||||||
\begin{tikzpicture}[node distance=2cm]
|
\begin{tikzpicture}[node distance=2cm]
|
||||||
\useasboundingbox (-5,0) rectangle (5, -17); % Set a custom bounding box
|
\useasboundingbox (-5,0) rectangle (5, -17); % Set a custom bounding box
|
||||||
@ -1075,17 +1090,103 @@ The engine's architecture is segmented into modules:
|
|||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
\paragraph{GLFW initialization}
|
\paragraph{GLFW initialization}
|
||||||
Very first operation of our engine is to initliaze GLFW context, window and openGL
|
Very first operation of our engine is to initliaze GLFW context, window and openGL, we set version of glfw to 3.3, resizable window and the profile depending on whether the engine got initialized on MacOS, or Linux/Windows, we set the windows width and height based on values from constants file
|
||||||
|
|
||||||
|
\subsubsection{Main Loop}
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\begin{tikzpicture}[node distance=2cm]
|
||||||
|
\useasboundingbox (-5,0) rectangle (5, -11); % Set a custom bounding box
|
||||||
|
\node (start) [startstop] {Enter main loop};
|
||||||
|
|
||||||
|
\node (pro2) [process, below of=start] {Process input};
|
||||||
|
\draw [arrow] (start) -- (pro2);
|
||||||
|
\node (pro3) [process, below of=pro2] {Update game state};
|
||||||
|
\draw [arrow] (pro2) -- (pro3);
|
||||||
|
|
||||||
|
\node (pro4) [process, below of=pro3] {Render};
|
||||||
|
\draw [arrow] (pro3) -- (pro4);
|
||||||
|
|
||||||
|
\node (dec1) [decision, below of=pro4] {Closed?};
|
||||||
|
\draw [arrow] (pro4) -- (dec1);
|
||||||
|
% Arrow from 'Closed?' decision node to 'Main Loop' node
|
||||||
|
\draw [arrow] (dec1.east) -- ++(2,0) |- node[anchor=south] {no} (start);
|
||||||
|
|
||||||
|
\node (close) [startstop, below of=dec1] {Close};
|
||||||
|
\draw [arrow] (dec1) -- node[anchor=east] {yes} (close);
|
||||||
|
|
||||||
|
\end{tikzpicture}
|
||||||
|
\caption{Main loop}
|
||||||
|
\label{fig:main_function_logic}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\paragraph{Process inputs}
|
||||||
|
Reacts to user inputs and sets up game state based on them, for example which tile was chosen by user
|
||||||
|
|
||||||
|
\paragraph{Update game state}
|
||||||
|
Changes game level, removes blocks if applicable, drops new blocks and checks for win/lose conditions
|
||||||
|
|
||||||
|
\paragraph{Render}
|
||||||
|
Based on changes from previous steps draws actual game window.
|
||||||
|
|
||||||
\subsection{Dependency Management}
|
|
||||||
There are several libraries: OpenGL, GLFW, stb\_image and freetype being integrated into engine, they are simply included at the top of any files that need them.
|
|
||||||
|
|
||||||
\subsection{Constants file}
|
\subsection{Constants file}
|
||||||
Game parameters, from graphics settings to gameplay variables, are stored in constants.cpp file, which can be modified, to apply the changes the engine must be compiled again.
|
Game parameters, from graphics settings to gameplay variables, are stored in constants.cpp file, which can be modified, to apply the changes the engine must be compiled again.
|
||||||
|
|
||||||
|
|
||||||
|
\subsection*{Game Constants}
|
||||||
|
|
||||||
|
\textbf{constants} namespace: Used for constants that are used over the project, for example colors, colors are hold in open gl vector of 3 values (for RGB colors)
|
||||||
|
|
||||||
|
\begin{lstlisting}[style=C++Style]
|
||||||
|
namespace constants {
|
||||||
|
constexpr glm::vec3 LIGHT_BLUE = glm::vec3(0.2F, 0.6F, 1.0F);
|
||||||
|
...
|
||||||
|
}
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
|
\newpage
|
||||||
|
\textbf{text} namespace: Parameters concerning text display positions on screen.
|
||||||
|
|
||||||
|
\begin{lstlisting}[style=C++Style]
|
||||||
|
struct Point {
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace text {
|
||||||
|
constexpr Point LIVES_POSITION = {5.0F, 5.0F};
|
||||||
|
...
|
||||||
|
}
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
|
\textbf{textures} namespace: Provides paths to texture files and their respective identifiers, in this examples gems are named as: "g" for gems, number of gem and then color of gem
|
||||||
|
|
||||||
|
\begin{lstlisting}[style=C++Style]
|
||||||
|
|
||||||
|
struct TextureInfo {
|
||||||
|
const char* path;
|
||||||
|
const char* name;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace textures {
|
||||||
|
static constexpr TextureInfo textures[] = {
|
||||||
|
{"resources/textures/background.jpg", "background"},
|
||||||
|
{"resources/textures/g1black.png", "block_black"},
|
||||||
|
{"resources/textures/g2blue.png", "block_blue"},
|
||||||
|
{"resources/textures/g3green.png", "block_green"},
|
||||||
|
{"resources/textures/g4purple.png", "block_purple"}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
|
\subsection{Dependency Management}
|
||||||
|
There are several libraries: OpenGL, GLFW, stb\_image and freetype being integrated into engine, they are simply included at the top of any files that need them.
|
||||||
|
|
||||||
\section{Match Three Logic and Mechanics}
|
\section{Match Three Logic and Mechanics}
|
||||||
Match Three game challenges players to align identical items in rows or columns of three or more. This section describes how the Match Three logic and mechanics were implemented within our game engine.
|
Match Three game challenges players to align identical items in rows or columns of three or more. This section describes how the Match Three logic and mechanics were implemented within our game engine.
|
||||||
|
|
||||||
|
|
||||||
\subsection{The Fundamental Game Grid}
|
\subsection{The Fundamental Game Grid}
|
||||||
|
|
||||||
A Match Three game takes place on a grid, where each cell holds an item (tile):
|
A Match Three game takes place on a grid, where each cell holds an item (tile):
|
||||||
|
|||||||
10
Thesis/images/mainLoop.drawio
Normal file
10
Thesis/images/mainLoop.drawio
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<mxfile host="app.diagrams.net" modified="2023-08-29T17:43:03.020Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" etag="HjrXqwIhBXk7ok3RFx8b" version="21.6.9" type="device">
|
||||||
|
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
|
||||||
|
<mxGraphModel dx="790" dy="1113" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||||
|
<root>
|
||||||
|
<mxCell id="WIyWlLk6GJQsqaUBKTNV-0" />
|
||||||
|
<mxCell id="WIyWlLk6GJQsqaUBKTNV-1" parent="WIyWlLk6GJQsqaUBKTNV-0" />
|
||||||
|
</root>
|
||||||
|
</mxGraphModel>
|
||||||
|
</diagram>
|
||||||
|
</mxfile>
|
||||||
Loading…
Reference in New Issue
Block a user