summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCracker64 <cracker642@gmail.com>2011-03-12 01:58:43 (GMT)
committer Cracker64 <cracker642@gmail.com>2011-03-12 01:58:43 (GMT)
commita3cc010aae7407c6e4600de691da876dc5c7b8fd (patch)
tree2a63c07ef61a0eeca27e5676584cef7d4df74baa
parent3b048f8a0634973e45703373d22bd9360a6c170c (diff)
downloadpowder-a3cc010aae7407c6e4600de691da876dc5c7b8fd.zip
powder-a3cc010aae7407c6e4600de691da876dc5c7b8fd.tar.gz
forgot some files, and a few fixes, set commands use 'setfrom' instead of 'from' as a keyword, wind brush fixes.
-rw-r--r--console_README45
-rw-r--r--getheader.py37
-rw-r--r--src/main.c20
3 files changed, 92 insertions, 10 deletions
diff --git a/console_README b/console_README
new file mode 100644
index 0000000..0171b2a
--- /dev/null
+++ b/console_README
@@ -0,0 +1,45 @@
+### CONSOLE ###
+the console in this version is a python console and will execute any command you enter.
+the api for interacting with the powder toy is contained in the tpt module and is already imported at startup.
+currently implemented api functions:
+ create(x,y,type) create a particle of type <type> at <x>,<y>
+ reset_velocity() resets all velocity
+ reset_pressure() resets all pressure
+ reset_sparks() resets all sparks
+
+### USING SET COMMANDS ###
+the console uses keywords to identify variables of what to set, you can specify x and y coords with x=100 y=100, ect.
+i is the particle number
+setfrom will change all of setfrom's type to the setto variable. It needs to be a string "dust" ect, "all" for all.
+the setto is what the particle(s) will be set to, it is a string for the type/ctype commands, and an int for the rest, there is a settoint for type and ctype command.
+you need to set the to* variable and one location/name/coords for it to work.
+ set_type(x=,y=,i=,setfrom="",setto="")
+ set_life()
+ set_temp()
+ set_tmp()
+ set_x()
+ set_y()
+ set_vx()
+ set_vy()
+ set_ctype()
+
+ pause() pause the game(note that closing the console
+ pauses the game)
+ unpause() unpause the game(note that closing the console
+ pauses the game)
+ toggle_pause() toggle pause(note that closing the console
+ pauses the game)
+ close_console() closes the console and pauses the game
+ open_console() opens the console
+ toggle_console() toggles the console
+
+NOTE: these functions don't do bounds checking, which means that they CAN AND
+ WILL CRASH the powder toy. be carefull.
+
+### TIPS&TRICKS ###
+all functions that need a particle type expect a number. but instead of doing
+tpt.set_life(32,life) you can do tpt.set_life(element['uran'],life)
+
+### COMPILING ###
+before you compile you should have python 2.x installed.
+you must run the "getheader.py" script to get the correct linking options, add these options to the makefile
diff --git a/getheader.py b/getheader.py
new file mode 100644
index 0000000..536915e
--- /dev/null
+++ b/getheader.py
@@ -0,0 +1,37 @@
+import sys
+import os.path
+import compileall
+path=os.path.join(sys.exec_prefix,"include","python%s"%sys.version[:3])
+#print "headers at ",repr(path)
+#-lpython2.3 -lm -L/usr/lib/python2.3/config
+args="-lpython%s -lm -L%s"%(sys.version[:3],os.path.join(sys.exec_prefix,"lib","python%s"%sys.version[:3],"config"))
+print " linux args are"
+print args,"-I%s"%path
+
+path=os.path.join(sys.exec_prefix,"include")
+args="-lpython%s -lm -L%s"%(sys.version[:3],os.path.join(sys.exec_prefix,"lib","config"))#,"python%s"%sys.version[:3]
+print "\n windows args are"
+print args,"-I%s"%path
+
+#unsigned char tpt_console_pyc[] = { 0x1B, 0x57};
+lst=[]
+compileall.compile_dir("./src/python", force=1)
+
+print "generating pyconsole.h"
+
+fname="./src/python/tpt_console.pyc"
+try:
+ fid=open(fname,"r")
+except IOError:
+ fname="./src/python/tpt_console.pyo"
+finally:
+ fid.close()
+
+with open(fname,"r") as fid:
+ for char in fid.read():
+ lst.append(hex(ord(char)))
+tmp=",".join(lst)
+out=''.join(["#include <Python.h>\nunsigned char tpt_console_pyc[] = {",tmp,"};"])
+with open("./includes/pyconsole.h","w") as fid:
+ fid.write(out)
+print "done"
diff --git a/src/main.c b/src/main.c
index 2323b97..c94bd18 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1357,7 +1357,7 @@ emb_set_life(PyObject *self, PyObject *args, PyObject *keywds)
{
int i = -1,life,j,x=-1,y=-1;
char *name = "";
- char *kwlist[] = {"setto", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
return NULL;
//
@@ -1398,7 +1398,7 @@ emb_set_type(PyObject *self, PyObject *args, PyObject *keywds)
int i = -1,life,j=-1,x=-1,y=-1;
char *name = "";
char *type = "";
- char *kwlist[] = {"setto", "settoint", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type,&life,&name,&i,&x,&y))
return NULL;
//
@@ -1439,7 +1439,7 @@ emb_set_temp(PyObject *self, PyObject *args, PyObject *keywds)
{
int i = -1,life,j,x=-1,y=-1;
char *name = "";
- char *kwlist[] = {"setto", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
return NULL;
//
@@ -1479,7 +1479,7 @@ emb_set_tmp(PyObject *self, PyObject *args, PyObject *keywds)
{
int i = -1,life,j,x=-1,y=-1;
char *name = "";
- char *kwlist[] = {"setto", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
return NULL;
//
@@ -1520,7 +1520,7 @@ emb_set_x(PyObject *self, PyObject *args, PyObject *keywds)
int i = -1,life,j,x=-1,y=-1;
char *name = "";
char *type = "";
- char *kwlist[] = {"setto", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
return NULL;
//
@@ -1560,7 +1560,7 @@ emb_set_y(PyObject *self, PyObject *args, PyObject *keywds)
{
int i = -1,life,j,x=-1,y=-1;
char *name = "";
- char *kwlist[] = {"setto", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
return NULL;
//
@@ -1601,7 +1601,7 @@ emb_set_ctype(PyObject *self, PyObject *args, PyObject *keywds)
int i = -1,life,j,x=-1,y=-1;
char *name = "";
char *type = "";
- char *kwlist[] = {"setto", "toctypeint", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "toctypeint", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "s|IsIII:set_type",kwlist ,&type, &life, &name,&i,&x,&y))
return NULL;
//
@@ -1643,7 +1643,7 @@ emb_set_vx(PyObject *self, PyObject *args, PyObject *keywds)
{
int i = -1,life,j,x=-1,y=-1;
char *name = "";
- char *kwlist[] = {"setto", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
return NULL;
//
@@ -1683,7 +1683,7 @@ emb_set_vy(PyObject *self, PyObject *args, PyObject *keywds)
{
int i = -1,life,j,x=-1,y=-1;
char *name = "";
- char *kwlist[] = {"setto", "from", "i", "x", "y", NULL};
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
return NULL;
//
@@ -3245,7 +3245,7 @@ int main(int argc, char *argv[])
{
for (j=-bsy; j<=bsy; j++)
for (i=-bsx; i<=bsx; i++)
- if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(bsx,2))+(pow(j,2))/(pow(bsy,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=bsy*bsx))
+ if (x+i>0 && y+j>0 && x+i<XRES && y+j<YRES && ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(bsx,2))+(pow(j,2))/(pow(bsy,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=bsy*bsx)))
{
vx[(y+j)/CELL][(x+i)/CELL] += (x-lx)*0.01f;
vy[(y+j)/CELL][(x+i)/CELL] += (y-ly)*0.01f;