\subtitle{\textbf{Lab} - Game Design Hack} \date{Monday (PM), 14 May 2018} \begin{document} \begin{frame} \titlepage \end{frame} \section{Intro} \begin{frame}{CE810 game engine} \begin{itemize}[<+->] \item Remember we mentioned that we built you a game engine... \item well, here it is. \end{itemize} \end{frame} \begin{frame}{Limitations} \note{\begin{itemize}} \begin{itemize}[<+->] \item Games take place on a hex grid \item Games are turn-based \item No randomness \note{\item In fairness, it is the UI and AI that do not support it} \end{itemize} \uncover<4>{We originally designed it for Civilization style games, but it's much more general than that.} \note{\end{itemize}} \end{frame} \section{Game Engine} \begin{frame}{Key Parts} \begin{itemize}[<+->] \item A game has \keyterm{Entity Types}, \keyterm{Resources}, and \keyterm{Terrain} \item Entity types have actions, costs and properties \item Resources and Terrain make up the maps \item Victory conditions tell you how to win (or lose) \end{itemize} \end{frame} \begin{frame}{Entity Types} \begin{itemize}[<+->] \item Used to \textbf{define} an \keyterm{Entity} \item \textbf{Every} entity has a type \item Entity Types can \textbf{extend} other types \item Defines: \begin{itemize} \item Graphics \item \keyterm{Actions} \item \keyterm{Properties} \end{itemize} \end{itemize} \end{frame} \begin{frame}[fragile]{Example: EntityType} \begin{minted}[breaklines,tabsize=4]{javascript} { "name": "abstract_civilian", "properties": { "movement": 1, "health": 5, "attackRange": 1, "atkMelee": 1, "ter-grass": 1 }, "cost": { "food": 10 }, \end{minted} \end{frame} \begin{frame}[fragile]{Example: EntityType} \begin{minted}[breaklines,tabsize=4]{javascript} "_actions": [ "Move", "MeleeAttackAction", "Build[farm]", "BuildOnResource[lumber_mill:wood]", "BuildOnResource[gold_mine:gold]", "Build[marketplace]" ] }, \end{minted} \end{frame} \begin{frame}{Entities} \begin{itemize}[<+->] \item Have an Entity Type \item Have \keyterm{properties} \item Can perform 1 \keyterm{Action} per turn \end{itemize} \end{frame} \begin{frame}{Actions} \begin{block}{Actions} \textbf{What} an Entity can do \end{block} \begin{itemize}[<+->] \item 0 or more \item Parameterisable \item Inherited \end{itemize} \end{frame} \begin{frame}{Orders} \begin{block}{Order} An order is \textbf{generated} when an Action is used on a \textbf{particular} location \end{block} \begin{itemize}[<+->] \item What an Entity \textbf{actually} does in its turn \item Used to \textbf{update} the game state \item Move Action $\rightarrow$ \textbf{multiple} possible Move Orders \end{itemize} \end{frame} \begin{frame}{Properties} \note{\begin{itemize}} \begin{itemize}[<+->] \item String $\rightarrow$ Integer mapping \item Used by default actions as well as custom ones \note{\item For example movement or attacking} \item \textbf{Two} sets per Entity \note{\item One from the Entity Type, another from the Entity itself that overrides it. EntityType properties can't be changed - only overwritten by lower level} \item Inherited \end{itemize} \note{\end{itemize}} \end{frame} \begin{frame}{Terrain} \note{\begin{itemize}} Terrain defines the ground in the games \begin{description} \item[id] The name of this terrain type \item[image] The graphics path for drawing \item[requiredTags] Mapping of String $\rightarrow$ Integer. \note{\item Keys are the tags needed as an entity property with ```ter-''} \note{\item Values are how much the entity property needs to be to travel here} \end{description} \note{\end{itemize}} \end{frame} \begin{frame}{Extensions} \note{\begin{itemize}} \begin{itemize}[<+->] \item The game is \textbf{extendible} \item You can \textbf{change} the json files \textbf{defining} the game \item You can \textbf{add} your own code \begin{itemize} \item It will be detected on the classpath \note{\item Built in items are detected the same } \item Use the same way as the built in items \note{\item First class citizens in the engine} \end{itemize} \item You can add \textbf{new}: \begin{itemize} \item Actions \item Orders \item AI \item Victory Conditions \end{itemize} \end{itemize} \note{\end{itemize}} \end{frame} \section{Example - Hexxagon} \begin{frame}{Hexxagon} \begin{center} \only<1>{\includegraphics[width=0.8\linewidth]{images/gd_hexxagon}\\} \uncover<2->{\includegraphics[width=0.7\linewidth]{images/gd_hexxagon}\\} \only<2>{Entity types: piece, piece-p1, piece-p2} \only<3>{Terrain types: board} \only<4>{Actions: jump and clone} \only<5>{Resources: ticks (used to permit moving only one piece)} \only<6>{Victory conditions: LastManStanding, MostPiecesLock} \end{center} \end{frame} \begin{frame}[fragile]{Entity Definition} \begin{minted}[breaklines]{javascript} { "name": "piece", // it's called 'piece' "properties": { "ter-playzone": 1, // it can 'walk' on playzone tiles "health": 1 // it has 1 health (things with no health die) }, "_actions":[ "Jump[tick]", // Jump Action (defined in Java) "Clone[tick]" // Clone action (defined in Java) ] }, \end{minted} \end{frame} \section{Design Patterns} \begin{frame}{Design Patterns} \begin{itemize}[<+->] \item Like programming patterns \item Many teams may have similar tasks to solve \item Some helpful patterns shown here \end{itemize} \end{frame} \begin{frame}{Movement Lock} Allow the player to only move one piece on their go \begin{itemize}[<+->] \item Resource: time \item Only allow a move if the resource < current tick \item After a move is made, update the resource to tick + 1 \end{itemize} \end{frame} \begin{frame}{Timers} You can define a timer by doing the following: \begin{itemize}[<+->] \item Create an automatic action that performs the effect that you'd like to achieve. \item Set requirements to be ``timeProperty $\geq$ timeRequired'' \item Create an automatic action that generates 1 timeProperty \item Define the automatic actions as [generateAction, doneAction] \end{itemize} \end{frame} \end{document}