226 lines
31 KiB
TeX
226 lines
31 KiB
TeX
\hypertarget{game_managers_8cpp_source}{}\doxysection{game\+Managers.\+cpp}
|
|
\label{game_managers_8cpp_source}\index{src/game/gameManagers.cpp@{src/game/gameManagers.cpp}}
|
|
\mbox{\hyperlink{game_managers_8cpp}{Go to the documentation of this file.}}
|
|
\begin{DoxyCode}{0}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00001}00001 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00011}00011 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{game_8h}{game.h}}"{}}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00012}00012 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00013}\mbox{\hyperlink{game_managers_8cpp_a543c1a1b2d90a36ad8f512ae3107ce2a}{00013}} \textcolor{preprocessor}{\#define ISPRESSED(ID, X) window.isPressed(\{confData.playerDefs[ID].keys.X, false\})}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00014}00014 \textcolor{keywordtype}{void} Game::manageOnePlayer(\mbox{\hyperlink{utils_8h_a19f2f2312637b6ed67b6d24598b6f470}{playerID}} pID)\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00015}00015 \mbox{\hyperlink{struct_player}{Player}}\& p = players[pID];}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00016}00016 \textcolor{keywordflow}{if}(p.\mbox{\hyperlink{struct_player_a7aacef142ba14d6af7a6dfcb8ef327cd}{isEliminated}}())\textcolor{keywordflow}{return};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00017}00017 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00018}00018 \textcolor{keywordflow}{if} (\mbox{\hyperlink{game_managers_8cpp_a543c1a1b2d90a36ad8f512ae3107ce2a}{ISPRESSED}}(pID, left))\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00019}00019 \textcolor{keywordflow}{if}(p.\mbox{\hyperlink{struct_player_a9edbd6fa228cf532b7a74fb45721c2e0}{x}} < confData.\mbox{\hyperlink{struct_config_data_a199264aa6e6c3b267462f0a5427cd5db}{playersSpeed}}) p.\mbox{\hyperlink{struct_player_a9edbd6fa228cf532b7a74fb45721c2e0}{x}} = 0;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00020}00020 \textcolor{keywordflow}{else} p.\mbox{\hyperlink{struct_player_a9edbd6fa228cf532b7a74fb45721c2e0}{x}} -\/= confData.\mbox{\hyperlink{struct_config_data_a199264aa6e6c3b267462f0a5427cd5db}{playersSpeed}};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00021}00021 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00022}00022 \textcolor{keywordflow}{if} (\mbox{\hyperlink{game_managers_8cpp_a543c1a1b2d90a36ad8f512ae3107ce2a}{ISPRESSED}}(pID, right))\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00023}00023 \textcolor{keywordflow}{if}(p.\mbox{\hyperlink{struct_player_a9edbd6fa228cf532b7a74fb45721c2e0}{x}} + confData.\mbox{\hyperlink{struct_config_data_ad8c5d2876699ea9e451e6b3a15618707}{playersWidth}} + confData.\mbox{\hyperlink{struct_config_data_a199264aa6e6c3b267462f0a5427cd5db}{playersSpeed}} >= pm-\/>getScreenWidth()) p.\mbox{\hyperlink{struct_player_a9edbd6fa228cf532b7a74fb45721c2e0}{x}} = pm-\/>getScreenWidth() -\/ confData.\mbox{\hyperlink{struct_config_data_ad8c5d2876699ea9e451e6b3a15618707}{playersWidth}} -\/ 1;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00024}00024 \textcolor{keywordflow}{else} p.\mbox{\hyperlink{struct_player_a9edbd6fa228cf532b7a74fb45721c2e0}{x}} += confData.\mbox{\hyperlink{struct_config_data_a199264aa6e6c3b267462f0a5427cd5db}{playersSpeed}};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00025}00025 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00026}00026 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00027}00027 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00028}00028 \textcolor{keywordflow}{if}(p.\mbox{\hyperlink{struct_player_a45bd873fbf46cb105cb038b51251a812}{hasDeathAnimation}}()) \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00029}00029 ++p.\mbox{\hyperlink{struct_player_a3f6353c84662c57d74aafa770773c409}{deathAnimCounter}};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00030}00030 \textcolor{keywordflow}{if} (p.\mbox{\hyperlink{struct_player_a3f6353c84662c57d74aafa770773c409}{deathAnimCounter}} == 75) \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00031}00031 p.\mbox{\hyperlink{struct_player_a3f6353c84662c57d74aafa770773c409}{deathAnimCounter}} = 0;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00032}00032 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00033}00033 \}\textcolor{keywordflow}{else}\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00034}00034 \textcolor{keywordflow}{if}(p.\mbox{\hyperlink{struct_player_a7aacef142ba14d6af7a6dfcb8ef327cd}{isEliminated}}())\textcolor{keywordflow}{return};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00035}00035 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00036}00036 \textcolor{keywordflow}{if}(p.\mbox{\hyperlink{struct_player_a68ea5bd892a77c115baff824c526b3d2}{fireCooldown}}==0) \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00037}00037 \textcolor{keywordflow}{if} (\mbox{\hyperlink{game_managers_8cpp_a543c1a1b2d90a36ad8f512ae3107ce2a}{ISPRESSED}}(pID, shoot)) \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00038}00038 torpedos.emplace\_back(p.\mbox{\hyperlink{struct_player_a9edbd6fa228cf532b7a74fb45721c2e0}{x}} + confData.\mbox{\hyperlink{struct_config_data_ad8c5d2876699ea9e451e6b3a15618707}{playersWidth}} / 2, pm-\/>getScreenHeight() -\/ \mbox{\hyperlink{utils_8h_a2712b06fd52f25adca031d05c3e0c09b}{PLAYER\_HEIGHT}}, pID);}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00039}00039 p.\mbox{\hyperlink{struct_player_a68ea5bd892a77c115baff824c526b3d2}{fireCooldown}} = confData.\mbox{\hyperlink{struct_config_data_a641d7b2133165ce2eccaea972265f557}{playersFireCooldown}};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00040}00040 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00041}00041 \}\textcolor{keywordflow}{else} -\/-\/p.\mbox{\hyperlink{struct_player_a68ea5bd892a77c115baff824c526b3d2}{fireCooldown}};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00042}00042 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00043}00043 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00044}00044 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00045}00045 \textcolor{keywordtype}{void} Game::managePlayers()\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00046}00046 \textcolor{keywordflow}{for}(\textcolor{keywordtype}{unsigned} i=0;i<players.size();++i)manageOnePlayer(i);}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00047}00047 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00048}00048 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00049}00049 \textcolor{keywordtype}{bool} Game::manageInvaders()\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00050}00050 \textcolor{keywordflow}{if}(!areThereInvadersLeft())\textcolor{keywordflow}{return} \textcolor{keyword}{false}; \textcolor{comment}{// If there are no more invaders we don't need to manage them}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00051}00051 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00052}00052 \textcolor{comment}{// shoot}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00053}00053 \textcolor{keywordflow}{if}(fireCooldown==0) \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00054}00054 fireCooldown = confData.\mbox{\hyperlink{struct_config_data_a0a8ca410dbc6b6cd62d16d1fa19a83f9}{invadersFireCooldown}} + rand() \% 25;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00055}00055 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00056}00056 \textcolor{keywordtype}{unsigned} rdCol = grid.\mbox{\hyperlink{class_invaders_grid_ac184c30c8a60fdbe8abed9b9455d35d2}{randomValidCol}}();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00057}00057 \textcolor{comment}{// fire !}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00058}00058 missiles.push\_back(basePos + \mbox{\hyperlink{utils_8h_aaa06d516441b519f8892f37adafeade2}{Position}}(}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00059}00059 confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}} * rdCol + confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}} * (rdCol + 0.5),}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00060}00060 confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}} * (grid[rdCol].size() -\/ 1) + confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}} * (grid[rdCol].size() -\/ 1)}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00061}00061 ));}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00062}00062 \}\textcolor{keywordflow}{else} -\/-\/fireCooldown;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00063}00063 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00064}00064 \textcolor{comment}{// moving}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00065}00065 \textcolor{comment}{// TODO fix this lol}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00066}00066 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00067}00067 \textcolor{keywordflow}{if}(direction)\{ \textcolor{comment}{// go to the right}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00068}00068 \textcolor{keywordtype}{int} end = basePos.getX(); \textcolor{comment}{// start Position}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00069}00069 end+= grid.size() * confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}}; \textcolor{comment}{// add the invaders}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00070}00070 end+= (grid.size()-\/1) * confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}}; \textcolor{comment}{// add the invadersDistance between invaders}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00071}00071 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00072}00072 \textcolor{comment}{// you got the end position of the invader crowd !}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00073}00073 \textcolor{keywordtype}{unsigned} relativeScreenWidth = pm-\/>getScreenWidth();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00074}00074 \textcolor{keywordtype}{size\_t} i = grid.size()-\/1;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00075}00075 \textcolor{keywordflow}{while} (grid[i].hasNoValid())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00076}00076 relativeScreenWidth += confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}} + confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00077}00077 -\/-\/i;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00078}00078 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00079}00079 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00080}00080 \textcolor{keywordflow}{if}(end + confData.\mbox{\hyperlink{struct_config_data_ad057123e1f1b7283b873eed8a07ead3f}{invadersSpeed}} < relativeScreenWidth)\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00081}00081 basePos.setX(basePos.getX() + confData.\mbox{\hyperlink{struct_config_data_ad057123e1f1b7283b873eed8a07ead3f}{invadersSpeed}});}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00082}00082 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00083}00083 \textcolor{keywordflow}{else}\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00084}00084 basePos.setY(basePos.getY() + confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}} + confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}});}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00085}00085 direction = !direction;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00086}00086 \textcolor{keywordflow}{return} \textcolor{keyword}{true};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00087}00087 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00088}00088 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00089}00089 \textcolor{keywordflow}{else}\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00090}00090 \textcolor{keywordtype}{size\_t} i = 0;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00091}00091 \textcolor{keywordtype}{unsigned} relativeBasePos = basePos.getX();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00092}00092 \textcolor{keywordflow}{while} (grid[i].hasNoValid())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00093}00093 relativeBasePos += confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}} + confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00094}00094 ++i;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00095}00095 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00096}00096 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00097}00097 \textcolor{keywordflow}{if}(relativeBasePos >= confData.\mbox{\hyperlink{struct_config_data_ad057123e1f1b7283b873eed8a07ead3f}{invadersSpeed}})\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00098}00098 basePos.setX(basePos.getX() -\/ confData.\mbox{\hyperlink{struct_config_data_ad057123e1f1b7283b873eed8a07ead3f}{invadersSpeed}});}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00099}00099 \}\textcolor{keywordflow}{else}\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00100}00100 basePos.setY(basePos.getY() + confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}} + confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}});}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00101}00101 direction = !direction;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00102}00102 \textcolor{keywordflow}{return} \textcolor{keyword}{true};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00103}00103 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00104}00104 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00105}00105 \textcolor{keywordflow}{return} \textcolor{keyword}{false};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00106}00106 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00107}00107 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00108}00108 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00109}00109 \textcolor{keywordtype}{void} Game::remCollidingProjectiles()\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00110}00110 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00111}00111 \textcolor{keyword}{auto} miss = missiles.begin();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00112}00112 \textcolor{keyword}{auto} tor = torpedos.begin();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00113}00113 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00114}00114 \textcolor{keywordflow}{while}(miss != missiles.end())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00115}00115 \textcolor{keywordtype}{bool} wasColliding = \textcolor{keyword}{false};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00116}00116 \textcolor{keywordflow}{while}(tor != torpedos.end())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00117}00117 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00118}00118 \textcolor{comment}{// missiles can't be right under torpedos, so that must means they are colliding in Y}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00119}00119 \textcolor{keywordflow}{if}(miss-\/>getY() + confData.\mbox{\hyperlink{struct_config_data_ae736dc72056f45f4a3f0fef365bc54be}{missilesLength}} < tor-\/>getY())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00120}00120 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00121}00121 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00122}00122 \textcolor{keywordflow}{if}(\mbox{\hyperlink{utils_8h_a8d01e61a45fe7072e45f22044013e358}{areLinesColliding}}( \textcolor{comment}{// now check if they collide in X}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00123}00123 miss-\/>getX(), miss-\/>getX() + confData.\mbox{\hyperlink{struct_config_data_a4f8e7615d2619a3b37e97465ac143fee}{missilesWidth}},}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00124}00124 tor-\/>getX(), tor-\/>getX() + confData.\mbox{\hyperlink{struct_config_data_aec2b163d49271a1a1654c903de9e45ff}{torpedosWidth}}))\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00125}00125 missiles.erase(miss);}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00126}00126 torpedos.erase(tor);}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00127}00127 wasColliding = \textcolor{keyword}{true};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00128}00128 \textcolor{keywordflow}{break};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00129}00129 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00130}00130 ++tor;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00131}00131 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00132}00132 \textcolor{comment}{/* if it was colling, it was removed and his Position is now replaced by the next.}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00133}00133 \textcolor{comment}{ * else, go to the next */}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00134}00134 \textcolor{keywordflow}{if}(!wasColliding)++miss;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00135}00135 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00136}00136 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00137}00137 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00138}00138 \textcolor{keywordtype}{void} Game::moveMissiles() \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00139}00139 \textcolor{keyword}{auto} miss = missiles.begin();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00140}00140 \textcolor{keywordflow}{while} (miss != missiles.end()) \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00141}00141 \textcolor{keywordflow}{if} (miss-\/>getY() >= pm-\/>getScreenHeight())missiles.erase(miss);}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00142}00142 \textcolor{keywordflow}{else} \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00143}00143 miss-\/>setY(miss-\/>getY()+confData.\mbox{\hyperlink{struct_config_data_ae5efc1b5a2b95b1a9c7ff60eee480e71}{missilesSpeed}});}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00144}00144 ++miss;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00145}00145 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00146}00146 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00147}00147 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00148}00148 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00149}00149 \textcolor{keywordtype}{void} Game::moveTorpedos() \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00150}00150 \textcolor{keyword}{auto} tor = torpedos.begin();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00151}00151 \textcolor{keywordflow}{while} (tor != torpedos.end()) \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00152}00152 \textcolor{keywordflow}{if} (tor-\/>getY()+confData.\mbox{\hyperlink{struct_config_data_a5de633401856c45fb3b8c3333d38804c}{torpedosLength}} <= 0)torpedos.erase(tor);}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00153}00153 \textcolor{keywordflow}{else}\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00154}00154 tor-\/>setY(tor-\/>getY()-\/confData.\mbox{\hyperlink{struct_config_data_aa491de435feeca58c85652f4961ddece}{torpedosSpeed}});}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00155}00155 ++tor;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00156}00156 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00157}00157 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00158}00158 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00159}00159 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00160}00160 \textcolor{keywordtype}{void} Game::checkMissilesAndPlayers() \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00161}00161 \textcolor{keyword}{auto} miss\_ite = missiles.begin();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00162}00162 \textcolor{keywordflow}{while}(miss\_ite!=missiles.end())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00163}00163 \textcolor{keywordtype}{bool} wasColliding = \textcolor{keyword}{false};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00164}00164 \textcolor{keywordflow}{if}(miss\_ite-\/>getY()>=pm-\/>getScreenHeight()-\/\mbox{\hyperlink{utils_8h_a2712b06fd52f25adca031d05c3e0c09b}{PLAYER\_HEIGHT}})\{ \textcolor{comment}{// check collision on Y}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00165}00165 \textcolor{comment}{// now check collision on X (with both players)}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00166}00166 \textcolor{keywordflow}{for}(\mbox{\hyperlink{struct_player}{Player}}\& p : players)\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00167}00167 \textcolor{keywordflow}{if}(p.isPlaying())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00168}00168 \textcolor{keywordflow}{if}(\mbox{\hyperlink{utils_8h_a8d01e61a45fe7072e45f22044013e358}{areLinesColliding}}(}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00169}00169 miss\_ite-\/>getX(), miss\_ite-\/>getX() + confData.\mbox{\hyperlink{struct_config_data_a4f8e7615d2619a3b37e97465ac143fee}{missilesWidth}},}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00170}00170 p.x, p.x + confData.\mbox{\hyperlink{struct_config_data_ad8c5d2876699ea9e451e6b3a15618707}{playersWidth}}))\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00171}00171 wasColliding = \textcolor{keyword}{true};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00172}00172 p.damage();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00173}00173 \textcolor{comment}{// do not break, the second player also deserves to be hit}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00174}00174 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00175}00175 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00176}00176 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00177}00177 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00178}00178 \textcolor{keywordflow}{if}(wasColliding)missiles.erase(miss\_ite);}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00179}00179 \textcolor{keywordflow}{else} ++miss\_ite;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00180}00180 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00181}00181 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00182}00182 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00183}00183 \textcolor{keywordtype}{bool} Game::checkTorpedosAndInvaders() \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00184}00184 \textcolor{keyword}{auto} tor\_ite = torpedos.begin();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00185}00185 \textcolor{keywordflow}{while}(tor\_ite!=torpedos.end())\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00186}00186 \textcolor{keywordtype}{unsigned} i=0;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00187}00187 \textcolor{keywordflow}{for}(;i<grid.size();++i)\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00188}00188 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00189}00189 \textcolor{keywordtype}{unsigned} alienIndex = grid[i].getOutterInvader();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00190}00190 \textcolor{keywordflow}{if}(alienIndex==grid[i].size())\textcolor{keywordflow}{continue};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00191}00191 \textcolor{comment}{// calculate top-\/left Position of invader}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00192}00192 \mbox{\hyperlink{utils_8h_aaa06d516441b519f8892f37adafeade2}{Position}} pos = basePos + \mbox{\hyperlink{utils_8h_aaa06d516441b519f8892f37adafeade2}{Position}}(}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00193}00193 confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}}*i+confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}}*i,}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00194}00194 confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}}*alienIndex+confData.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}}*alienIndex}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00195}00195 );}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00196}00196 \textcolor{comment}{// check collision on Y (invaders can actually be "{}under"{} torpedos, so we check both lower and upper bounds}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00197}00197 \textcolor{keywordflow}{if}(pos.getY()+confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}}>=tor\_ite-\/>getY() \&\&}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00198}00198 pos.getY()<=tor\_ite-\/>getY()+confData.\mbox{\hyperlink{struct_config_data_a5de633401856c45fb3b8c3333d38804c}{torpedosLength}})\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00199}00199 \textcolor{comment}{// now check collision on X}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00200}00200 \textcolor{keywordflow}{if}(\mbox{\hyperlink{utils_8h_a8d01e61a45fe7072e45f22044013e358}{areLinesColliding}}( \textcolor{comment}{// now check collision on X}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00201}00201 tor\_ite-\/>getX(), tor\_ite-\/>getX() + confData.\mbox{\hyperlink{struct_config_data_aec2b163d49271a1a1654c903de9e45ff}{torpedosWidth}},}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00202}00202 pos.getX(), pos.getX() + confData.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}}))\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00203}00203 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00204}00204 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00205}00205 \mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018}{InvaderType}} invType = grid[i][alienIndex];}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00206}00206 players[tor\_ite-\/>owner].score += confData.\mbox{\hyperlink{struct_config_data_af0c88560ab28fe51ef1743219633cfdc}{invadersDef}}.at(invType).points;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00207}00207 torpedos.erase(tor\_ite);}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00208}00208 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00209}00209 grid[i][alienIndex] = \mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018ab50339a10e1de285ac99d4c3990b8693}{InvaderType::NONE}};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00210}00210 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00211}00211 \textcolor{keywordflow}{if}(!areThereInvadersLeft()) \textcolor{keywordflow}{return} \textcolor{keyword}{true};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00212}00212 \textcolor{keywordflow}{break};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00213}00213 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00214}00214 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00215}00215 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00216}00216 \textcolor{keywordflow}{if}(i==grid.size()) ++tor\_ite;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00217}00217 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00218}00218 \textcolor{keywordflow}{return} \textcolor{keyword}{false};}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00219}00219 \}}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00220}00220 }
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00221}00221 \textcolor{keywordtype}{bool} Game::invadersTouchPlayer()\textcolor{keyword}{ const }\{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00222}00222 \textcolor{keywordflow}{return} any\_of(grid.begin(), grid.end(), [\textcolor{keyword}{this}](\textcolor{keyword}{const} \mbox{\hyperlink{class_invaders_column}{InvadersColumn}}\& line) -\/> \textcolor{keywordtype}{bool} \{}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00223}00223 unsigned outter = line.getOutterInvader();}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00224}00224 return this-\/>basePos.getY()+confData.invadersSize*(outter+1)}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00225}00225 +confData.invadersDistance*outter}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00226}00226 >= pm-\/>getScreenHeight() -\/ PLAYER\_HEIGHT;}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00227}00227 \});}
|
|
\DoxyCodeLine{\Hypertarget{game_managers_8cpp_source_l00228}00228 \}}
|
|
|
|
\end{DoxyCode}
|