Jump to content
  • Advertisement

Archived

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

d000hg

Getting stuff inside

This topic is 5916 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I get the message handler in windows to know about the classes being used. e.g if I get a WM_KEYDOWN message how do I call Object.MoveRight(); Currently I have some global vars which tell what''s happened since last render loop wrt messages, and acts on tthem. But there must be a better way? I don''t want to use global vars really, but It''ll be like the game class or engine class that needs informing, so there may well only be one of the object available. If I have a singleton, does that make things easier? John 3:16

Share this post


Link to post
Share on other sites
Advertisement
If possible, use DirectInput. Otherwise, the most straightforward way would be to do this:



  
//some .h file

extern bool keys[256];

//some msg handling func

switch(msg)
{
case WM_KEYDOWN:
keys[wParam] = true;
break;
case WM_KEYUP:
keys[wParam] = false;
break;
}

FOR_EACH_OF_YOUR_OBJECTS
Object[i]->Move();



Since keys is global, you can access it from anywhere.

If you''re usign glut - go for the glut input handling calls.

Hope this helps,
Crispy

Share this post


Link to post
Share on other sites
PS - if you want to completely lose globals, I''d say that''s pretty much impossible. You will need somekind of global variable to coordinate stuff in different files. Or am I missing your point here?

Crispy

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!