File: ac.h

package info (click to toggle)
balder2d 1.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,552 kB
  • ctags: 1,226
  • sloc: cpp: 8,623; xml: 398; python: 364; ansic: 214; makefile: 79; sh: 9
file content (29 lines) | stat: -rw-r--r-- 1,067 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "../../../include/input.h"


static PyMethodDef BalderAIMethods[] = {
    {NULL, NULL, 0, NULL}        /* Sentinel */
};

class ArtificialController{
public:
    static void Initialize(){
        Py_InitializeEx(0);
        // set up the python environment to find the scrpits
        PyRun_SimpleString("import sys\n");
        PyRun_SimpleString("sys.path.append('scripts')\n");
        PyObject *balder_module = Py_InitModule("balder", BalderAIMethods);
        PyModule_AddIntConstant(balder_module, "INPUT_LEFT", Balder::LEFT);
        PyModule_AddIntConstant(balder_module, "INPUT_RIGHT", Balder::RIGHT);
        PyModule_AddIntConstant(balder_module, "INPUT_STICK", Balder::STICK);
        PyModule_AddIntConstant(balder_module, "INPUT_FIRE", Balder::FIRE);
    }
    static void ShutDown(){
        Py_Finalize();
    }

    #ifdef Py_PYTHON_H  // so gamemanager doesn't see this python related stuff
    static PyObject* py_IsWall(PyObject *self, PyObject *args);
    static PyObject* py_IsLineOfSight(PyObject *self, PyObject *args);
    #endif
};