void KeyHandlesSheet::UpdateSelectionFrame() { if (mIsFrameSelecting) return; if (mSelectedHandles.Count() > 1) { mSelectionFrame->enabled = true; mSelectionRect.left = mSelectedHandles.First()->GetPosition().x; mSelectionRect.bottom = mTree->GetLineNumber(mSelectedHandles.First()->GetScreenPosition().y); mSelectionRect.right = mSelectionRect.left; mSelectionRect.top = mSelectionRect.bottom; for (auto handle : mSelectedHandles) { float localPos = handle->GetPosition().x; float lineNumber = mTree->GetLineNumber(handle->GetScreenPosition().y); mSelectionRect.left = Math::Min(mSelectionRect.left, localPos); mSelectionRect.right = Math::Max(mSelectionRect.right, localPos); mSelectionRect.bottom = Math::Max(mSelectionRect.bottom, Math::Ceil(lineNumber)); mSelectionRect.top = Math::Min(mSelectionRect.top, Math::Floor(lineNumber - 0.5f)); } mCenterFrameDragHandle.position = mSelectionRect.Center(); mLeftFrameDragHandle.position = Vec2F(mSelectionRect.left, mSelectionRect.Center().y); mRightFrameDragHandle.position = Vec2F(mSelectionRect.right, mSelectionRect.Center().y); } else mSelectionFrame->enabled = false; }
void EditorApplication::OnResizing() { mBackground->SetSize(o2Render.GetResolution() + Vec2F(20, 20)); mBackSign->position = (Vec2F)(o2Render.GetResolution()).InvertedX()*0.5f + Vec2F(40.0f, -85.0f); mConfig->OnWindowChange(); mUIRoot->OnApplicationSized(); }
WidgetLayout WidgetLayout::BothStretch(float borderLeft, float borderBottom, float borderRight, float borderTop) { WidgetLayout res; res.mData->anchorMin = Vec2F(0, 0); res.mData->anchorMax = Vec2F(1, 1); res.mData->offsetMin = Vec2F(borderLeft, borderBottom); res.mData->offsetMax = Vec2F(-borderRight, -borderTop); return res; }
void SolarSystem::spawnGroup(Vec2F pos, int groupSize, PlaySpace *Space) { const float SPRAY_FACTOR = 150.f; Ship* leader = NULL; for(int i = 0; i < groupSize; ++i) { Ship* ship = spawnShip(pos + gRNG.getVec2(-Vec2F(SPRAY_FACTOR, SPRAY_FACTOR), Vec2F(SPRAY_FACTOR, SPRAY_FACTOR)), Space); } }
void KeyHandlesSheet::OnCursorStillDown(const Input::Cursor& cursor) { if (cursor.isPressed) { if (!mIsFrameSelecting) { if (cursor.delta != Vec2F()) mIsFrameSelecting = true; } if (mIsFrameSelecting) { mSelectionFrame->enabled = true; Vec2F current(mTimeline->WorldToLocal(cursor.position.x), mTree->GetLineNumber(cursor.position.y)); mSelectionRect.left = Math::Min(mBeginSelectPoint.x, current.x); mSelectionRect.right = Math::Max(mBeginSelectPoint.x, current.x); mSelectionRect.top = Math::Floor(Math::Min(mBeginSelectPoint.y, current.y)); mSelectionRect.bottom = Math::Ceil(Math::Max(mBeginSelectPoint.y, current.y)); DeselectAll(); for (auto handle : mBeginSelectHandles) SelectHandle(handle); for (auto handle : mHandles) { Vec2F handlePos(handle->GetPosition().x, mTree->GetLineNumber(handle->GetScreenPosition().y)); if (handlePos.x > mSelectionRect.left && handlePos.x < mSelectionRect.right && handlePos.y > mSelectionRect.top && handlePos.y < mSelectionRect.bottom + 0.5f) { SelectHandle(handle); } } } } }
void FrameScrollView::OnVerScrollScrolled(float value) { float min = mVerScrollbar->GetMinValue(); float max = mVerScrollbar->GetMaxValue(); float invertedValue = min + (max - min - (value - min)); mViewCamera.SetPosition(Vec2F(mViewCamera.GetPosition().x, invertedValue)); mViewCameraTargetPos = mViewCamera.GetPosition(); mNeedRedraw = true; }
void KeyHandlesSheet::InitializeRightHandle() { mRightFrameDragHandle.localToScreenTransformFunc = [&](const Vec2F& point) { return Vec2F(mTimeline->LocalToWorld(point.x), mTree->GetLineWorldPosition(point.y)); }; mRightFrameDragHandle.screenToLocalTransformFunc = [&](const Vec2F& point) { return Vec2F(mTimeline->WorldToLocal(point.x), mTree->GetLineNumber(point.y)); }; mRightFrameDragHandle.isPointInside = [&](const Vec2F& point) { auto r = mSelectionFrame->GetRect(); return RectF(r.right - 5, r.bottom, r.right + 5, r.top).IsInside(point); }; mRightFrameDragHandle.checkPositionFunc = [&](const Vec2F& point) { return Vec2F(point.x, mSelectionRect.Center().y); }; mRightFrameDragHandle.onChangedPos = [&](const Vec2F& point) { if (Math::Equals(mSelectionRect.Width(), 0.0f)) return; float scale = (point.x - mSelectionRect.left) / (mSelectionRect.right - mSelectionRect.left); for (auto animatedValueDef : mAnimation->GetAnimationsValues()) animatedValueDef.animatedValue->BeginKeysBatchChange(); for (auto handle : GetSelectedHandles()) { handle->SetPosition(Vec2F((handle->GetPosition().x - mSelectionRect.left)*scale + mSelectionRect.left, handle->GetPosition().y)); handle->onChangedPos(handle->GetPosition()); } for (auto animatedValueDef : mAnimation->GetAnimationsValues()) animatedValueDef.animatedValue->CompleteKeysBatchingChange(); UpdateSelectionFrame(); }; mRightFrameDragHandle.cursorType = CursorType::SizeWE; }
void Input::Update(float dt) { mDownKeys.Add(mPressedKeys); mPressedKeys.Clear(); mReleasedKeys.Clear(); for (Key& ikey : mDownKeys) ikey.pressedTime += dt; for (Cursor& cursor : mCursors) { cursor.pressedTime += dt; cursor.delta = Vec2F(); } mMainCursorDelta = Vec2F(); mReleasedCursors.Clear(); mMouseWheelDelta = 0; }
void WidgetLayout::CheckMinMax() { Vec2F resSize = mData->size; Vec2F minSizeWithChildren(mData->owner->GetMinWidthWithChildren(), mData->owner->GetMinHeightWithChildren()); Vec2F clampSize(Math::Clamp(resSize.x, minSizeWithChildren.x, mData->maxSize.x), Math::Clamp(resSize.y, minSizeWithChildren.y, mData->maxSize.y)); Vec2F szDelta = clampSize - resSize; if (szDelta != Vec2F()) mData->size += szDelta; }
Vec2F Input::GetCursorPos(CursorId id /*= 0*/) const { for (auto cursor : mCursors) { if (cursor.id == id) return cursor.position; } if (id == 0) return mMainCursorPos; return Vec2F(); }
void KeyHandlesSheet::InitializeCenterHandle() { mCenterFrameDragHandle.localToScreenTransformFunc = [&](const Vec2F& point) { return Vec2F(mTimeline->LocalToWorld(point.x), mTree->GetLineWorldPosition(point.y)); }; mCenterFrameDragHandle.screenToLocalTransformFunc = [&](const Vec2F& point) { return Vec2F(mTimeline->WorldToLocal(point.x), mTree->GetLineNumber(point.y)); }; mCenterFrameDragHandle.isPointInside = [&](const Vec2F& point) { auto local = Vec2F(mTimeline->WorldToLocal(point.x), mTree->GetLineNumber(point.y)); return local.x > mSelectionRect.left && local.x < mSelectionRect.right && local.y > mSelectionRect.top && local.y < mSelectionRect.bottom; }; mCenterFrameDragHandle.checkPositionFunc = [&](const Vec2F& point) { return Vec2F(point.x, mSelectionRect.Center().y); }; mCenterFrameDragHandle.onPressed = [&]() { SelectableDragHandlesGroup::OnHandleCursorPressed(&mCenterFrameDragHandle, *o2Input.GetCursor()); }; mCenterFrameDragHandle.onChangedPos = [&](const Vec2F& point) { Vec2F delta(point.x - mSelectionRect.Center().x, mSelectionRect.Center().y); for (auto animatedValueDef : mAnimation->GetAnimationsValues()) animatedValueDef.animatedValue->BeginKeysBatchChange(); SelectableDragHandlesGroup::OnHandleMoved(&mCenterFrameDragHandle, o2Input.GetCursorPos()); for (auto animatedValueDef : mAnimation->GetAnimationsValues()) animatedValueDef.animatedValue->CompleteKeysBatchingChange(); UpdateSelectionFrame(); }; mCenterFrameDragHandle.cursorType = CursorType::SizeWE; }
VertexArray<4> RenderContext::transformRect(RectF rect, RenderParameters params) { VertexArray<4> output; int halfWidth = this->Size.X / 2; int halfHeight = this->Size.Y / 2; float xPixelFactor = 1.0f / halfWidth; float yPixelFactor = 1.0f / halfHeight; Vec2F origin = rect.getOrigin(); Vec2F size = rect.getSize(); float left = (xPixelFactor * (params.Offset.X + this->CameraPos.X + origin.X)) + this->CoordinateOrigin.X; float right = (xPixelFactor * (params.Offset.X + this->CameraPos.X + origin.X + size.X)) + this->CoordinateOrigin.X; float down = (yPixelFactor * (params.Offset.Y + this->CameraPos.Y + origin.Y)) + this->CoordinateOrigin.Y; float up = (yPixelFactor * (params.Offset.Y + this->CameraPos.Y + origin.Y + size.Y)) + this->CoordinateOrigin.Y; output[0] = Vec2F(left, down); output[1] = Vec2F(right, down); output[2] = Vec2F(left, up); output[3] = Vec2F(right, up); return output; }
Vec2F Input::GetCursorDelta(CursorId id /*= 0*/) const { for (auto cursor : mCursors) { if (cursor.id == id) { return cursor.delta; } } if (id == 0) return mMainCursorDelta; return Vec2F(); }
void EditorApplication::OnDraw() { o2Render.Clear(); o2Render.camera = Camera::Default(); mBackground->Draw(); mBackSign->Draw(); mWindowsManager->Draw(); // Debug draw undo actions if (o2Input.IsKeyDown(VK_F6)) { for (int i = 0; i < mActions.Count(); i++) o2Debug.DrawText(Vec2F(0, 20 * i), (String)i + mActions[i]->GetName()); } }
void Input::OnCursorReleasedMsgApply(CursorId id /*= 0*/) { Cursor releasedCursor(Vec2F(), -100); for (auto& cursor : mCursors) { if (cursor.id == id) { releasedCursor = cursor; if (id == 0 && o2Config.GetPlatform() == Platform::Windows) cursor.isPressed = false; else mCursors.Remove(cursor); break; } } mReleasedCursors.Add(releasedCursor); }
void Application::CheckCursorInfiniteMode() { int threshold = 10; POINT p, lp; GetCursorPos(&p); lp = p; Vec2I resolution = GetScreenResolution(); if (p.x > resolution.x - threshold) p.x = threshold; else if (p.x < threshold) p.x = resolution.x - threshold; if (p.y > resolution.y - threshold) p.y = threshold; else if (p.y < threshold) p.y = resolution.y - threshold; SetCursorPos(p.x, p.y); if (p.x != lp.x || p.y != lp.y) mCursorCorrectionDelta = Vec2F((float)(lp.x - p.x), (float)(lp.y - p.y)); }
Vec2F SquareParticlesEmitterShape::GetEmittinPoint() { Vec2F hs = size*0.5f; return Vec2F(Math::Random(-hs.x, hs.x), Math::Random(-hs.y, hs.y)); }
void FrameScrollView::OnHorScrollScrolled(float value) { mViewCamera.SetPosition(Vec2F(value, mViewCamera.GetPosition().y)); mViewCameraTargetPos = mViewCamera.GetPosition(); mNeedRedraw = true; }
Vec2F ParticlesEmitterShape::GetEmittinPoint() { return Vec2F(); }
void Root::start() { al_init(); al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); al_init_primitives_addon(); al_install_keyboard(); al_install_mouse(); m_windowWidth = 1024; m_windowHeight = 768; m_display = al_create_display(m_windowWidth, m_windowHeight); m_drawTimer = al_create_timer(1.0 / FPS); m_tickTimer = al_create_timer(1.0 / TPS); m_fpsLimit = false; /* Initializing assets */ m_assets = new Assets(); /* Initializing spritesheets */ m_spritesheetDatabase = new SpritesheetDatabase(); m_spritesheetDatabase->load(m_assets); /* Initializing tiles */ m_tileDatabase = new TileDatabase(); addBaseTilesToDatabase(); m_tileDatabase->load(m_assets); /* World generator */ //temporarly it will be hardcoded world generator path/handle/id std::vector<std::string> generators = m_assets->worldGenerators(); if(generators.empty()) { std::cout << "No world generators found. Exiting."; return; } Configuration worldGeneratorConfig = Configuration(generators[0]); m_worldGenerator = new WorldGenerator(worldGeneratorConfig); /* Creating world */ m_world = new World(m_worldGenerator); al_start_timer(m_tickTimer); al_start_timer(m_drawTimer); int framesThisSecond = 0; int ticksThisSecond = 0; int lastTicks = al_get_timer_count(m_tickTimer); int lastFPSTicks = al_get_timer_count(m_drawTimer); for(;;) { ALLEGRO_KEYBOARD_STATE currentKeyboardState; al_get_keyboard_state(¤tKeyboardState); int nowTicks = al_get_timer_count(m_tickTimer); int nowDrawTicks = al_get_timer_count(m_drawTimer); if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_ESCAPE)) { return; } if(nowTicks != lastTicks && !(nowTicks % TPS)) { m_currentFps = framesThisSecond; framesThisSecond = 0; m_currentTps = ticksThisSecond; ticksThisSecond = 0; std::cout << "FPS: " << m_currentFps << "\nTPS: " << m_currentTps << "\n\n"; } if(nowTicks != lastTicks) { lastTicks = nowTicks; ++m_ticks; ++ticksThisSecond; #define HIGH_SPEED_CAMERA #ifndef HIGH_SPEED_CAMERA /* low camera speed */ if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_LEFT)) { m_world->moveCamera(Vec2D(-3, 0)); } if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_RIGHT)) { m_world->moveCamera(Vec2D(3, 0)); } if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_UP)) { m_world->moveCamera(Vec2D(0, -3)); } if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_DOWN)) { m_world->moveCamera(Vec2D(0, 3)); } #else /* high camera speed */ if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_LEFT)) { m_world->moveCamera(Vec2F(-20.3, 0)); } if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_RIGHT)) { m_world->moveCamera(Vec2F(20.3, 0)); } if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_UP)) { m_world->moveCamera(Vec2F(0, -20.3)); } if(al_key_down(¤tKeyboardState, ALLEGRO_KEY_DOWN)) { m_world->moveCamera(Vec2F(0, 20.3)); } #endif // HIGH_SPEED_CAMERA m_world->update(); } if(nowDrawTicks != lastFPSTicks || !m_fpsLimit) { lastFPSTicks = nowDrawTicks; ++framesThisSecond; al_clear_to_color(al_map_rgb(64, 128, 255)); m_world->draw(); al_flip_display(); } } }
void RenderContext::loadDefaults() { CameraPos = Vec2F(0, 0); LastBoundTexture = 0; }
Rect Texture::calcTextureCoordinates(Vec2I pos, Vec2I size) { return Rect((Vec2F(pos) + 0.375f) / Vec2F(TextureSize), (Vec2F(size) - 0.375f) / Vec2F(TextureSize)); }
LRESULT WndProcFunc::WndProc(HWND wnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { auto app = Application::InstancePtr(); POINT pt; RECT rt; int key = 0; Vec2I size, pos; GetCursorPos(&pt); ScreenToClient(wnd, &pt); Vec2F cursorPos = Vec2F((float)pt.x, (float)-pt.y); if (app->mRender) cursorPos -= Vec2F(Math::Round(app->mRender->mResolution.x*0.5f), Math::Round(-app->mRender->mResolution.y*0.5f)); float wheelDelta; if (app->IsReady()) { switch (uMsg) { case WM_LBUTTONDOWN: SetCapture(app->mHWnd); app->mInput->OnCursorPressed(cursorPos); break; case WM_LBUTTONUP: app->mInput->OnCursorReleased(); ReleaseCapture(); break; case WM_RBUTTONDOWN: SetCapture(app->mHWnd); app->mInput->OnAltCursorPressed(cursorPos); break; case WM_RBUTTONUP: app->mInput->OnAltCursorReleased(); ReleaseCapture(); break; case WM_MBUTTONDOWN: SetCapture(app->mHWnd); app->mInput->OnAlt2CursorPressed(cursorPos); break; case WM_MBUTTONUP: app->mInput->OnAlt2CursorReleased(); ReleaseCapture(); break; case WM_KEYDOWN: key = (int)wParam; app->mInput->OnKeyPressed(key); break; case WM_KEYUP: app->mInput->OnKeyReleased((int)wParam); break; case WM_MOUSEMOVE: app->mInput->OnCursorMoved(cursorPos, 0); app->mInput->GetCursor()->delta -= app->mCursorCorrectionDelta; app->mCursorCorrectionDelta = Vec2F(); break; case WM_MOUSEWHEEL: wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam); app->mInput->OnMouseWheel(wheelDelta); break; case WM_ACTIVATEAPP: case WM_ENABLE: if (wParam == TRUE) { app->mActive = true; app->OnActivated(); app->onActivated.Invoke(); o2Events.OnApplicationActivated(); } else { app->mActive = false; app->OnDeactivated(); app->onDeactivated.Invoke(); o2Events.OnApplicationDeactivated(); } break; case WM_SIZE: GetWindowRect(app->mHWnd, &rt); size.x = rt.right - rt.left; size.y = rt.bottom - rt.top; if (size.x > 0 && size.y > 0 && size != app->mWindowedSize) { app->mWindowedSize = size; app->mRender->OnFrameResized(); app->onResizing.Invoke(); app->OnResizing(); o2Events.OnApplicationSized(); } app->ProcessFrame(); break; case WM_MOVE: GetWindowRect(app->mHWnd, &rt); pos.x = rt.left; pos.y = rt.top; if (pos.x < 10000 && pos.y < 10000 && pos != app->mWindowedPos) { app->mWindowedPos = pos; app->OnMoved(); app->onMoving.Invoke(); } break; case WM_DESTROY: PostQuitMessage(0); return 0; break; } } return DefWindowProc(wnd, uMsg, wParam, lParam); }
WidgetLayout WidgetLayout::Based(BaseCorner corner, const Vec2F& size, const Vec2F& offset) { WidgetLayout res; switch (corner) { case BaseCorner::Left: res.mData->anchorMin = Vec2F(0.0f, 0.5f); res.mData->anchorMax = Vec2F(0.0f, 0.5f); res.mData->offsetMin = Vec2F(0.0f, -size.y*0.5f) + offset; res.mData->offsetMax = Vec2F(size.x, size.y*0.5f) + offset; break; case BaseCorner::Right: res.mData->anchorMin = Vec2F(1.0f, 0.5f); res.mData->anchorMax = Vec2F(1.0f, 0.5f); res.mData->offsetMin = Vec2F(-size.x, -size.y*0.5f) + offset; res.mData->offsetMax = Vec2F(0.0f, size.y*0.5f) + offset; break; case BaseCorner::Top: res.mData->anchorMin = Vec2F(0.5f, 1.0f); res.mData->anchorMax = Vec2F(0.5f, 1.0f); res.mData->offsetMin = Vec2F(-size.x*0.5f, -size.y) + offset; res.mData->offsetMax = Vec2F(size.x*0.5f, 0.0f) + offset; break; case BaseCorner::Bottom: res.mData->anchorMin = Vec2F(0.5f, 0.0f); res.mData->anchorMax = Vec2F(0.5f, 0.0f); res.mData->offsetMin = Vec2F(-size.x*0.5f, 0.0f) + offset; res.mData->offsetMax = Vec2F(size.x*0.5f, size.y) + offset; break; case BaseCorner::Center: res.mData->anchorMin = Vec2F(0.5f, 0.5f); res.mData->anchorMax = Vec2F(0.5f, 0.5f); res.mData->offsetMin = Vec2F(-size.x*0.5f, -size.y*0.5f) + offset; res.mData->offsetMax = Vec2F(size.x*0.5f, size.y*0.5f) + offset; break; case BaseCorner::LeftBottom: res.mData->anchorMin = Vec2F(0.0f, 0.0f); res.mData->anchorMax = Vec2F(0.0f, 0.0f); res.mData->offsetMin = Vec2F(0.0f, 0.0f) + offset; res.mData->offsetMax = Vec2F(size.x, size.y) + offset; break; case BaseCorner::LeftTop: res.mData->anchorMin = Vec2F(0.0f, 1.0f); res.mData->anchorMax = Vec2F(0.0f, 1.0f); res.mData->offsetMin = Vec2F(0.0f, -size.y) + offset; res.mData->offsetMax = Vec2F(size.x, 0.0f) + offset; break; case BaseCorner::RightBottom: res.mData->anchorMin = Vec2F(1.0f, 0.0f); res.mData->anchorMax = Vec2F(1.0f, 0.0f); res.mData->offsetMin = Vec2F(-size.x, 0.0f) + offset; res.mData->offsetMax = Vec2F(0.0f, size.y) + offset; break; case BaseCorner::RightTop: res.mData->anchorMin = Vec2F(1.0f, 1.0f); res.mData->anchorMax = Vec2F(1.0f, 1.0f); res.mData->offsetMin = Vec2F(-size.x, -size.y) + offset; res.mData->offsetMax = Vec2F(0.0f, 0.0f) + offset; break; } return res; }
void MyApplication::OnStarted() { auto button = o2UI.AddButton("Hello world", []() { o2Debug.Log("Click!"); }); button->layout = UIWidgetLayout::Based(BaseCorner::Center, Vec2F(100, 30)); }
void PlaySpace::update(float time) { if(time > 0.25f) { ParticleBudget = 0; time = 0.25f; } else ParticleBudget = 500; LastDeltaTime = time; GameTime += time; GameFrame += 1; if(!Player) TimeSincePlayerDestruction += time; SoundManager* manager = SoundManager::GetInstance(); manager->setListenerPosition(CameraPos); if(IsStressTesting) time = 1.f / 30; if(!IsStressTesting) for(int i = 0; i < Systems.UsedLength; ++i) { Systems[i]->update(time, this); } for(int i = 0; i < Bullets.UsedLength; ++i) { if(Bullets[i].canBeDespawned()) Bullets.quickRemove(i--); } for(int i = 0; i < Particles.UsedLength; ++i) { if(Particles[i].canBeDespawned()) Particles.quickRemove(i--); } for(int i = 0; i < Ships.UsedLength; ++i) { if(Ships[i]->canBeDespawned()) { ObjectPointer<Ship>(Ships[i]).destroy(); // Object pointer lets other object pointers know that the object got deleted. Objects.quickRemove(Objects.findIndex(Ships[i])); Ships.quickRemove(i--); } } for(PhysicsObject* obj : Objects) obj->update(time, this); for(GravitySource& src : GravitySources) src.update(time, this); for(Bullet& obj : Bullets) obj.update(time, this); // The more particles exist the faster time passes for them, the faster they die float particleTimeFactor = Max(float(Particles.UsedLength) / SoftMaxParticleCount, 1.0f); for(Particle& particle : Particles) particle.update(time * particleTimeFactor, this); // Physics for(PhysicsObject* obj : Objects) applyPhysics(obj, time); for(Bullet& obj : Bullets) applyPhysics(&obj, time); for(Particle& particle : Particles) applyPhysics(&particle, time * particleTimeFactor); // Add gravity for(GravitySource& src : GravitySources) { float start = src.Position.X - src.Range*2; float end = src.Position.X + src.Range*2; for(auto* obj : Objects) src.influence(obj, time); for(auto& obj : Bullets) src.influence(&obj, time); for(auto& obj : Particles) src.influence(&obj, time); } for(Bullet& bullet : Bullets) for(Ship* ship : Ships) if(ship->Faction != bullet.Faction) if(ship->Status != Ship::Destroyed) if(IsIntersecting(bullet.Bounds, ship->Bounds)) ship->onHit(&bullet, this); if(Player) { CameraPos = Player->Position; Renderer.Context.Camera.Position = CameraPos; // Will be reset to true before next PlaySpace::update Player->IsShooting = false; Player->IsShootingSecondary = false; Player->IsBraking = false; Player->IsStabilizing = false; Player->IsBoosting = false; Player->Steering = 0.0f; if(!IsStressTesting) { checkSectorGeneration(Player->Position); checkSectorGeneration(Player->Position + Vec2F(SectorLookAhead, 0)); checkSectorGeneration(Player->Position + Vec2F(0, SectorLookAhead)); checkSectorGeneration(Player->Position - Vec2F(SectorLookAhead, 0)); checkSectorGeneration(Player->Position - Vec2F(0, SectorLookAhead)); checkSectorGeneration(Player->Position + Vec2F(SectorLookAhead)); checkSectorGeneration(Player->Position - Vec2F(SectorLookAhead)); checkSectorGeneration(Player->Position + Vec2F(SectorLookAhead/2, 0)); checkSectorGeneration(Player->Position + Vec2F(0, SectorLookAhead/2)); checkSectorGeneration(Player->Position - Vec2F(SectorLookAhead/2, 0)); checkSectorGeneration(Player->Position - Vec2F(0, SectorLookAhead/2)); checkSectorGeneration(Player->Position + Vec2F(SectorLookAhead/2)); checkSectorGeneration(Player->Position - Vec2F(SectorLookAhead/2)); } } ParticleBudget = 0; if(Music->isFinished()){ Music->setOffset(0); Music->resume(); }; }