Click here to Skip to main content
15,922,894 members
Home / Discussions / C#
   

C#

 
GeneralRe: Import data Pin
Nick Parker20-Nov-04 5:07
protectorNick Parker20-Nov-04 5:07 
GeneralRe: Import data Pin
bouli20-Nov-04 5:08
bouli20-Nov-04 5:08 
GeneralRe: Import data Pin
Heath Stewart19-Nov-04 10:13
protectorHeath Stewart19-Nov-04 10:13 
Generalenum Questions Pin
niceguyeddie19-Nov-04 6:31
niceguyeddie19-Nov-04 6:31 
GeneralRe: enum Questions Pin
Daniel Turini19-Nov-04 6:55
Daniel Turini19-Nov-04 6:55 
GeneralRe: enum Questions Pin
Dennis C. Dietrich19-Nov-04 6:59
Dennis C. Dietrich19-Nov-04 6:59 
GeneralRe: enum Questions Pin
niceguyeddie19-Nov-04 7:25
niceguyeddie19-Nov-04 7:25 
GeneralRe: enum Questions Pin
Heath Stewart19-Nov-04 8:12
protectorHeath Stewart19-Nov-04 8:12 
On a different note (since your question was accurately answered) you should consider not hard-coding certain keys. Many people agree that a good game allows for key mapping, and - in a basic capacity - it's not that hard to add.

Lets say you host your game in a Form (this is typically the came even with Managed DirectX). There is a method you can override (actually several) named ProcessDialogKey. You would also keep a key map of what keys map to which actions. One way would be to use the hash table and an enumeration (like you already have) of Keys to Actions (assuming Actions is your action enumeration), which you could persist in a file, database, etc.

Take the following example (doesn't include persistence):
protected override bool ProcessDialogKey(Keys keyData)
{
  if (keyMap.ContainsKey(keyData))
  {
    Action a = (Action)keyMap[keyData];
    switch (a)
    {
      case Action.Shoot:
        Shoot();
        break;
      case Action.Duck;
        Duck();
        break;
      // ...
    }
    return true;
  }
  return false;
}
Depending on how your game's Form is set up, you may also need to set the Form's KeyPreview property to true to make sure that the form processes the keys before its child controls do.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: enum Questions Pin
Daniel Turini20-Nov-04 5:47
Daniel Turini20-Nov-04 5:47 
GeneralRe: enum Questions Pin
niceguyeddie22-Nov-04 6:22
niceguyeddie22-Nov-04 6:22 
GeneralRe: enum Questions Pin
Daniel Turini22-Nov-04 6:24
Daniel Turini22-Nov-04 6:24 
Generalpicturebox and imagelist in C# Pin
youssef19-Nov-04 4:44
youssef19-Nov-04 4:44 
GeneralRe: picturebox and imagelist in C# Pin
Heath Stewart19-Nov-04 8:13
protectorHeath Stewart19-Nov-04 8:13 
GeneralRe: picturebox and imagelist in C# Pin
youssef19-Nov-04 8:37
youssef19-Nov-04 8:37 
GeneralRasAPI in C# - connecting after failure Pin
Roland Bär19-Nov-04 3:16
Roland Bär19-Nov-04 3:16 
GeneralRe: RasAPI in C# - connecting after failure Pin
Daniel Turini19-Nov-04 6:53
Daniel Turini19-Nov-04 6:53 
GeneralRe: RasAPI in C# - connecting after failure Pin
Roland Bär21-Nov-04 23:25
Roland Bär21-Nov-04 23:25 
GeneralWindows Service and Sql Server Pin
Anonymous19-Nov-04 2:41
Anonymous19-Nov-04 2:41 
GeneralRe: Windows Service and Sql Server Pin
Dennis C. Dietrich19-Nov-04 3:15
Dennis C. Dietrich19-Nov-04 3:15 
GeneralRe: Windows Service and Sql Server Pin
Daniel Turini19-Nov-04 6:49
Daniel Turini19-Nov-04 6:49 
GeneralRe: Windows Service and Sql Server Pin
Steven Campbell19-Nov-04 7:37
Steven Campbell19-Nov-04 7:37 
GeneralRe: Windows Service and Sql Server Pin
Anonymous19-Nov-04 19:13
Anonymous19-Nov-04 19:13 
GeneralRe: Windows Service and Sql Server Pin
Dennis C. Dietrich20-Nov-04 3:43
Dennis C. Dietrich20-Nov-04 3:43 
GeneralRe: Windows Service and Sql Server Pin
Zishan Haider22-Nov-04 0:07
Zishan Haider22-Nov-04 0:07 
GeneralPrinting Graphics Pin
rognog19-Nov-04 1:33
rognog19-Nov-04 1:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.