Update

posted in Beals Software
Published April 09, 2006
Advertisement
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 keybool KeyIsChar(int nKeyID);// True if the key is a special key character(':', ';', '"', etc)// Counts tab, backspace, and enter// Does not count spacebool KeyIsSpecialChar(int nKeyID);// True if 0-9 (regular or number pad) keybool 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 newlinebool KeyIsText(int nKeyID);// KeyIsChar, KeyIsAlphaNumeric, and KeyIsText all count space// Returns the character for a key if possiblechar 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.
Previous Entry I lied...
Next Entry Update
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement