From 86abc9323b578d4a113199379a43c86323d5c194 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Sat, 4 Feb 2012 11:31:07 -0500 Subject: [PATCH] Add ParticleSystem:getPosition (issue #368) --- src/modules/graphics/opengl/ParticleSystem.cpp | 5 +++++ src/modules/graphics/opengl/ParticleSystem.h | 5 +++++ src/modules/graphics/opengl/wrap_ParticleSystem.cpp | 12 ++++++++++++ src/modules/graphics/opengl/wrap_ParticleSystem.h | 1 + 4 files changed, 23 insertions(+) diff --git a/src/modules/graphics/opengl/ParticleSystem.cpp b/src/modules/graphics/opengl/ParticleSystem.cpp index ab0da26c3..156f109cf 100644 --- a/src/modules/graphics/opengl/ParticleSystem.cpp +++ b/src/modules/graphics/opengl/ParticleSystem.cpp @@ -320,6 +320,11 @@ namespace opengl { return position.getY(); } + + const love::Vector& ParticleSystem::getPosition() const + { + return position; + } float ParticleSystem::getDirection() const { diff --git a/src/modules/graphics/opengl/ParticleSystem.h b/src/modules/graphics/opengl/ParticleSystem.h index 4bd8e06af..7237bcc04 100644 --- a/src/modules/graphics/opengl/ParticleSystem.h +++ b/src/modules/graphics/opengl/ParticleSystem.h @@ -363,6 +363,11 @@ namespace opengl **/ float getY() const; + /** + * Returns the position of the emitter. + **/ + const love::Vector& getPosition() const; + /** * Returns the direction of the emitter (in degrees). **/ diff --git a/src/modules/graphics/opengl/wrap_ParticleSystem.cpp b/src/modules/graphics/opengl/wrap_ParticleSystem.cpp index 884f46af4..c81e42239 100644 --- a/src/modules/graphics/opengl/wrap_ParticleSystem.cpp +++ b/src/modules/graphics/opengl/wrap_ParticleSystem.cpp @@ -20,6 +20,8 @@ #include "wrap_ParticleSystem.h" +#include + #include namespace love @@ -260,6 +262,15 @@ namespace opengl lua_pushnumber(L, t->getY()); return 1; } + + int w_ParticleSystem_getPosition(lua_State * L) + { + ParticleSystem * t = luax_checkparticlesystem(L, 1); + const love::Vector& p = t->getPosition(); + lua_pushnumber(L, p.x); + lua_pushnumber(L, p.y); + return 2; + } int w_ParticleSystem_getDirection(lua_State * L) { @@ -376,6 +387,7 @@ namespace opengl { "setOffset", w_ParticleSystem_setOffset }, { "getX", w_ParticleSystem_getX }, { "getY", w_ParticleSystem_getY }, + { "getPosition", w_ParticleSystem_getPosition }, { "getDirection", w_ParticleSystem_getDirection }, { "getSpread", w_ParticleSystem_getSpread }, { "getOffsetX", w_ParticleSystem_getOffsetX }, diff --git a/src/modules/graphics/opengl/wrap_ParticleSystem.h b/src/modules/graphics/opengl/wrap_ParticleSystem.h index 980794f6e..7fb0f17b5 100644 --- a/src/modules/graphics/opengl/wrap_ParticleSystem.h +++ b/src/modules/graphics/opengl/wrap_ParticleSystem.h @@ -55,6 +55,7 @@ namespace opengl int w_ParticleSystem_setOffset(lua_State * L); int w_ParticleSystem_getX(lua_State * L); int w_ParticleSystem_getY(lua_State * L); + int w_ParticleSystem_getPosition(lua_State * L); int w_ParticleSystem_getDirection(lua_State * L); int w_ParticleSystem_getSpread(lua_State * L); int w_ParticleSystem_getOffsetX(lua_State * L);