Wierd (?) problem.
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.
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
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 -
I''m not sure though. Its just a thought.
- An eye for an eye will make the world go blind -
<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>
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.

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.
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~
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~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement