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 8448645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:29:03+00:00 2026-06-10T10:29:03+00:00

So my basic 2d game framework in SlimDX is going well. I’ve created a

  • 0

So my basic 2d game framework in SlimDX is going well. I’ve created a custom Sprite object, and have some rudimentary mastery of rendering sprites. I just need to move them now.

I have a basic game loop set up, which is based on an old C# game programming book. Having set up all the graphics device bits and bobs, and drawn my sprite on screen, I enter a method in my Game class called Run(). This has the following content:

public void Run()
{

    while( this.Created )
    {
        // Process one frame of the game
        ProcessFrame();
        Render();
        // Handle all events
        Application.DoEvents();
    }
}

ProcessFrame() is supposed to have all the game logic in it, in response to events. Whilst I have a simple event handler (based on an override of OnKeyDown) set up to detect keypresses, I’m wondering how to collect keypresses such that I can process the responses to them in the ProcessFrame() method.

Some initial research on this subject suggests creating a HashSet<Keys>. I’ve never done this before, so I’m not sure how I would go about it.

There are probably many ways to do this, so I thought I’d see what people would recommend before jumping right in there.

Thanks in advance everyone.

  • 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. Editorial Team
    Editorial Team
    2026-06-10T10:29:05+00:00Added an answer on June 10, 2026 at 10:29 am

    I don’t believe you need to manually capture inputs. This typically would be handled by the direct input keyboard class. I personally have not used SlimDX myself yet but as it is a wrapper for DirectX (which I’ve dabbled in) you should just need to initialize a variable to hold the reference to the keyboard so that you can poll it for changes, and then act upon those changes.

    http://slimdx.org/docs/#T_SlimDX_DirectInput_Keyboard

    Such that you would code something like

    if (myKeyboard.IsKeyDown(Keys.Escape)) { ProgramStatus = GameState.Title; }

    assuming my reference variable was called myKeyboard.

    Edit:
    I might also mention that depending on the particular library your using that it can be beneficial to save current, and previous keyboard states. This is very useful when you want to ensure that the program only takes in one keystroke vs many.

    XNA as I recall has a KEYDOWN method for controllers, useful to test if the button is being held down. If you need to take in a input for each time the button is hit capture both.
    IE if your library has a Keypress method, your good, if it captures KEYDOWN only you may need to capture current and previous.

     if (myMouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released) 
    

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

Sidebar

Related Questions

Consider I have a game-creation framework, with a basic class called Game. // Action
If I have some basic game loop in a thread, like this: public void
So, i have a basic game scenerario: Some unit moves close to an enemy
I am making a basic platform game for the iPhone and I have encountered
I am making a basic little game in Java and I want to have
I have been developing a game basic card game for Android. At the moment
My current class is planning on creating a basic networked game, but we have
I have coded a basic game in JavaScript and am working on a high
I'm working on a very basic game and I have a std::list collection of
So I'm creating a very basic python game and I need some help with

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.