summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-08-11 12:02:00 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-11 12:02:00 (GMT)
commit9e634b95cca748b67d63a496b719a0b5c9746dc3 (patch)
treed2e5b90c634e148a735dcde600ea58e07746d98b /src
parent806e1933a2f1a80feeeb10e7923ae58461640225 (diff)
downloadpowder-9e634b95cca748b67d63a496b719a0b5c9746dc3.zip
powder-9e634b95cca748b67d63a496b719a0b5c9746dc3.tar.gz
Fire intensity from Lua
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c6
-rw-r--r--src/luaconsole.c10
2 files changed, 13 insertions, 3 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 4be05a6..055a867 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -3869,9 +3869,11 @@ void render_fire(pixel *vid)
}
}
-void prepare_alpha(void)
+void prepare_alpha(int size, float intensity)
{
+ //TODO: implement size
int x,y,i,j;
+ float multiplier = 255.0f*intensity;
float temp[CELL*3][CELL*3];
memset(temp, 0, sizeof(temp));
for (x=0; x<CELL; x++)
@@ -3881,7 +3883,7 @@ void prepare_alpha(void)
temp[y+CELL+j][x+CELL+i] += expf(-0.1f*(i*i+j*j));
for (x=0; x<CELL*3; x++)
for (y=0; y<CELL*3; y++)
- fire_alpha[y][x] = (int)(255.0f*temp[y][x]/(CELL*CELL));
+ fire_alpha[y][x] = (int)(multiplier*temp[y][x]/(CELL*CELL));
}
pixel *render_packed_rgb(void *image, int width, int height, int cmp_size)
diff --git a/src/luaconsole.c b/src/luaconsole.c
index dac25ea..5eba5e2 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -53,6 +53,7 @@ void luacon_open(){
{"display_mode", &luatpt_cmode_set},
{"throw_error", &luatpt_error},
{"heat", &luatpt_heat},
+ {"setfire", &luatpt_setfire},
{NULL,NULL}
};
@@ -1036,8 +1037,15 @@ int luatpt_heat(lua_State* l)
int luatpt_cmode_set(lua_State* l)
{
int aheatstate;
- aheatstate = luaL_optint(l, 1, CM_COUNT);
+ aheatstate = luaL_optint(l, 1, CM_FIRE);
cmode = aheatstate;
return 0;
}
+int luatpt_setfire(lua_State* l)
+{
+ int firesize = luaL_optint(l, 2, 4);
+ float fireintensity = (float)luaL_optnumber(l, 1, 1.0d);
+ prepare_alpha(firesize, fireintensity);
+ return 0;
+}
#endif