Archived

This topic is now archived and is closed to further replies.

Cobra

Wierd (?) problem.

Recommended Posts

Cobra    122
Okay... this is an odd problem that''s probably very simple, and is only partially a problem (I can get it working, but only in THIS file.....). Now, I''ve made some test controls to move my camera around the world in my engine, and it works absolutely great so long as it''s in the same file as the winmain function (the function is called in winmain every frame before calling drawing loop). The problem here, is that I wanted to put the "do this when these keys are pressed" function as part of my input class, but as soon as I move it out of winmain, and make it CINPUT::CheckForKeyPresses(), it no-longer works. I know it''s not the code in the function itself (because it works... if I move it into my main file), but for some reason it really REALLY doesnt like calling it externally.

Share this post


Link to post
Share on other sites
Sander    1332
I don''t know how you check for key presses but it might have something to do with the window variables that are not linked to your external file (hWnd, hInstance, etc...)

I''m not sure though. Its just a thought.

- An eye for an eye will make the world go blind -

Share this post


Link to post
Share on other sites
RipTorn    722
If I''ve got this utterly wrong, please ignore me and go about your buisiness

looks like your accessing a static function. and not creating a input object (class''s are discriptions for objects, not actual data). Pretty simple really, but gets a lot of people (have you been trying to learn form a MFC book?)


eg:

somewhere in app, create the input object... Preferablly within an object controlling your app.
like:

CInput InputControl;


then later on, in the app,

InputControl.CheckForKeyPresses();

then...

if (InputControl.Keys[VK_WHATEVER])
doWhatNot();

or however you want to go about storing the data.

(I assume that inside the chekc for key presses funtion, you are simply running through lots of GetAsyncKeyState calls)

static fucntions (accessed with :: ) don''t need an object to be called, but cannot access anything that might normall be part of the object... they can only return a result, or edit data you might pass to it, via a pointer or such.


objects beat C functions hands down anyday. Imagine now making an extended input object to use Dirext Input and letting the app choose what to use at run time. A right bugger to do in C, very simple with objects.

Share this post


Link to post
Share on other sites
Cobra    122
That''s pretty much how I''ve done it.

Not a problem though, I just made a new function inside my main class, and call everything in from my CINPUT class to there.
Not a problem.

Thx for all your help anyway.

~Cobra~

Share this post


Link to post
Share on other sites