I'm having a first look at physics and in doing so, I'm mashing the 08_physics.c project into the standalone project.
Took a bit to get everything compiling as it's been a while since I needed to start anything from scratch. But I finally got it running and physics working.
Now the problem; whenever the physics EventHandler runs, the routine tries to add some FX to the sender and recipient objects, the code crashes because both are null:
orxSTATUS orxFASTCALL EventHandler(const orxEVENT *_pstEvent)
/* Is a new contact? */
if(_pstEvent->eID == orxPHYSICS_EVENT_CONTACT_ADD)
orxOBJECT *pstObject1, *pstObject2;
/* Gets colliding objects */
pstObject1 = orxOBJECT(_pstEvent->hRecipient);
pstObject2 = orxOBJECT(_pstEvent->hSender);
/* Adds bump FX on both objects */
orxObject_AddFX(pstObject1, "Bump"); //crash
/* Done! */
The physics are working, the boxes are bouncing off each other. Can't understand why the recipient and sender objects are always null.
I realise something I have defined is causing the issue. Rather than flood this post with realms of code and ini, is there a specific section I should provide first?
Of course afterwards, I found Grey's tutorial on mashing these projects and I have been through it but I'd rather know what causes this than start again with the tutorial.
There are two reasons I can think of that would produce this kind of issue:
- EventHandler is register to handle other types of events in addition to physics and as the type of event isn't checked, the ID might match another ID for another type of event that doesn't have any payload
- the include files are not in sync with the libraries you're using, which mean that the type of event might not be the same value inside orx and for you, resulting in the same kind of mismatch mentioned above
If you have the whole source file it' ll be easier to diagnose if one of these two options is actually what's happening.
However, it is very likely the second point where I would say my mashing of files has caused it, and my libs and includes are likely to be mismatched. Think I am best to start over with a clean solution.
Thank you as usual!
Pretty dumb I know :cheer: :huh:
Also, any reason why you don't use the latest/svn version of orx instead? Things have changed so much the 1.3rc0!
It was mainly because I had a spare lunchtime at work and I downloaded the svn version from there. However I have VS2010 Ultimate and there was no pre-built orx.dll or orxd.dll.
The solutions loaded ok in vs2010 but they're still not configured 100% to compile all the necessary things out of the box.
So I didn't want to spend my entire lunch just getting the setup working.
But maybe that's something I can get working and commit back to svn. I feel more comfortable with it these days.
The pictures are since missing (404s) but I re-wrote the missing bits so they don't rely on the images.
At the end of the tutorial, I've provided an entry point to Grey's Tutorial 1 where Quick and Dirty SVN + VS2010 users should go.