Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: What's the best way to...

  1. #1
    Join Date
    Jul 2010
    Washington, USA
    Thanked 43 Times in 39 Posts

    Default What's the best way to...

    What's the best way to structure KB/M input in a game. I currently have it when the users clicks the X and Y coords are saved in the mouseListener class. Every update the game loop asks the mouseListener class for the X and Y data. the main loop then sends the X and Y data to the GUI/drawing class. I do the same with the keyboard.

    I don't know why, but i feel like I'm structuring my game incorrectly. (not the most efficient way) Is this method efficient. If not, what would be more efficient?

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: What's the best way to...

    Take a look at the MVC design (Model-View-Controller). If you search the web most explanations will probably revolve around web application design, but the principle still applies (many swing components use the MVC design). From what you describe it seems your approach is a bit similar. IMO design is relative, there is always more than one solution, and there typically isn't a perfect solution. Long story short, without looking at the full UML layout, I'd guess your design is plenty efficient