Jump to content
  • Advertisement
  • entries
    707
  • comments
    1173
  • views
    435841

Update

Sign in to follow this  
Programmer16

106 views

Ok, I've been working away on the game, and I've gotten the basics set up. I eliminated 90% of the GUI, leaving only the button (since its all that I need.)

I have the state system hacked together, and everything seems to be working pretty nicely.

Edit: Oh, and disregard the list at the top of my journal, its probably going to be redone at the end of the month.

On a side note, I finished my input system just now. Its based on DirectInput. I chose DI because my system turned out a lot neater with it along with a few other reasons. First of all, my mousewheel code works for DI (my Win32 version did not.) In the event based mode, I have everything working fine, including repeated character input.

Pretty simple to use:

#include
#include "dftInput.h"

LRESULT CALLBACK WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam);
HWND g_hWnd;
dft::Input g_Input;

void EventProc(dft::InputEvent Event)
{
static char szText[256] = {0};
static int nIndex = 0;

if(Event.m_nMessage == dft::IM_CHAR)
{
szText[nIndex++] = dft::KeyIdToChar(Event.m_ucKey, g_Input.KeyDown(dft::IK_LSHIFT) || g_Input.KeyDown(dft::IK_RSHIFT));
if(nIndex > 254)
nIndex = 254;
}
SetWindowText(g_hWnd, szText);
}

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
WNDCLASS WndClass;
ZeroMemory(&WndClass, sizeof(WNDCLASS));
WndClass.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
WndClass.hCursor = LoadCursor(0, IDC_ARROW);
WndClass.hIcon = LoadIcon(0, IDI_APPLICATION);
WndClass.hInstance = GetModuleHandle(0);
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = "Screwin Around";
RegisterClass(&WndClass);

g_hWnd = CreateWindowEx(0, WndClass.lpszClassName, WndClass.lpszClassName, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 800, 600, 0, 0, GetModuleHandle(0), 0);

g_Input.Create(g_hWnd);
g_Input.SetEventProc(EventProc);

MSG Msg;
ZeroMemory(&Msg, sizeof(MSG));
while(1)
{
if(PeekMessage(&Msg, 0, 0, 0, PM_REMOVE))
{
if(Msg.message == WM_QUIT)
break;

TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
else
g_Input.Update();
}
return 0;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
if(nMsg == WM_DESTROY)
{
DestroyWindow(hWnd);
PostQuitMessage(0);
return 0;
}

return DefWindowProc(hWnd, nMsg, wParam, lParam);
}







This is my sample application that uses dftInput to allow the user to type text into the window's title. dftInput will be released with the rest of DragonForge Technology.

The system includes several helper functions:

// True if A-Z key
bool KeyIsChar(int nKeyID);

// True if the key is a special key character(':', ';', '"', etc)
// Counts tab, backspace, and enter
// Does not count space
bool KeyIsSpecialChar(int nKeyID);

// True if 0-9 (regular or number pad) key
bool KeyIsNumeric(int nKeyID);

// Same as KeyIsChar(nKeyID) && KeyIsNumeric(nKeyID)
bool KeyIsAlphaNumeric(int nKeyID);

// Same as KeyIsAlphaNumeric(nKeyID)&& KeyIsSpecialChar(nKeyID)
// Does not count tab, backspace, or newline
bool KeyIsText(int nKeyID);

// KeyIsChar, KeyIsAlphaNumeric, and KeyIsText all count space

// Returns the character for a key if possible
char KeyIdToChar(int nKeyID, bool bShift);


Edit 2: Oops, I wasn't finished. I had to add a special case to repeat the special characters tab, backspace, and newline.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!