Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void TWorld::ProcessShips() {
- QVector<TShip> newShips;
- newShips.reserve(Ships.size());
- for (size_t i = 0; i < (size_t)Ships.size(); ++i) {
- TShip& ship = Ships[i];
- QPointF v1 = Rule1(i);
- QPointF v2 = Rule2(i);
- QPointF v3 = Rule3(i);
- QPointF v4 = Rule4(i);
- QPointF v5 = Rule5(i);
- ship.Speed = ship.Speed + v1 + v2 + v3 + v4 + v5;
- LimitSpeed(ship.Speed);
- ship.Position += ship.Speed;
- if (!ProcessCollision(ship) &&
- ship.Position.x() >= 0 && ship.Position.x() < WORLD_WIDTH &&
- ship.Position.y() >= 0 && ship.Position.y() < WORLD_HEIGHT)
- {
- newShips.push_back(ship);
- }
- }
- Ships.swap(newShips);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement