From bb0860c5d03de85e860fa92b7e34fa795977366d Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Fri, 16 Dec 2011 13:32:49 -0200 Subject: [PATCH] particles on center --- modules/particle.otpa | 36 +++++++++++++++++++++-------- src/framework/graphics/particle.cpp | 2 +- src/framework/util/point.h | 9 ++++---- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/modules/particle.otpa b/modules/particle.otpa index 44ca84d3..6720a01a 100644 --- a/modules/particle.otpa +++ b/modules/particle.otpa @@ -2,24 +2,42 @@ ParticleSystem AttractionAffector destination: 200 200 - acceleration: 128 - velocity-reduction-percent: 10 + acceleration: 64 + velocity-reduction-percent: 0 + Emitter + position: 200 264 + duration: 12 + burstRate: 2 + burstCount: 1 + delay: 0.5 + + particle-duration: 9999 + particle-position-radius: 0 + + particle-velocity: 64 + particle-velocity-angle: 0 + + particle-acceleration: 0 + + particle-size: 32 32 + particle-color: #33ff33ff + particle-texture: circle2.png + Emitter position: 200 200 - burstRate: 1 - burstCount: 128 + burstRate: 9999999999 + burstCount: 1 - particle-duration: 2 + particle-duration: 9999999 particle-position-radius: 0 - particle-velocity: 128 - particle-min-velocity-angle: 0 - particle-max-velocity-angle: 360 + particle-velocity: 0 + particle-velocity-angle: 0 particle-acceleration: 0 particle-size: 32 32 - particle-color: #33ff3344 + particle-color: #33ff33ff particle-texture: circle2.png diff --git a/src/framework/graphics/particle.cpp b/src/framework/graphics/particle.cpp index 7dce5bdb..5c9289f7 100644 --- a/src/framework/graphics/particle.cpp +++ b/src/framework/graphics/particle.cpp @@ -71,5 +71,5 @@ void Particle::update() // update acceleration m_velocity += m_acceleration * elapsedTime; - m_rect.moveTo((int)m_position.x, (int)m_position.y); + m_rect.moveTo((int)m_position.x - m_size.width() / 2, (int)m_position.y - m_size.height() / 2); } diff --git a/src/framework/util/point.h b/src/framework/util/point.h index a4683ccf..e13bf740 100644 --- a/src/framework/util/point.h +++ b/src/framework/util/point.h @@ -42,23 +42,24 @@ public: TSize toSize() const { return TSize(x, y); } TPoint operator-() const { return TPoint(-x, -y); } + TPoint operator+(const TPoint& other) const { return TPoint(x + other.x, y + other.y); } TPoint& operator+=(const TPoint& other) { x+=other.x; y+=other.y; return *this; } TPoint operator-(const TPoint& other) const { return TPoint(x - other.x, y - other.y); } TPoint& operator-=(const TPoint& other) { x-=other.x; y-=other.y; return *this; } TPoint operator*(const TPoint& other) const { return TPoint(x * other.x, y * other.y); } TPoint& operator*=(const TPoint& other) { x*=other.x; y*=other.y; return *this; } - TPoint operator*(const T v) const { return TPoint(x*v, y*v); } - TPoint& operator*=(const T v) { x*=v; y*=v; return *this; } TPoint operator/(const TPoint& other) const { return TPoint(x/other.x, y/other.y); } TPoint& operator/=(const TPoint& other) { x/=other.x; y/=other.y; return *this; } - TPoint operator/(const T v) const { return TPoint(x/v, y/v); } - TPoint& operator/=(const T v) { x/=v; y/=v; return *this; } TPoint operator+(T other) const { return TPoint(x + other, y + other); } TPoint& operator+=(T other) { x+=other; y+=other; return *this; } TPoint operator-(T other) const { return TPoint(x - other, y - other); } TPoint& operator-=(T other) { x-=other; y-=other; return *this; } + TPoint operator*(const T v) const { return TPoint(x*v, y*v); } + TPoint& operator*=(const T v) { x*=v; y*=v; return *this; } + TPoint operator/(const T v) const { return TPoint(x/v, y/v); } + TPoint& operator/=(const T v) { x/=v; y/=v; return *this; } bool operator<=(const TPoint&other) const { return x<=other.x && y<=other.y; } bool operator>=(const TPoint&other) const { return x>=other.x && y>=other.y; }