| 1235 | } |
| 1236 | |
| 1237 | void PlayLayer::checkCollisions(PlayerObject* player, float dt) |
| 1238 | { |
| 1239 | auto playerOuterBounds = player->_mini ? player->getOuterBounds(0.6f, 0.6f) : player->getOuterBounds(); |
| 1240 | if (player->getPositionY() < (player->_mini ? 99.f : 105.0f) && player->_currentGamemode == PlayerGamemodeCube) |
| 1241 | { |
| 1242 | if (player->isGravityFlipped()) |
| 1243 | { |
| 1244 | this->destroyPlayer(player); |
| 1245 | return; |
| 1246 | } |
| 1247 | |
| 1248 | player->setPositionY((player->_mini ? 99.f : 105.0f)); |
| 1249 | |
| 1250 | player->hitGround(false); |
| 1251 | } |
| 1252 | |
| 1253 | else if (player->getPositionY() > 1290.0f) |
| 1254 | { |
| 1255 | this->destroyPlayer(player); |
| 1256 | return; |
| 1257 | } |
| 1258 | |
| 1259 | if (player->_currentGamemode != PlayerGamemodeCube) |
| 1260 | { |
| 1261 | if (player->getPositionY() < |
| 1262 | _bottomGround->getPositionY() + cameraFollow->getPositionY() + (player->_mini ? 87.f : 93.0f)) |
| 1263 | { |
| 1264 | player->setPositionY(_bottomGround->getPositionY() + cameraFollow->getPositionY() + |
| 1265 | (player->_mini ? 87.f : 93.0f)); |
| 1266 | |
| 1267 | if (!player->isGravityFlipped()) |
| 1268 | player->hitGround(false); |
| 1269 | |
| 1270 | player->setYVel(0.f); |
| 1271 | } |
| 1272 | if (player->getPositionY() > |
| 1273 | _ceiling->getPositionY() - (player->_mini ? 234.f : 240.f) + m_fCameraYCenter - 12.f) |
| 1274 | { |
| 1275 | player->setPositionY(_ceiling->getPositionY() - (player->_mini ? 234.f : 240.f) + m_fCameraYCenter - 12.f); |
| 1276 | |
| 1277 | if (player->isGravityFlipped()) |
| 1278 | player->hitGround(true); |
| 1279 | |
| 1280 | player->setYVel(0.f); |
| 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | dn->setVisible(showDn); |
| 1285 | |
| 1286 | if (showDn) |
| 1287 | { |
| 1288 | dn->clear(); |
| 1289 | renderRect(playerOuterBounds, ax::Color4B::RED); |
| 1290 | renderRect(player->getInnerBounds(), ax::Color4B::GREEN); |
| 1291 | } |
| 1292 | |
| 1293 | int current_section = this->sectionForPos(player->getPositionX()); |
| 1294 |
no test coverage detected