\hypertarget{game_basics_8cpp_source}{}\doxysection{game\+Basics.\+cpp}
\label{game_basics_8cpp_source}\index{src/game/gameBasics.cpp@{src/game/gameBasics.cpp}}
\mbox{\hyperlink{game_basics_8cpp}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00001}00001 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00012}00012 \textcolor{preprocessor}{\#include <chrono>}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00013}00013 \textcolor{preprocessor}{\#include <thread>}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00014}00014 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{game_8h}{game.h}}"{}}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00015}00015 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{play_mode_8h}{playMode.h}}"{}}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00016}00016 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{good_pixel_manager_8h}{pixelManager/goodPixelManager.h}}"{}}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00017}00017 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00018}\mbox{\hyperlink{game_basics_8cpp_ab3ae3d2c20c90e75f1ad88ba88227bb7}{00018}} \textcolor{preprocessor}{\#define WININIT window("{}SUPER Space Invader : Turbo Apocalypse DX -\/ VS GOD"{}}, Position(1280, 720), Position(128, 128), nsGraphics::KBlack)}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00019}00019 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00020}\mbox{\hyperlink{class_game_ad59df6562a58a614fda24622d3715b65}{00020}} \mbox{\hyperlink{class_game_ad59df6562a58a614fda24622d3715b65}{Game::Game}}() : \mbox{\hyperlink{game_basics_8cpp_ab3ae3d2c20c90e75f1ad88ba88227bb7}{WININIT}} \{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00021}00021 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00022}00022     if(!reloadConfig())\{ \textcolor{comment}{// Config}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00023}00023         \textcolor{keywordflow}{throw} runtime\_error(\textcolor{stringliteral}{"{}Initial config loading failed. Please check the error above and fix the configuration"{}});}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00024}00024     \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00025}00025 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00026}00026     \textcolor{comment}{// Pixel Manager}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00027}00027     \textcolor{keywordflow}{if}(confData.theme==\textcolor{stringliteral}{"{}good"{}})\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00028}00028         pm = std::make\_unique<GoodPixelManager>(window);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00029}00029     \}\textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(confData.theme==\textcolor{stringliteral}{"{}bad"{}})\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00030}00030         pm = std::make\_unique<PixelManager>(window);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00031}00031     \}\textcolor{keywordflow}{else} \textcolor{keywordflow}{throw} runtime\_error(\textcolor{stringliteral}{"{}Invalid theme value : "{}}+confData.theme+}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00032}00032     \textcolor{stringliteral}{"{}\(\backslash\)nValid values are : good,bad"{}});}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00033}00033 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00034}00034     cout << \textcolor{stringliteral}{"{}Loading sprites..."{}} << endl;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00035}00035     vector<Task> tasks;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00036}00036     chrono::high\_resolution\_clock::time\_point start = chrono::high\_resolution\_clock::now();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00037}00037 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00038}00038     pm-\/>loadSprites(tasks);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00039}00039     \textcolor{keywordflow}{for}(\mbox{\hyperlink{utils_8h_a7a271d55f100974f7703690edbaca2e2}{Task}}\& f : tasks)f.wait();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00040}00040 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00041}00041     \textcolor{comment}{// We just do that for one sprite, so I didn't bother creating an 'API' for that}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00042}00042     pm-\/>leftHand.mirror(pm-\/>rightHand);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00043}00043 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00044}00044     chrono::high\_resolution\_clock::duration elapsed = chrono::high\_resolution\_clock::now()-\/start;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00045}00045     cout << \textcolor{stringliteral}{"{}Done ! Time : "{}} << chrono::duration\_cast<chrono::milliseconds>(elapsed).count() << \textcolor{stringliteral}{"{}ms"{}} << endl;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00046}00046 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00047}00047     sm.readFile(); \textcolor{comment}{// Score manager}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00048}00048 \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00049}00049 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00050}00050 \textcolor{keywordtype}{bool} Game::areThereInvadersLeft()\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00051}00051     \textcolor{keywordflow}{return} grid.\mbox{\hyperlink{class_invaders_grid_ad327fc6f3a003e65ff3c131698ca6982}{validColsNumber}}() > 0;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00052}00052 \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00053}00053 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00054}00054 \textcolor{keywordtype}{void} Game::handleScoreSaving()\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00055}00055     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{unsigned} i=0;i<players.size();++i)\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00056}00056         \textcolor{keywordtype}{string} pName;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00057}00057         pm-\/>askPlayerNameMenu(i, players[i].score, pName);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00058}00058         sm.\mbox{\hyperlink{class_scores_manager_aecc0c2cd11b529022e490634ac5927c2}{inputScore}}(move(pName), players[i].score);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00059}00059     \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00060}00060     sm.\mbox{\hyperlink{class_scores_manager_adf752264356a8ece07858c466c001d23}{writeFile}}();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00061}00061 \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00062}00062 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00063}\mbox{\hyperlink{class_game_a185d2ce9845c75b62064dc6d60f79eab}{00063}} \textcolor{keywordtype}{void} \mbox{\hyperlink{class_game_a185d2ce9845c75b62064dc6d60f79eab}{Game::managedGames}}() \{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00064}00064 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00065}00065     playMode = \mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34ab50339a10e1de285ac99d4c3990b8693}{PlayMode::NONE}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00066}00066     \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318de}{WinValue}} whoWon; }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00067}00067 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00068}00068     \textcolor{keywordflow}{while}(playMode!=\mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34aa42b2fb0e720a080e79a92f4ca97d927}{PlayMode::EXIT}})\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00069}00069         \textcolor{keywordflow}{if}(playMode==\mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34ab50339a10e1de285ac99d4c3990b8693}{PlayMode::NONE}})\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00070}00070             playMode = pm-\/>showInitialMenu();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00071}00071         \}\textcolor{keywordflow}{else}\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00072}00072             \mbox{\hyperlink{utils_8h_aa1bc11933ce4506010028d354b3364b4}{DEBUG\_MSG}}(\textcolor{stringliteral}{"{}Starting game"{}})}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00073}00073             \mbox{\hyperlink{class_game_ab684b380c7d3f3577e2fb80006415297}{initGame}}();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00074}00074             whoWon = \mbox{\hyperlink{class_game_a74570e2b1a4930b1ab1c957b5e60320e}{enterGameLoop}}(); \textcolor{comment}{// will read the playMode}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00075}00075             \mbox{\hyperlink{utils_8h_aa1bc11933ce4506010028d354b3364b4}{DEBUG\_MSG}}(\textcolor{stringliteral}{"{}END End of game"{}})}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00076}00076             handleScoreSaving();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00077}00077             \textcolor{keywordflow}{if}(!pm-\/>showDeathMenu(sm.\mbox{\hyperlink{class_scores_manager_a87042119c89a7af9f0ba05f724808956}{scores}}, whoWon))playMode = \mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34ab50339a10e1de285ac99d4c3990b8693}{PlayMode::NONE}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00078}00078         \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00079}00079     \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00080}00080 \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00081}00081 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00082}00082 \textcolor{comment}{// we assume the game has been played before, and so we need to clean used members}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00083}\mbox{\hyperlink{class_game_ab684b380c7d3f3577e2fb80006415297}{00083}} \textcolor{keywordtype}{void} \mbox{\hyperlink{class_game_ab684b380c7d3f3577e2fb80006415297}{Game::initGame}}()\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00084}00084     grid = confData.\mbox{\hyperlink{struct_config_data_a260272afae4d9a0cfdf683ce7b1bb5f0}{grid}}; \textcolor{comment}{// will copy the grid}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00085}00085 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00086}00086     \textcolor{comment}{// we re-\/construct players objects, we don't have to clear all members and can rely on the construction value (set in .h file)}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00087}00087     players.clear();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00088}00088 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00089}00089     missiles.clear();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00090}00090     god.\mbox{\hyperlink{class_god_aa509fa274d956215aa439de1c8e2e290}{state}} = \mbox{\hyperlink{god_8h_af1459ba6e17d6a2aef2bf5f4f56f6355ab50339a10e1de285ac99d4c3990b8693}{GodState::NONE}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00091}00091     torpedos.clear();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00092}00092 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00093}00093     \textcolor{keywordflow}{if}(playMode==\mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34a0679273e201afd0bf57af3961f8a23b8}{PlayMode::SINGLE}})\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00094}00094         players.resize(1);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00095}00095     \}\textcolor{keywordflow}{else}\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00096}00096         players.resize(2);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00097}00097         \textcolor{comment}{// mirror the start X Position for the other}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00098}00098         players[1].x = pm-\/>getScreenWidth() -\/ confData.\mbox{\hyperlink{struct_config_data_a002e3aaf06ba352a9ff4e2f50895a65f}{startXPosition}} -\/ confData.\mbox{\hyperlink{struct_config_data_ad8c5d2876699ea9e451e6b3a15618707}{playersWidth}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00099}00099     \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00100}00100     players[0].x = confData.\mbox{\hyperlink{struct_config_data_a002e3aaf06ba352a9ff4e2f50895a65f}{startXPosition}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00101}00101 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00102}00102     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{unsigned} i=0;i<players.size();++i)\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00103}00103         players[i].id = i;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00104}00104         players[i].lives = confData.\mbox{\hyperlink{struct_config_data_a09170415d0a4c525e546d6fd0ecb354c}{playersLives}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00105}00105     \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00106}00106 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00107}00107     baseInvPos = \mbox{\hyperlink{utils_8h_aaa06d516441b519f8892f37adafeade2}{Position}}(200, 0);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00108}00108     direction = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00109}00109 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00110}00110 \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00111}00111 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00112}\mbox{\hyperlink{game_basics_8cpp_aba14ffc4d97baf6395f7d4ff9757798b}{00112}} \textcolor{preprocessor}{\#define START\_TIMER() DEBUG\_INSTR(debugTime = chrono::high\_resolution\_clock::now())}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00113}\mbox{\hyperlink{game_basics_8cpp_a2f666d6c16c142851b1e1ab009f2c4b5}{00113}} \textcolor{preprocessor}{\#define PRINT\_TIMER(X) DEBUG\_MSG((X) << "{}: "{}} << chrono::duration\_cast<chrono::nanoseconds>(chrono::high\_resolution\_clock::now()-\/debugTime).count())}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00114}00114 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00115}\mbox{\hyperlink{class_game_a74570e2b1a4930b1ab1c957b5e60320e}{00115}} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318de}{WinValue}} \mbox{\hyperlink{class_game_a74570e2b1a4930b1ab1c957b5e60320e}{Game::enterGameLoop}}()\{ \textcolor{comment}{// returns when game is finished}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00116}00116     \textcolor{comment}{// computed in advance for performance reasons}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00117}00117     chrono::milliseconds maxFrameTime = chrono::milliseconds(1000/confData.\mbox{\hyperlink{struct_config_data_adb4b297d72ba060cbe54785d5791d6ea}{maxFPS}});}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00118}00118 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00119}00119     \textcolor{keywordtype}{unsigned} tmpFps = 0;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00120}00120     \textcolor{keywordtype}{unsigned} fps = 0;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00121}00121     \textcolor{keyword}{typedef} chrono::high\_resolution\_clock::time\_point MyTimePoint;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00122}00122     MyTimePoint fpsStartTime = \{\};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00123}00123 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00124}00124     \textcolor{keywordflow}{while}(window.isOpen())\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00125}00125 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00126}00126         MyTimePoint startTime = chrono::high\_resolution\_clock::now();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00127}00127         \textcolor{keywordflow}{if}(fpsStartTime.time\_since\_epoch()==chrono::seconds(0))\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00128}00128             fpsStartTime = startTime;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00129}00129         \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00130}00130 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00131}00131         pm-\/>startFrame();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00132}00132 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00133}00133         managePlayers();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00134}00134         \textcolor{keywordflow}{if}(manageInvaders()) \{ \textcolor{comment}{// if they went down}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00135}00135             \textcolor{keywordflow}{if} (invadersTouchPlayer())\textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318dea6c5e2f894ce45b3f0b6c6a9f35165354}{WinValue::INVADERS}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00136}00136             tryAwakeGod();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00137}00137         \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00138}00138 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00139}00139         \textcolor{keywordflow}{if}(manageGod())\textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318deae334ea4bb6fd38968f6809b091120ad8}{WinValue::PLAYERS}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00140}00140         \textcolor{keywordflow}{if}(\mbox{\hyperlink{class_game_aef8202b79983c3b0f8d6db6c01d17fa6}{arePlayersDead}}())\textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318dea0d28cba0bd4f26e16d766000d27e49fa}{WinValue::GOD}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00141}00141 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00142}00142         moveMissiles();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00143}00143         remCollidingProjectiles();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00144}00144         moveTorpedos();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00145}00145         remCollidingProjectiles();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00146}00146 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00147}00147         checkMissilesAndPlayers();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00148}00148         \textcolor{keywordflow}{if}(checkTorpedosAndInvaders())\textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318deae334ea4bb6fd38968f6809b091120ad8}{WinValue::PLAYERS}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00149}00149 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00150}00150         \textcolor{keywordflow}{if}(\mbox{\hyperlink{class_game_aef8202b79983c3b0f8d6db6c01d17fa6}{arePlayersDead}}())\textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318dea6c5e2f894ce45b3f0b6c6a9f35165354}{WinValue::INVADERS}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00151}00151 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00152}00152         displayAll(fps);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00153}00153 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00154}00154         pm-\/>endFrame();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00155}00155 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00156}00156         MyTimePoint endTime = chrono::high\_resolution\_clock::now();}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00157}00157 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00158}00158         \textcolor{comment}{// This code is counted as part of frames, but that's not really something we can control}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00159}00159         \textcolor{keywordflow}{if}(fpsStartTime+chrono::seconds(1) < endTime)\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00160}00160             fps = tmpFps;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00161}00161             tmpFps = 0;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00162}00162             fpsStartTime = \{\};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00163}00163         \}\textcolor{keywordflow}{else} ++tmpFps;}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00164}00164 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00165}00165         this\_thread::sleep\_until(startTime+maxFrameTime);}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00166}00166     \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00167}00167 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00168}00168     \textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318deab0a805cee749933cf3e707de70a80dbf}{WinValue::NOBODY}};}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00169}00169 \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00170}00170 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00171}00171 \mbox{\hyperlink{utils_8h_aaa06d516441b519f8892f37adafeade2}{Position}} Game::invIndexToPos(\textcolor{keywordtype}{unsigned} x, \textcolor{keywordtype}{unsigned} y)\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00172}00172     \textcolor{keywordflow}{return} baseInvPos + \mbox{\hyperlink{utils_8h_aaa06d516441b519f8892f37adafeade2}{Position}}(\mbox{\hyperlink{utils_8h_a0fbfb06f12128eab237cbb52f92a1d04}{INV\_GET\_SINGLE\_POS}}(x), \mbox{\hyperlink{utils_8h_a0fbfb06f12128eab237cbb52f92a1d04}{INV\_GET\_SINGLE\_POS}}(y));}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00173}00173 \}}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00174}00174 }
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00175}\mbox{\hyperlink{class_game_aef8202b79983c3b0f8d6db6c01d17fa6}{00175}} \textcolor{keywordtype}{bool} \mbox{\hyperlink{class_game_aef8202b79983c3b0f8d6db6c01d17fa6}{Game::arePlayersDead}}() \{}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00176}00176     \textcolor{keywordflow}{return} all\_of(players.begin(), players.end(), [](\mbox{\hyperlink{struct_player}{Player}}\& p) -\/> \textcolor{keywordtype}{bool} \{return p.isEliminated();\});}
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00177}00177 \}}

\end{DoxyCode}
