Code:
#include <windows.h>
#include <tchar.h>
#include "resource.h"
#include <conio.h>
#include <windowsx.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <iostream.h>
//GLOBALS//////////////////////////////////////
int picx=0;
int picy=0;
int picsizex=100;
int picsizey=100;
///////////////////////////////////////////////
TCHAR szBitmapFilename[MAX_PATH];
HBITMAP hBitmap;
LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
if(GetAsyncKeyState(VK_RIGHT))
{
hDC = BeginPaint(hWnd, &ps);
hBitmap = (HBITMAP)LoadImage(NULL, "C:\\Visual C++\\Game\\none.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
DrawState(hDC, NULL, NULL, (LPARAM)hBitmap, 0, picx, picy, picsizex, picsizey, DST_BITMAP | DSS_NORMAL);
hBitmap = (HBITMAP)LoadImage(NULL, "C:\\Visual C++\\Game\\guy.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
picx++;
DrawState(hDC, NULL, NULL, (LPARAM)hBitmap, 0, picx, picy, picsizex, picsizey, DST_BITMAP | DSS_NORMAL);
EndPaint(hWnd, &ps);
}
switch (uMsg)
{
case WM_PAINT:
{
return 0;
}break;
case WM_CLOSE:
PostQuitMessage(0);
DestroyWindow(hWnd);
return 0;break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
void RegisterWindowClass()
{
WNDCLASSEX wcx;
ZeroMemory(&wcx, sizeof(WNDCLASSEX));
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.lpfnWndProc = MainWindowProc;
wcx.hInstance = GetModuleHandle(NULL);
wcx.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = "WinClass";
RegisterClassEx(&wcx);
}
HWND hWndMain;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
MSG msg;
RegisterWindowClass();
HDC hDC;
HWND hWnd;
hWndMain = CreateWindowEx(WS_EX_APPWINDOW,
"WinClass", "Some Game", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hWndMain, SW_SHOW);
PlaySound("C:\\chrono.wav",NULL,SND_FILENAME | SND_ASYNC);
while (GetMessage(&msg, NULL, 0, 0))
DispatchMessage(&msg);
return 0;
}
guy.bmp just isn't going right another space! Someone help me solve this simple problem!