diff --git a/slides.tex b/slides.tex index b2d9b1d..15979ac 100644 --- a/slides.tex +++ b/slides.tex @@ -6,6 +6,8 @@ \usetheme{metropolis} +\usepackage{outlines} + \usepackage{minted} \setminted{fontsize=\footnotesize,samepage=true} %\usepackage{xcolor} @@ -66,12 +68,69 @@ Hate \item git-modules - do not bloat contributions } -\begin{frame}[allowframebreaks, fragile]{We made an ECS - almost?} +\begin{frame}[allowframebreaks, fragile]{We made an ECS} Why an ECS - Entity Component System? \begin{itemize} \item Encourages reusable code + \item "Plug-and-play" to add functionality + \item We found a video tutorial series for it + \item Simplified implementation: Entities propagate updates to the components \end{itemize} \end{frame} +\note[itemize]{ + \item Reusable code mainly on engine side, but also applies to game dev components + \item plug and play mostly an advantage for game dev - i.e. "I want physics, here are physics" + \item \say{video series} - tease issue of abruptly ending + \item Components usually only have data, and are querried by the system (hence ecS) + \item System part used for rendering +} +\begin{frame}[allowframebreaks, fragile]{We made an ECS - Implementation} +\begin{minted}[linenos,autogobble,samepage=false]{c++} +class Entity { +private: + std::vector> components; + ComponentArray componentArray = {}; + ComponentBitSet componentBitSet; +public: + void update(uint_fast16_t diffTime) const; + template bool hasComponent() const { + return componentBitSet[getComponentTypeID()]; + } + template T& getComponent() const { + auto ptr(componentArray[getComponentTypeID()]); + return *static_cast(ptr); + } + template T& addComponent(TArgs&&...mArgs) { + T* c(new T(std::forward(mArgs)...)); + c->entity = this; + std::unique_ptr uPtr{ c }; + this->components.emplace_back(std::move(uPtr)); + + componentArray[getComponentTypeID()] = c; + componentBitSet[getComponentTypeID()] = true; + + c->init(); + return *c; + }; +}; +\end{minted} +\end{frame} +\note[itemize]{ + \item appologize for formatting - for the sake of compactness + \item TypeID: increments through all components - copied from video tutorial + \item NOT beginner friendly +} +\begin{frame}[allowframebreaks, fragile]{We made an ECS - Usage} +Very easy to use: +\begin{minted}[linenos,autogobble]{c++} +auto& projectile(this->manager->addEntity()); +projectile.addComponent(pos.x, pos.y, 32, 32, scale); +projectile.addComponent(texture, 4); // 4 => zIndex +projectile.addComponent(range, speed, velocity, owner); +projectile.addComponent(0.6f); +\end{minted} +\end{frame} +\note{mention: this ease of use is our goal} \begin{frame}[allowframebreaks, fragile]{Memory Management} \begin{minted}[linenos,autogobble]{c++} class Manager @@ -99,7 +158,7 @@ Does that solve memory management? Not quite: \end{frame} %code example -\begin{frame}[fragile] +\begin{frame}[fragile]{Hello, World!} \begin{minted}[linenos,autogobble]{c} #include