[gameprogrammer] Re: engine design, question 2
- From: Josh Stewart <aek@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Tue, 21 Feb 2006 23:43:49 +0800
Roger D Vargas wrote:
After studying game engines API and a game programming book I have
noticed that all uses a separate Input class. Why should I use one
instead of processing the events in the main loop via sdl event
management functions? The only reason that comes to my mind is to
isolate event management from the game logic and so be able to switch
event handling library or something like that.
You have a separate input class to encapsulate that behaviour in a
single object. As you said, you could then switch input handling
libraries more easily, as all of the input handling code is in one place.
Also it would allow you to create a simple wrapper / facade for your
application to use, to hide the complexities of whatever input handling
libraries are used.
You may also hide away input handling of different devices
(joystick/keyboard/mouse), using a generic interface which doesnt need
to know what input function it is dealing with. In the game loop, it
shouldnt matter if the user pressed Button 3 on the joystick or x on the
keyboard.. as long as the action is registered and it changes the state
of the game somehow. An input handler class might do this for us.
If the concerns are separated properly, your code will be more
maintainable and extensible hopefully.
Josh
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] engine design, question 2
- From: Roger D Vargas
Other related posts:
- » [gameprogrammer] engine design, question 2
- » [gameprogrammer] Re: engine design, question 2
- » [gameprogrammer] Re: engine design, question 2
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- [gameprogrammer] engine design, question 2
- From: Roger D Vargas