From 852617a2ea3cfe83c1d0aec134d9369aa5c3af7b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 7 Mar 2016 17:13:01 +0300 Subject: Improve a bit imageparticle draw. --- src/particle/imageparticle.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/particle/imageparticle.cpp') diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp index d6914eafc..5a67886c0 100644 --- a/src/particle/imageparticle.cpp +++ b/src/particle/imageparticle.cpp @@ -75,15 +75,17 @@ void ImageParticle::draw(Graphics *restrict const graphics, if (mAlive != AliveStatus::ALIVE || !mImage) return; + const int w = mImage->mBounds.w; + const int h = mImage->mBounds.h; const int screenX = CAST_S32(mPos.x) - + offsetX - mImage->mBounds.w / 2; + + offsetX - w / 2; const int screenY = CAST_S32(mPos.y) - CAST_S32(mPos.z) - + offsetY - mImage->mBounds.h / 2; + + offsetY - h / 2; // Check if on screen - if (screenX + mImage->mBounds.w < 0 || + if (screenX + w < 0 || screenX > graphics->mWidth || - screenY + mImage->mBounds.h < 0 || + screenY + h < 0 || screenY > graphics->mHeight) { return; -- cgit v1.2.3-60-g2f50