So, given that no one wanted to tackle the last post (and I don't blame you either-- it was a doozie!)... I decided I'd try to simplify things a bit, and stick to one file-- after all, I'm still learning the basics of DirectX 9 here...

Again, I'm getting compile errors... Is anyone willing to take a stab at this (or be willing to refer me to someone/somehere who might know)?? It's driving me absolutely nuts, and I have no idea where to go now...

Thanks!

-Maxthecat

Compile Errors (MS VS 6):
C:\Program Files\Microsoft Visual Studio\MyProjects\d3dspriter\spritetest.cpp(15) : error C2146: syntax error : missing ';' before identifier 'sprite'
C:\Program Files\Microsoft Visual Studio\MyProjects\d3dspriter\spritetest.cpp(15) : error C2501: 'LP3DXSPRITE' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\d3dspriter\spritetest.cpp(15) : fatal error C1004: unexpected end of file found

Code:
#include <d3d9.h>
#include <d3dx9.h>
#include <d3dx9core.h>
#include <dinput.h>
#include <windows.h>

LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DSURFACE9 backbuffer;


//LPDIRECTSURFACE9 back;
LPDIRECTINPUT8 dinput;
LPDIRECTINPUTDEVICE8 dikeyboard;
LP3DXSPRITE sprite;
LPDIRECT3DTEXTURE9 texture;
char keys[256];

int Init_Direct3D(HWND);
int Key_Down(int key);
void Poll_Keyboard();
int Game_Init(HWND);
void Game_Run(HWND);
//void Game_End(HWND);

typedef struct {
	int x, y;
	int width, height;
	int movex, movey;
} SPRITE;

SPRITE kitty;

void Game_Run(HWND hwnd)
{
	if (d3ddev == NULL)
		return;

	Poll_Keyboard();
	if (Key_Down(DIK_LEFT)
		kitty.x -= kitty.movex;
	
	if (Key_Down(DIK_RIGHT)
		kitty.x -= kitty.movey;
	
	if (Key_Down(DIK_ESCAPE)
	{
		PostMessage(hwnd, WM_DESTROY, 0, 0);
	}

	if (d3ddev->BeginScene())
	{
		d3ddev->ColorFill(backbuffer, NULL, D3DCOLOR_XRGB(0,0,0));
		D3DXVECTOR3 position((float)kitty.x, (float)kitty.y, 0);
		sprite->Draw(
			texture,
			NULL,
			NULL,
			NULL,
			0,
			position,
			D3DCOLOR_XRGB(255,255,255);
		sprite->End();
		d3dev->EndScene();
	}
}

int Game_Init(HWND hwnd)
{
	D3DXIMAGE_INFO d3dxImageInfo;

	D3DXCreateTextureFromFileEx( d3ddev,
                                 "cat.bmp",
                                 96, // I had to set width manually. D3DPOOL_DEFAULT works for textures but causes problems for D3DXSPRITE.
                                 96, // I had to set height manually. D3DPOOL_DEFAULT works for textures but causes problems for D3DXSPRITE.
                                 1,   // Don't create mip-maps when you plan on using D3DXSPRITE. It throws off the pixel math for sprite animation.
                                 D3DPOOL_DEFAULT,
                                 D3DFMT_UNKNOWN,
                                 D3DPOOL_DEFAULT,
                                 D3DX_DEFAULT,
                                 D3DX_DEFAULT,
                                 D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f),
                                 &d3dxImageInfo,
                                 NULL,
                                 &texture );

	D3DXCreateSprite( sprite, &texture);
	
	kitty.x = 100;
	kitty.y = 150;
	kitty.width = 96;
	kitty.height = 96;
	kitty.movex = 8;
	kitty.movey = 0;

	return 1;
}

int Key_Down(int key);
{
	return (keys[key] & 0x80);
}

void Poll_Keyboard()
{
	dikeyboard->GetDeviceState(sizeof(keys), (LPVOID)&keys);
}

int Init_Direct3D(HWND hwnd)
{
	HRESULT result;

	d3d = Direct3DCreate9(D3D_SDK_VERSION);
	if (d3d == NULL)
	{
		MessageBox(hwnd, "Error Initializing D3D", "Error", MB_OK);
		return 0;
	}

	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(d3dpp));

	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;
	d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
	d3dpp.BackBufferCount = 1;
	d3dpp.BackBufferWidth = 640;
	d3dpp.BackBufferHeight = 480;
	d3dpp.hDeviceWindow = hwnd;
	d3dpp.EnableAutoDepthStencil = TRUE;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	d3d->CreateDevice(
		D3DADAPTER_DEFAULT,
		D3DDEVTYPE_HAL,
		hwnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp,
		&d3ddev);

	if (d3ddev == NULL)
	{
		MessageBox(hwnd, "Failed to init d3ddev", "Error!!", MB_OK);
		return 0;
	}

	d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
	d3ddev->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO, &backbuffer);
	
	//graphics initlaized... Now for the keyboard!

	result = DirectInput8Create(
		GetModuleHandle(NULL),
		DIRECTINPUT_VERSION,
		IID_IDirectInput8,
		(void**)&dinput,
		NULL);

	if (result != DI_OK)
		return 0;

	result = dinput->CreateDevice(GUID_SysKeyboard, &dikeyboard, NULL);
	if (result != DI_OK)
		return 0;

	result = dikeyboard->SetDataFormat(&c_dfDIKeyboard);
	if (result != DI_OK)
		return 0;

	result = dikeyboard->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
	if (result != DI_OK)
		return 0;

	result = dikeyboard->Acquire();
	if (result != DI_OK)
		return 0;

	return 1;
}



LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_DESTROY:
		if (d3ddev != NULL)
			d3ddev->Release();

		if (d3d != NULL)
			d3d->Release();

		if (dikeyboard != NULL)
		{
			dikeybaord->Unacquire();
			dikeyboard->Release();
			dikeyboard = NULL;
		}

		if (backbuffer != NULL)
			backbuffer->Release();

		if (sprite != NULL)
			sprite->Release();

		if (texture != NULL)
			texture->Release();

		/*if (dinput != NULL)
			dinput->Release();       <------is this needed????*/
	
		//Game_End(hWnd);
		
		PostQuitMessage(0);
	}
	return DefWindowProc(hWnd, msg, wParam, lParam);
}

ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wc;
	wc.cbSize = sizeof(WNDCLASSEX);

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = (WNDPROC)WinProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = NULL;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "2D Sprite Test...";
	wc.hIconSm = NULL;

	return RegisterClassEx(&wc);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	MSG msg;
	HWND hWnd;

	MyRegisterClass(hInstance);

	hWnd = CreateWindow(
			"2D Sprite Test...",
			"2D Sprite Test...",
			WS_OVERLAPPED,
			CW_USEDEFAULT,
			CW_USEDEFAULT,
			640,
			480,
			NULL,
			NULL,
			hInstance,
			NULL);

	if (!hWnd)
		return FALSE;

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

	if (!Init_Direct3D(hWnd))
		return 0;

	if (!Game_Init(hWnd))
	{
		MessageBox(hWnd, "Error Initializing Game", "Error ..........!", MB_OK);
		return 0;
	}
	
	int done = 0;
	while (!done)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
				done = 1;

			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
			Game_Run(hWnd);
	}
	
	return msg.wParam;
}