Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 44701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:41:36+00:00 2026-05-10T15:41:36+00:00

Should I push keypresses to vehicles when they’re pressed, or should vehicles pull keys

  • 0

Should I push keypresses to vehicles when they’re pressed, or should vehicles pull keys pressed from the engine?

I have a vehicle object, which has location, velocity and accelleration members (among other things) and an update method, during which it updates its location based on its velocity, and its vevlocity based on its accelleration.

I have a game object which contains the game loop, which calls the update method on the vehicle.

If the player controls the vehicle with the arrow keys, should a keypress set the accelleration (push) and a key-release clear the velocity, or should the vehicle ask the game-engine if the accellerate key is pressed (pull)? I think a push would mean that the keyboard control module would need to know about vehicles, whereas pull would mean a vehicle needs to know specific keyboard controls.

I think a related question would be something like: should all objects know about all other objects, or should there be a strict hierarchy, so objects can ask things / tell things to other objects up the tree, but not down (or vice-versa)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:41:36+00:00Added an answer on May 10, 2026 at 3:41 pm

    You should try and follow an Subscribing/Observer pattern. You put all the key capture code into one singleton InputManager and then each object that requires reaction to input registers with the manager.

    The manager holds the list of subscribed objects and sends events to them when the keys are pressed/depressed. Just don’t forget to unsubscribe when the object is deleted or ‘loses focus’.

    This avoids the polling problem. There are very few exceptions where a polling solution is desirable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer List comprehensions. In Python they look something like: a =… May 11, 2026 at 12:16 pm
  • added an answer Aha! I had an old version of the Python readline… May 11, 2026 at 12:15 pm
  • added an answer I don't think that a SHA algorithm could be optimized… May 11, 2026 at 12:15 pm

Related Questions

Should I push keypresses to vehicles when they're pressed, or should vehicles pull keys
Should I start with Django or JavaScript?
Should I still be using tables anyway? The table code I'd be replacing is:
Should I use Named Pipes, or .NET Remoting to communicate with a running process
Should I catch exceptions for logging purposes? public foo(..) { try { ... }
Should I stick with Sun's Java code conventions for PHP code?
Should I keep project filesm like Eclipse's .project, .classpath, .settings, under version control (e.g.
Should I try to actually upgrade my existing app, or just rewrite it mostly
Should I learn NHaml ? What does it provide me over a classic ASP.NET
Should I create two CFile objects and copy one into the other character by

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.