user can now manually set the offset for particle rotation

This commit is contained in:
bill@Ixion
2009-08-30 05:05:27 -05:00
parent 98db275e76
commit 8d666d0284
4 changed files with 515 additions and 448 deletions
+19 -2
View File
@@ -47,7 +47,8 @@ namespace opengl
gravityMax(0), radialAccelerationMin(0), radialAccelerationMax(0), gravityMax(0), radialAccelerationMin(0), radialAccelerationMax(0),
tangentialAccelerationMin(0), tangentialAccelerationMax(0), tangentialAccelerationMin(0), tangentialAccelerationMax(0),
sizeStart(1), sizeEnd(1), sizeVariation(0), rotationMin(0), rotationMax(0), sizeStart(1), sizeEnd(1), sizeVariation(0), rotationMin(0), rotationMax(0),
spinStart(0), spinEnd(0), spinVariation(0) spinStart(0), spinEnd(0), spinVariation(0), offsetX(sprite->getWidth()*0.5f),
offsetY(sprite->getHeight()*0.5f)
{ {
this->sprite = sprite; this->sprite = sprite;
sprite->retain(); sprite->retain();
@@ -307,6 +308,12 @@ namespace opengl
memcpy(colorStart, start, 4); memcpy(colorStart, start, 4);
memcpy(colorEnd, end, 4); memcpy(colorEnd, end, 4);
} }
void ParticleSystem::setOffset(float x, float y)
{
offsetX = x;
offsetY = y;
}
float ParticleSystem::getX() const float ParticleSystem::getX() const
{ {
@@ -327,6 +334,16 @@ namespace opengl
{ {
return spread * LOVE_M_TODEG; return spread * LOVE_M_TODEG;
} }
float ParticleSystem::getOffsetX() const
{
return offsetX;
}
float ParticleSystem::getOffsetY() const
{
return offsetY;
}
int ParticleSystem::count() const int ParticleSystem::count() const
{ {
@@ -393,7 +410,7 @@ namespace opengl
glTranslatef(p->position[0],p->position[1],0.0f); glTranslatef(p->position[0],p->position[1],0.0f);
glRotatef(p->rotation * 57.29578f, 0.0f, 0.0f, 1.0f); // rad * (180 / pi) glRotatef(p->rotation * 57.29578f, 0.0f, 0.0f, 1.0f); // rad * (180 / pi)
glScalef(p->size,p->size,1.0f); glScalef(p->size,p->size,1.0f);
glTranslatef(sprite->getWidth()*-0.5f,sprite->getHeight()*-0.5f,0.0f); glTranslatef(-offsetX,-offsetY,0.0f);
sprite->draw(0,0, 0, 1, 1, 0, 0); sprite->draw(0,0, 0, 1, 1, 0, 0);
glPopMatrix(); glPopMatrix();
+41 -20
View File
@@ -1,21 +1,21 @@
/** /**
* Copyright (c) 2006-2009 LOVE Development Team * Copyright (c) 2006-2009 LOVE Development Team
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
* arising from the use of this software. * arising from the use of this software.
* *
* Permission is granted to anyone to use this software for any purpose, * Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it * including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions: * freely, subject to the following restrictions:
* *
* 1. The origin of this software must not be misrepresented; you must not * 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software * claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be * in a product, an acknowledgment in the product documentation would be
* appreciated but is not required. * appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be * 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software. * misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution. * 3. This notice may not be removed or altered from any source distribution.
**/ **/
#ifndef LOVE_GRAPHICS_OPENGL_PARTICLE_SYSTEM_H #ifndef LOVE_GRAPHICS_OPENGL_PARTICLE_SYSTEM_H
@@ -139,6 +139,10 @@ namespace opengl
float spinStart; float spinStart;
float spinEnd; float spinEnd;
float spinVariation; float spinVariation;
// Offsets
float offsetX;
float offsetY;
// Color. // Color.
unsigned char colorStart[4]; unsigned char colorStart[4];
@@ -340,7 +344,14 @@ namespace opengl
* @param color The color. * @param color The color.
**/ **/
void setColor(unsigned char * color); void setColor(unsigned char * color);
/**
* Sets the particles' offsets for rotation.
* @param x The x offset.
* @param y The y offset.
**/
void setOffset(float x, float y);
/** /**
* Sets the color of the particles. * Sets the color of the particles.
* @param start The color of the particle when created. * @param start The color of the particle when created.
@@ -367,7 +378,17 @@ namespace opengl
* Returns the directional spread of the emitter (in degrees). * Returns the directional spread of the emitter (in degrees).
**/ **/
float getSpread() const; float getSpread() const;
/**
* Returns the X offset of the particles.
**/
float getOffsetX() const;
/**
* Returns the Y offset of the particles.
**/
float getOffsetY() const;
/** /**
* Returns the amount of particles that are currently active in the system. * Returns the amount of particles that are currently active in the system.
**/ **/
@@ -1,352 +1,378 @@
/** /**
* Copyright (c) 2006-2009 LOVE Development Team * Copyright (c) 2006-2009 LOVE Development Team
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
* arising from the use of this software. * arising from the use of this software.
* *
* Permission is granted to anyone to use this software for any purpose, * Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it * including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions: * freely, subject to the following restrictions:
* *
* 1. The origin of this software must not be misrepresented; you must not * 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software * claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be * in a product, an acknowledgment in the product documentation would be
* appreciated but is not required. * appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be * 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software. * misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution. * 3. This notice may not be removed or altered from any source distribution.
**/ **/
#include "wrap_ParticleSystem.h" #include "wrap_ParticleSystem.h"
#include <cstring> #include <cstring>
namespace love namespace love
{ {
namespace graphics namespace graphics
{ {
namespace opengl namespace opengl
{ {
ParticleSystem * luax_checkparticlesystem(lua_State * L, int idx) ParticleSystem * luax_checkparticlesystem(lua_State * L, int idx)
{ {
return luax_checktype<ParticleSystem>(L, idx, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T); return luax_checktype<ParticleSystem>(L, idx, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T);
} }
int w_ParticleSystem_setSprite(lua_State * L) int w_ParticleSystem_setSprite(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
Image * i = luax_checkimage(L, 2); Image * i = luax_checkimage(L, 2);
t->setSprite(i); t->setSprite(i);
return 0; return 0;
} }
int w_ParticleSystem_setBufferSize(lua_State * L) int w_ParticleSystem_setBufferSize(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
int arg1 = luaL_checkint(L, 2); int arg1 = luaL_checkint(L, 2);
t->setBufferSize((unsigned int)arg1); t->setBufferSize((unsigned int)arg1);
return 0; return 0;
} }
int w_ParticleSystem_setEmissionRate(lua_State * L) int w_ParticleSystem_setEmissionRate(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
int arg1 = luaL_checkint(L, 2); int arg1 = luaL_checkint(L, 2);
t->setEmissionRate((unsigned int)arg1); t->setEmissionRate((unsigned int)arg1);
return 0; return 0;
} }
int w_ParticleSystem_setLifetime(lua_State * L) int w_ParticleSystem_setLifetime(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
t->setLifetime(arg1); t->setLifetime(arg1);
return 0; return 0;
} }
int w_ParticleSystem_setParticleLife(lua_State * L) int w_ParticleSystem_setParticleLife(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_optnumber(L, 3, arg1); float arg2 = (float)luaL_optnumber(L, 3, arg1);
t->setParticleLife(arg1, arg2); t->setParticleLife(arg1, arg2);
return 0; return 0;
} }
int w_ParticleSystem_setPosition(lua_State * L) int w_ParticleSystem_setPosition(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_checknumber(L, 3); float arg2 = (float)luaL_checknumber(L, 3);
t->setPosition(arg1, arg2); t->setPosition(arg1, arg2);
return 0; return 0;
} }
int w_ParticleSystem_setDirection(lua_State * L) int w_ParticleSystem_setDirection(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
t->setDirection(arg1); t->setDirection(arg1);
return 0; return 0;
} }
int w_ParticleSystem_setSpread(lua_State * L) int w_ParticleSystem_setSpread(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
t->setSpread(arg1); t->setSpread(arg1);
return 0; return 0;
} }
int w_ParticleSystem_setRelativeDirection(lua_State * L) int w_ParticleSystem_setRelativeDirection(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
bool arg1 = (bool)luax_toboolean(L, 2); bool arg1 = (bool)luax_toboolean(L, 2);
t->setRelativeDirection(arg1); t->setRelativeDirection(arg1);
return 0; return 0;
} }
int w_ParticleSystem_setSpeed(lua_State * L) int w_ParticleSystem_setSpeed(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_optnumber(L, 3, arg1); float arg2 = (float)luaL_optnumber(L, 3, arg1);
t->setSpeed(arg1, arg2); t->setSpeed(arg1, arg2);
return 0; return 0;
} }
int w_ParticleSystem_setGravity(lua_State * L) int w_ParticleSystem_setGravity(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_optnumber(L, 3, arg1); float arg2 = (float)luaL_optnumber(L, 3, arg1);
t->setGravity(arg1, arg2); t->setGravity(arg1, arg2);
return 0; return 0;
} }
int w_ParticleSystem_setRadialAcceleration(lua_State * L) int w_ParticleSystem_setRadialAcceleration(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_optnumber(L, 3, arg1); float arg2 = (float)luaL_optnumber(L, 3, arg1);
t->setRadialAcceleration(arg1, arg2); t->setRadialAcceleration(arg1, arg2);
return 0; return 0;
} }
int w_ParticleSystem_setTangentialAcceleration(lua_State * L) int w_ParticleSystem_setTangentialAcceleration(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_optnumber(L, 3, arg1); float arg2 = (float)luaL_optnumber(L, 3, arg1);
t->setTangentialAcceleration(arg1, arg2); t->setTangentialAcceleration(arg1, arg2);
return 0; return 0;
} }
int w_ParticleSystem_setSize(lua_State * L) int w_ParticleSystem_setSize(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_optnumber(L, 3, arg1); float arg2 = (float)luaL_optnumber(L, 3, arg1);
float arg3 = (float)luaL_optnumber(L, 3, 0); float arg3 = (float)luaL_optnumber(L, 3, 0);
t->setSize(arg1, arg2, arg3); t->setSize(arg1, arg2, arg3);
return 0; return 0;
} }
int w_ParticleSystem_setSizeVariation(lua_State * L) int w_ParticleSystem_setSizeVariation(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
t->setSizeVariation(arg1); t->setSizeVariation(arg1);
return 0; return 0;
} }
int w_ParticleSystem_setRotation(lua_State * L) int w_ParticleSystem_setRotation(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_optnumber(L, 3, arg1); float arg2 = (float)luaL_optnumber(L, 3, arg1);
t->setRotation(arg1, arg2); t->setRotation(arg1, arg2);
return 0; return 0;
} }
int w_ParticleSystem_setSpin(lua_State * L) int w_ParticleSystem_setSpin(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
float arg2 = (float)luaL_optnumber(L, 3, arg1); float arg2 = (float)luaL_optnumber(L, 3, arg1);
float arg3 = (float)luaL_optnumber(L, 3, 0); float arg3 = (float)luaL_optnumber(L, 3, 0);
t->setSpin(arg1, arg2, arg3); t->setSpin(arg1, arg2, arg3);
return 0; return 0;
} }
int w_ParticleSystem_setSpinVariation(lua_State * L) int w_ParticleSystem_setSpinVariation(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
float arg1 = (float)luaL_checknumber(L, 2); float arg1 = (float)luaL_checknumber(L, 2);
t->setSpinVariation(arg1); t->setSpinVariation(arg1);
return 0; return 0;
} }
int w_ParticleSystem_setColor(lua_State * L) int w_ParticleSystem_setColor(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
unsigned char start[4]; unsigned char start[4];
start[0] = (unsigned char)luaL_checkint(L, 2); start[0] = (unsigned char)luaL_checkint(L, 2);
start[1] = (unsigned char)luaL_checkint(L, 3); start[1] = (unsigned char)luaL_checkint(L, 3);
start[2] = (unsigned char)luaL_checkint(L, 4); start[2] = (unsigned char)luaL_checkint(L, 4);
start[3] = (unsigned char)luaL_checkint(L, 5); start[3] = (unsigned char)luaL_checkint(L, 5);
if(lua_gettop(L) > 5) if(lua_gettop(L) > 5)
{ {
unsigned char end[4]; unsigned char end[4];
end[0] = (unsigned char)luaL_checkint(L, 6); end[0] = (unsigned char)luaL_checkint(L, 6);
end[1] = (unsigned char)luaL_checkint(L, 7); end[1] = (unsigned char)luaL_checkint(L, 7);
end[2] = (unsigned char)luaL_checkint(L, 8); end[2] = (unsigned char)luaL_checkint(L, 8);
end[3] = (unsigned char)luaL_checkint(L, 9); end[3] = (unsigned char)luaL_checkint(L, 9);
t->setColor(start, end); t->setColor(start, end);
} }
else else
t->setColor(start); t->setColor(start);
return 0; return 0;
} }
int w_ParticleSystem_getX(lua_State * L) int w_ParticleSystem_setOffset(lua_State * L)
{ {
ParticleSystem * t = luax_checkparticlesystem(L, 1); ParticleSystem * t = luax_checkparticlesystem(L, 1);
lua_pushnumber(L, t->getX()); float x = (float)luaL_checknumber(L, 2);
return 1; float y = (float)luaL_checknumber(L, 3);
} t->setOffset(x, y);
return 0;
int w_ParticleSystem_getY(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_getX(lua_State * L)
lua_pushnumber(L, t->getY()); {
return 1; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} lua_pushnumber(L, t->getX());
return 1;
int w_ParticleSystem_getDirection(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_getY(lua_State * L)
lua_pushnumber(L, t->getDirection()); {
return 1; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} lua_pushnumber(L, t->getY());
return 1;
int w_ParticleSystem_getSpread(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_getDirection(lua_State * L)
lua_pushnumber(L, t->getSpread()); {
return 1; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} lua_pushnumber(L, t->getDirection());
return 1;
int w_ParticleSystem_count(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_getSpread(lua_State * L)
lua_pushnumber(L, t->count()); {
return 1; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} lua_pushnumber(L, t->getSpread());
return 1;
int w_ParticleSystem_start(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_getOffsetX(lua_State * L)
t->start(); {
return 0; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} lua_pushnumber(L, t->getOffsetX());
return 1;
int w_ParticleSystem_stop(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_getOffsetY(lua_State * L)
t->stop(); {
return 0; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} lua_pushnumber(L, t->getOffsetY());
return 1;
int w_ParticleSystem_pause(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_count(lua_State * L)
t->pause(); {
return 0; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} lua_pushnumber(L, t->count());
return 1;
int w_ParticleSystem_reset(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_start(lua_State * L)
t->reset(); {
return 0; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} t->start();
return 0;
int w_ParticleSystem_isActive(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_stop(lua_State * L)
luax_pushboolean(L, t->isActive()); {
return 1; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} t->stop();
return 0;
int w_ParticleSystem_isEmpty(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_pause(lua_State * L)
luax_pushboolean(L, t->isEmpty()); {
return 1; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} t->pause();
return 0;
int w_ParticleSystem_isFull(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_reset(lua_State * L)
luax_pushboolean(L, t->isFull()); {
return 1; ParticleSystem * t = luax_checkparticlesystem(L, 1);
} t->reset();
return 0;
int w_ParticleSystem_update(lua_State * L) }
{
ParticleSystem * t = luax_checkparticlesystem(L, 1); int w_ParticleSystem_isActive(lua_State * L)
float dt = (float)luaL_checknumber(L, 2); {
t->update(dt); ParticleSystem * t = luax_checkparticlesystem(L, 1);
return 0; luax_pushboolean(L, t->isActive());
} return 1;
}
static const luaL_Reg functions[] = {
{ "setSprite", w_ParticleSystem_setSprite }, int w_ParticleSystem_isEmpty(lua_State * L)
{ "setBufferSize", w_ParticleSystem_setBufferSize }, {
{ "setEmissionRate", w_ParticleSystem_setEmissionRate }, ParticleSystem * t = luax_checkparticlesystem(L, 1);
{ "setLifetime", w_ParticleSystem_setLifetime }, luax_pushboolean(L, t->isEmpty());
{ "setParticleLife", w_ParticleSystem_setParticleLife }, return 1;
{ "setPosition", w_ParticleSystem_setPosition }, }
{ "setDirection", w_ParticleSystem_setDirection },
{ "setSpread", w_ParticleSystem_setSpread }, int w_ParticleSystem_isFull(lua_State * L)
{ "setRelativeDirection", w_ParticleSystem_setRelativeDirection }, {
{ "setSpeed", w_ParticleSystem_setSpeed }, ParticleSystem * t = luax_checkparticlesystem(L, 1);
{ "setGravity", w_ParticleSystem_setGravity }, luax_pushboolean(L, t->isFull());
{ "setRadialAcceleration", w_ParticleSystem_setRadialAcceleration }, return 1;
{ "setTangentialAcceleration", w_ParticleSystem_setTangentialAcceleration }, }
{ "setSize", w_ParticleSystem_setSize },
{ "setSizeVariation", w_ParticleSystem_setSizeVariation }, int w_ParticleSystem_update(lua_State * L)
{ "setRotation", w_ParticleSystem_setRotation }, {
{ "setSpin", w_ParticleSystem_setSpin }, ParticleSystem * t = luax_checkparticlesystem(L, 1);
{ "setSpinVariation", w_ParticleSystem_setSpinVariation }, float dt = (float)luaL_checknumber(L, 2);
{ "setColor", w_ParticleSystem_setColor }, t->update(dt);
{ "getX", w_ParticleSystem_getX }, return 0;
{ "getY", w_ParticleSystem_getY }, }
{ "getDirection", w_ParticleSystem_getDirection },
{ "getSpread", w_ParticleSystem_getSpread }, static const luaL_Reg functions[] = {
{ "count", w_ParticleSystem_count }, { "setSprite", w_ParticleSystem_setSprite },
{ "start", w_ParticleSystem_start }, { "setBufferSize", w_ParticleSystem_setBufferSize },
{ "stop", w_ParticleSystem_stop }, { "setEmissionRate", w_ParticleSystem_setEmissionRate },
{ "pause", w_ParticleSystem_pause }, { "setLifetime", w_ParticleSystem_setLifetime },
{ "reset", w_ParticleSystem_reset }, { "setParticleLife", w_ParticleSystem_setParticleLife },
{ "isActive", w_ParticleSystem_isActive }, { "setPosition", w_ParticleSystem_setPosition },
{ "isEmpty", w_ParticleSystem_isEmpty }, { "setDirection", w_ParticleSystem_setDirection },
{ "isFull", w_ParticleSystem_isFull }, { "setSpread", w_ParticleSystem_setSpread },
{ "update", w_ParticleSystem_update }, { "setRelativeDirection", w_ParticleSystem_setRelativeDirection },
{ 0, 0 } { "setSpeed", w_ParticleSystem_setSpeed },
}; { "setGravity", w_ParticleSystem_setGravity },
{ "setRadialAcceleration", w_ParticleSystem_setRadialAcceleration },
int luaopen_particlesystem(lua_State * L) { "setTangentialAcceleration", w_ParticleSystem_setTangentialAcceleration },
{ { "setSize", w_ParticleSystem_setSize },
return luax_register_type(L, "ParticleSystem", functions); { "setSizeVariation", w_ParticleSystem_setSizeVariation },
} { "setRotation", w_ParticleSystem_setRotation },
{ "setSpin", w_ParticleSystem_setSpin },
} // opengl { "setSpinVariation", w_ParticleSystem_setSpinVariation },
} // graphics { "setColor", w_ParticleSystem_setColor },
} // love { "setOffset", w_ParticleSystem_setOffset },
{ "getX", w_ParticleSystem_getX },
{ "getY", w_ParticleSystem_getY },
{ "getDirection", w_ParticleSystem_getDirection },
{ "getSpread", w_ParticleSystem_getSpread },
{ "getOffsetX", w_ParticleSystem_getOffsetX },
{ "getOffsetY", w_ParticleSystem_getOffsetY },
{ "count", w_ParticleSystem_count },
{ "start", w_ParticleSystem_start },
{ "stop", w_ParticleSystem_stop },
{ "pause", w_ParticleSystem_pause },
{ "reset", w_ParticleSystem_reset },
{ "isActive", w_ParticleSystem_isActive },
{ "isEmpty", w_ParticleSystem_isEmpty },
{ "isFull", w_ParticleSystem_isFull },
{ "update", w_ParticleSystem_update },
{ 0, 0 }
};
int luaopen_particlesystem(lua_State * L)
{
return luax_register_type(L, "ParticleSystem", functions);
}
} // opengl
} // graphics
} // love
@@ -1,74 +1,77 @@
/** /**
* Copyright (c) 2006-2009 LOVE Development Team * Copyright (c) 2006-2009 LOVE Development Team
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
* arising from the use of this software. * arising from the use of this software.
* *
* Permission is granted to anyone to use this software for any purpose, * Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it * including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions: * freely, subject to the following restrictions:
* *
* 1. The origin of this software must not be misrepresented; you must not * 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software * claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be * in a product, an acknowledgment in the product documentation would be
* appreciated but is not required. * appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be * 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software. * misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution. * 3. This notice may not be removed or altered from any source distribution.
**/ **/
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H #ifndef LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H
#define LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H #define LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H
// LOVE // LOVE
#include <common/runtime.h> #include <common/runtime.h>
#include "wrap_Image.h" #include "wrap_Image.h"
#include "ParticleSystem.h" #include "ParticleSystem.h"
namespace love namespace love
{ {
namespace graphics namespace graphics
{ {
namespace opengl namespace opengl
{ {
ParticleSystem * luax_checkparticlesystem(lua_State * L, int idx); ParticleSystem * luax_checkparticlesystem(lua_State * L, int idx);
int w_ParticleSystem_setSprite(lua_State * L); int w_ParticleSystem_setSprite(lua_State * L);
int w_ParticleSystem_setBufferSize(lua_State * L); int w_ParticleSystem_setBufferSize(lua_State * L);
int w_ParticleSystem_setEmissionRate(lua_State * L); int w_ParticleSystem_setEmissionRate(lua_State * L);
int w_ParticleSystem_setLifetime(lua_State * L); int w_ParticleSystem_setLifetime(lua_State * L);
int w_ParticleSystem_setParticleLife(lua_State * L); int w_ParticleSystem_setParticleLife(lua_State * L);
int w_ParticleSystem_setPosition(lua_State * L); int w_ParticleSystem_setPosition(lua_State * L);
int w_ParticleSystem_setDirection(lua_State * L); int w_ParticleSystem_setDirection(lua_State * L);
int w_ParticleSystem_setSpread(lua_State * L); int w_ParticleSystem_setSpread(lua_State * L);
int w_ParticleSystem_setRelativeDirection(lua_State * L); int w_ParticleSystem_setRelativeDirection(lua_State * L);
int w_ParticleSystem_setSpeed(lua_State * L); int w_ParticleSystem_setSpeed(lua_State * L);
int w_ParticleSystem_setGravity(lua_State * L); int w_ParticleSystem_setGravity(lua_State * L);
int w_ParticleSystem_setRadialAcceleration(lua_State * L); int w_ParticleSystem_setRadialAcceleration(lua_State * L);
int w_ParticleSystem_setTangentialAcceleration(lua_State * L); int w_ParticleSystem_setTangentialAcceleration(lua_State * L);
int w_ParticleSystem_setSize(lua_State * L); int w_ParticleSystem_setSize(lua_State * L);
int w_ParticleSystem_setSizeVariation(lua_State * L); int w_ParticleSystem_setSizeVariation(lua_State * L);
int w_ParticleSystem_setRotation(lua_State * L); int w_ParticleSystem_setRotation(lua_State * L);
int w_ParticleSystem_setSpin(lua_State * L); int w_ParticleSystem_setSpin(lua_State * L);
int w_ParticleSystem_setSpinVariation(lua_State * L); int w_ParticleSystem_setSpinVariation(lua_State * L);
int w_ParticleSystem_setColor(lua_State * L); int w_ParticleSystem_setColor(lua_State * L);
int w_ParticleSystem_getX(lua_State * L); int w_ParticleSystem_setOffset(lua_State * L);
int w_ParticleSystem_getY(lua_State * L); int w_ParticleSystem_getX(lua_State * L);
int w_ParticleSystem_getDirection(lua_State * L); int w_ParticleSystem_getY(lua_State * L);
int w_ParticleSystem_getSpread(lua_State * L); int w_ParticleSystem_getDirection(lua_State * L);
int w_ParticleSystem_count(lua_State * L); int w_ParticleSystem_getSpread(lua_State * L);
int w_ParticleSystem_start(lua_State * L); int w_ParticleSystem_getOffsetX(lua_State * L);
int w_ParticleSystem_stop(lua_State * L); int w_ParticleSystem_getOffsetY(lua_State * L);
int w_ParticleSystem_pause(lua_State * L); int w_ParticleSystem_count(lua_State * L);
int w_ParticleSystem_reset(lua_State * L); int w_ParticleSystem_start(lua_State * L);
int w_ParticleSystem_isActive(lua_State * L); int w_ParticleSystem_stop(lua_State * L);
int w_ParticleSystem_isEmpty(lua_State * L); int w_ParticleSystem_pause(lua_State * L);
int w_ParticleSystem_isFull(lua_State * L); int w_ParticleSystem_reset(lua_State * L);
int w_ParticleSystem_update(lua_State * L); int w_ParticleSystem_isActive(lua_State * L);
int luaopen_particlesystem(lua_State * L); int w_ParticleSystem_isEmpty(lua_State * L);
int w_ParticleSystem_isFull(lua_State * L);
} // opengl int w_ParticleSystem_update(lua_State * L);
} // graphics int luaopen_particlesystem(lua_State * L);
} // love
} // opengl
#endif // LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H } // graphics
} // love
#endif // LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H