175 lines
22 KiB
TeX
175 lines
22 KiB
TeX
\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 <memory>}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00014}00014 \textcolor{preprocessor}{\#include <thread>}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00015}00015 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{game_8h}{game.h}}"{}}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00016}00016 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{play_mode_8h}{playMode.h}}"{}}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00017}00017 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{good_pixel_manager_8h}{pixelManager/goodPixelManager.h}}"{}}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00018}00018 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00019}\mbox{\hyperlink{game_basics_8cpp_ab3ae3d2c20c90e75f1ad88ba88227bb7}{00019}} \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_l00020}00020 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00021}\mbox{\hyperlink{class_game_ad59df6562a58a614fda24622d3715b65}{00021}} \mbox{\hyperlink{class_game_ad59df6562a58a614fda24622d3715b65}{Game::Game}}() : \mbox{\hyperlink{game_basics_8cpp_ab3ae3d2c20c90e75f1ad88ba88227bb7}{WININIT}} \{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00022}00022 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00023}00023 if(!reloadConfig())\{ \textcolor{comment}{// Config}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00024}00024 \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_l00025}00025 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00026}00026 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00027}00027 \textcolor{comment}{// Pixel Manager}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00028}00028 \textcolor{keywordflow}{if}(confData.theme==\textcolor{stringliteral}{"{}good"{}})\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00029}00029 pm = std::make\_unique<GoodPixelManager>(window);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00030}00030 \}\textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(confData.theme==\textcolor{stringliteral}{"{}bad"{}})\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00031}00031 pm = std::make\_unique<PixelManager>(window);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00032}00032 \}\textcolor{keywordflow}{else} \textcolor{keywordflow}{throw} runtime\_error(\textcolor{stringliteral}{"{}Invalid theme value : "{}}+confData.theme+}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00033}00033 \textcolor{stringliteral}{"{}\(\backslash\)nValid values are : good,bad"{}});}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00034}00034 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00035}00035 cout << \textcolor{stringliteral}{"{}Loading sprites..."{}} << endl;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00036}00036 vector<Task> tasks;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00037}00037 chrono::high\_resolution\_clock::time\_point start = chrono::high\_resolution\_clock::now();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00038}00038 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00039}00039 pm-\/>loadSprites(tasks);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00040}00040 \textcolor{keywordflow}{for}(future<void>\& f : tasks)f.wait();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00041}00041 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00042}00042 \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_l00043}00043 pm-\/>leftHand.mirror(pm-\/>rightHand);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00044}00044 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00045}00045 chrono::high\_resolution\_clock::duration elapsed = chrono::high\_resolution\_clock::now()-\/start;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00046}00046 cout << \textcolor{stringliteral}{"{}Done ! Time : "{}} << chrono::duration\_cast<chrono::milliseconds>(elapsed).count() << \textcolor{stringliteral}{"{}ms"{}} << endl;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00047}00047 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00048}00048 sm.readFile(); \textcolor{comment}{// Score manager}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00049}00049 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00050}00050 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00051}00051 \textcolor{keywordtype}{bool} Game::areThereInvadersLeft()\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00052}00052 \textcolor{keywordflow}{return} grid.\mbox{\hyperlink{class_invaders_grid_ad327fc6f3a003e65ff3c131698ca6982}{validColsNumber}}() > 0;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00053}00053 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00054}00054 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00055}00055 \textcolor{keywordtype}{void} Game::handleScoreSaving()\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00056}00056 \textcolor{keywordflow}{for}(\textcolor{keywordtype}{unsigned} i=0;i<players.size();++i)\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00057}00057 \textcolor{keywordtype}{string} pName;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00058}00058 pm-\/>askPlayerNameMenu(i, players[i].score, pName);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00059}00059 sm.\mbox{\hyperlink{class_scores_manager_aecc0c2cd11b529022e490634ac5927c2}{inputScore}}(move(pName), players[i].score);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00060}00060 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00061}00061 sm.\mbox{\hyperlink{class_scores_manager_adf752264356a8ece07858c466c001d23}{writeFile}}();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00062}00062 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00063}00063 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00064}\mbox{\hyperlink{class_game_a185d2ce9845c75b62064dc6d60f79eab}{00064}} \textcolor{keywordtype}{void} \mbox{\hyperlink{class_game_a185d2ce9845c75b62064dc6d60f79eab}{Game::managedGames}}() \{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00065}00065 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00066}00066 playMode = \mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34ab50339a10e1de285ac99d4c3990b8693}{PlayMode::NONE}};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00067}00067 \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318de}{WinValue}} whoWon; }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00068}00068 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00069}00069 \textcolor{keywordflow}{while}(playMode!=\mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34aa42b2fb0e720a080e79a92f4ca97d927}{PlayMode::EXIT}})\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00070}00070 \textcolor{keywordflow}{if}(playMode==\mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34ab50339a10e1de285ac99d4c3990b8693}{PlayMode::NONE}})\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00071}00071 playMode = pm-\/>showInitialMenu();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00072}00072 \}\textcolor{keywordflow}{else}\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00073}00073 \mbox{\hyperlink{utils_8h_aa1bc11933ce4506010028d354b3364b4}{DEBUG\_MSG}}(\textcolor{stringliteral}{"{}Starting game"{}})}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00074}00074 initGame();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00075}00075 whoWon = \mbox{\hyperlink{class_game_a74570e2b1a4930b1ab1c957b5e60320e}{enterGameLoop}}(); \textcolor{comment}{// will read the playMode}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00076}00076 \mbox{\hyperlink{utils_8h_aa1bc11933ce4506010028d354b3364b4}{DEBUG\_MSG}}(\textcolor{stringliteral}{"{}END End of game"{}})}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00077}00077 handleScoreSaving();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00078}00078 \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_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 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00083}00083 \textcolor{comment}{// we assume the game has been played before, and so we need to clean used members}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00084}00084 \textcolor{keywordtype}{void} Game::initGame()\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00085}00085 grid = confData.\mbox{\hyperlink{struct_config_data_a260272afae4d9a0cfdf683ce7b1bb5f0}{grid}}; \textcolor{comment}{// will copy the grid}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00086}00086 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00087}00087 \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_l00088}00088 players.clear();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00089}00089 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00090}00090 missiles.clear();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00091}00091 god.\mbox{\hyperlink{class_god_aa509fa274d956215aa439de1c8e2e290}{state}} = \mbox{\hyperlink{god_8h_af1459ba6e17d6a2aef2bf5f4f56f6355ab50339a10e1de285ac99d4c3990b8693}{GodState::NONE}};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00092}00092 torpedos.clear();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00093}00093 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00094}00094 \textcolor{keywordflow}{if}(playMode==\mbox{\hyperlink{play_mode_8h_a188092ed559d356ade9a517d60ec3f34a0679273e201afd0bf57af3961f8a23b8}{PlayMode::SINGLE}})\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00095}00095 players.resize(1);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00096}00096 \}\textcolor{keywordflow}{else}\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00097}00097 players.resize(2);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00098}00098 \textcolor{comment}{// mirror the start X Position for the other}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00099}00099 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_l00100}00100 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00101}00101 players[0].x = confData.\mbox{\hyperlink{struct_config_data_a002e3aaf06ba352a9ff4e2f50895a65f}{startXPosition}};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00102}00102 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00103}00103 \textcolor{keywordflow}{for}(\textcolor{keywordtype}{unsigned} i=0;i<players.size();++i)\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00104}00104 players[i].id = i;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00105}00105 players[i].lives = confData.\mbox{\hyperlink{struct_config_data_a09170415d0a4c525e546d6fd0ecb354c}{playersLives}};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00106}00106 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00107}00107 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00108}00108 basePos = \mbox{\hyperlink{utils_8h_aaa06d516441b519f8892f37adafeade2}{Position}}(200, 0);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00109}00109 direction = \textcolor{keyword}{true};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00110}00110 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00111}00111 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00112}00112 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00113}\mbox{\hyperlink{game_basics_8cpp_aba14ffc4d97baf6395f7d4ff9757798b}{00113}} \textcolor{preprocessor}{\#define START\_TIMER() DEBUG\_INSTR(debugTime = chrono::high\_resolution\_clock::now())}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00114}\mbox{\hyperlink{game_basics_8cpp_a2f666d6c16c142851b1e1ab009f2c4b5}{00114}} \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_l00115}00115 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00116}\mbox{\hyperlink{class_game_a74570e2b1a4930b1ab1c957b5e60320e}{00116}} \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_l00117}00117 \textcolor{comment}{// computed in advance for performance reasons}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00118}00118 chrono::milliseconds maxFrameTime = chrono::milliseconds(1000/confData.\mbox{\hyperlink{struct_config_data_adb4b297d72ba060cbe54785d5791d6ea}{maxFPS}});}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00119}00119 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00120}00120 \textcolor{keywordtype}{unsigned} tmpFps = 0;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00121}00121 \textcolor{keywordtype}{unsigned} fps = 0;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00122}00122 \textcolor{keyword}{typedef} chrono::high\_resolution\_clock::time\_point MyTimePoint;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00123}00123 MyTimePoint fpsStartTime = \{\};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00124}00124 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00125}00125 \textcolor{keywordflow}{while}(window.isOpen())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00126}00126 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00127}00127 MyTimePoint startTime = chrono::high\_resolution\_clock::now();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00128}00128 \textcolor{keywordflow}{if}(fpsStartTime.time\_since\_epoch()==chrono::seconds(0))\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00129}00129 fpsStartTime = startTime;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00130}00130 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00131}00131 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00132}00132 pm-\/>startFrame();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00133}00133 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00134}00134 managePlayers();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00135}00135 \textcolor{keywordflow}{if}(manageInvaders()) \{ \textcolor{comment}{// if they went down}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00136}00136 \textcolor{keywordflow}{if} (invadersTouchPlayer())\textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318dea6c5e2f894ce45b3f0b6c6a9f35165354}{WinValue::INVADERS}};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00137}00137 tryAwakeGod();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00138}00138 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00139}00139 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00140}00140 \textcolor{keywordflow}{if}(manageGod())\textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318deae334ea4bb6fd38968f6809b091120ad8}{WinValue::PLAYERS}};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00141}00141 \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_l00142}00142 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00143}00143 moveMissiles();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00144}00144 remCollidingProjectiles();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00145}00145 moveTorpedos();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00146}00146 remCollidingProjectiles();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00147}00147 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00148}00148 checkMissilesAndPlayers();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00149}00149 \textcolor{keywordflow}{if}(checkTorpedosAndInvaders())\textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318deae334ea4bb6fd38968f6809b091120ad8}{WinValue::PLAYERS}};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00150}00150 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00151}00151 \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_l00152}00152 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00153}00153 displayAll(fps);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00154}00154 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00155}00155 pm-\/>endFrame();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00156}00156 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00157}00157 MyTimePoint endTime = chrono::high\_resolution\_clock::now();}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00158}00158 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00159}00159 \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_l00160}00160 \textcolor{keywordflow}{if}(fpsStartTime+chrono::seconds(1) < endTime)\{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00161}00161 fps = tmpFps;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00162}00162 tmpFps = 0;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00163}00163 fpsStartTime = \{\};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00164}00164 \}\textcolor{keywordflow}{else} ++tmpFps;}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00165}00165 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00166}00166 this\_thread::sleep\_until(startTime+maxFrameTime);}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00167}00167 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00168}00168 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00169}00169 \textcolor{keywordflow}{return} \mbox{\hyperlink{utils_8h_acd2eabcda2cfc7902077f1f9a9e318deab0a805cee749933cf3e707de70a80dbf}{WinValue::NOBODY}};}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00170}00170 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00171}00171 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00172}00172 \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_l00173}00173 \textcolor{keywordflow}{return} basePos+\mbox{\hyperlink{utils_8h_aaa06d516441b519f8892f37adafeade2}{Position}}(\mbox{\hyperlink{utils_8h_a815cc3532f834befd1c85e0e8d3bc9f7}{INV\_GET\_POS}}(x), \mbox{\hyperlink{utils_8h_a815cc3532f834befd1c85e0e8d3bc9f7}{INV\_GET\_POS}}(y));}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00174}00174 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00175}00175 }
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00176}\mbox{\hyperlink{class_game_aef8202b79983c3b0f8d6db6c01d17fa6}{00176}} \textcolor{keywordtype}{bool} \mbox{\hyperlink{class_game_aef8202b79983c3b0f8d6db6c01d17fa6}{Game::arePlayersDead}}() \{}
|
|
\DoxyCodeLine{\Hypertarget{game_basics_8cpp_source_l00177}00177 \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_l00178}00178 \}}
|
|
|
|
\end{DoxyCode}
|