Exemplo n.º 1
0
	bool InitialiseFramework( PyObject* a_pModule )
	{
		bool bSuccess = false;
		PyObject* pInitialise = GetHandleToPythonFunction( a_pModule, "PyInitialise" );
		if( pInitialise )
		{
			PyObject* pReturnValue = CallPythonFunction( pInitialise, nullptr );
			if( pReturnValue )
			{
				int iWidth; int iHeight; bool bFullscreen; char* windowTitle;

				if (!PyArg_ParseTuple(pReturnValue, "iibs", &iWidth, &iHeight, &bFullscreen, &windowTitle)) 
				{
					ParsePyTupleError( __func__, __LINE__ );
				}
				Py_DECREF(pReturnValue);

				int titleLength = strlen(windowTitle);
				g_pWindowTitle = new char[titleLength+1];
				memcpy(g_pWindowTitle, windowTitle, titleLength);
				g_pWindowTitle[titleLength] = '\0';
				bSuccess = ( Initialise( iWidth, iHeight, bFullscreen, g_pWindowTitle) == 0 );
			}
			Py_XDECREF(pInitialise);
			
		}
		return bSuccess;
	}
bool LMF_CallPythonFunction(PyObject* a_pModule, char* cs_FunctionName){
	bool bSuccess = false;
	PyObject* pFunction = GetHandleToPythonFunction( a_pModule, cs_FunctionName);
	if( pFunction ){
		PyObject* pReturnValue = CallPythonFunction( pFunction, nullptr );
		if( pReturnValue ){
			bSuccess = true;
		}
		Py_XDECREF(pFunction);	
	}
	return bSuccess;
}
Exemplo n.º 3
0
	void ShutdownFramework( PyObject* a_pModule )
	{
		PyObject* pShutdownFunc = GetHandleToPythonFunction( a_pModule, "PyShutdown" );
		if (pShutdownFunc) 
		{
			PyObject* pReturnValue = CallPythonFunction( pShutdownFunc, nullptr );
			if( pReturnValue )
			{
				printf("We have reached the end of the Game! Arguments returned from call: %ld\n", PyInt_AsLong(pReturnValue));
				Py_DECREF(pReturnValue);
			}
			Py_XDECREF(pShutdownFunc);
		}
		Shutdown();
	}
Exemplo n.º 4
0
	void UpdatePython( PyObject* a_pModule, float a_fDeltaTime )
	{
		PyObject* pUpdateFunc = GetHandleToPythonFunction( a_pModule, "PyUpdate" );
		if (pUpdateFunc) 
		{
			PyObject* pDeltaTime = PyFloat_FromDouble( a_fDeltaTime );
			PyObject* pArgs = PyTuple_New(1);
			PyTuple_SetItem( pArgs, 0, pDeltaTime );
			PyObject* pReturnValue = CallPythonFunction( pUpdateFunc, pArgs );
			if( pReturnValue )
			{
				//std::cout << "Updating Python Game Loop" << std::endl;
				Py_DECREF(pReturnValue);
			}
			Py_XDECREF(pUpdateFunc);
		}  
	}
Exemplo n.º 5
0
	void Load( PyObject* a_pModule )
	{
		//"./images/crate_sideup.png", 64.0, 64.0, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 255, 255, 255, 255
		float fv2Size[2] = { 64.f, 64.f };
		float fv2Origin[2] = { 0.5f, 0.5f };
		float fv4UVCoords[4] = { 0.f, 0.f, 1.f, 1.f };
		float vColour[4] = { 1.f, 1.f, 1.f, 1.f };

		unsigned int uiSpriteID = CreateSprite( "./images/crate_sideup.png", fv2Size, fv2Origin, fv4UVCoords, SColour(vColour[0]/255, vColour[1]/255, vColour[2]/255, vColour[3]/255) );
	
		PyObject* pLoad = GetHandleToPythonFunction( a_pModule, "PyLoad" );
		if( pLoad )
		{
			PyObject* pReturnValue = CallPythonFunction( pLoad, nullptr );
			if( pReturnValue )
			{
				Py_DECREF(pReturnValue);
			}
			Py_XDECREF(pLoad);
			
		}
	}