예제 #1
0
void Init(HWND hWnd)
{
	// Set our global window handle to our main window
	g_hWnd = hWnd;

	// Create our double buffering for each window
	g_Buffer.CreateDoubleBuffering(hWnd);
	g_ToolBuffer.CreateDoubleBuffering(g_hWndTool);

	// Set the map to default
    g_Map.SetDefault();

	// Load the tiles into the global lists and then get the scroll bar max scroll position
	g_ScrollInfo.nMax = LoadTiles();

	// By default set the current tile type to map tiles
	g_Map.SetCurrentType(TILE_TYPE);

	// Set our current map to ....  our current map :)
	g_pCurrentMap = &g_Map;

	// Initialize the scroll bar information
	g_ScrollInfo.cbSize = sizeof(SCROLLINFO);
	g_ScrollInfo.nMin = 0; 
	g_ScrollInfo.nPage = 1; 
	g_ScrollInfo.fMask = SIF_PAGE | SIF_RANGE;
	SetScrollInfo(g_hWndTool, SB_VERT, &g_ScrollInfo, FALSE);
				

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

	// Here we initialize our open file information
	g_OpenInfo.lStructSize = sizeof(OPENFILENAME);				// Set the size of the structure
	g_OpenInfo.nMaxFile = MAX_PATH;								// Set the max characters for a file name
	g_OpenInfo.lpstrFile = g_szFileName;						// Give a string to store the file name
	g_OpenInfo.lpstrFilter = "Map Files (*.map)\0*.map";		// Only accept .map files to load
	g_OpenInfo.hwndOwner = g_hWndTool;							// Assign the window owner and give it desired flags
	g_OpenInfo.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


	// Here we set the current pen to red for drawing our exit rectangles
	g_Buffer.SetPen(PS_SOLID,2,RGB(255,0,0));

	// Set the backbuffer to black first (This clears the backbuffer)
	g_Buffer.ClearScreen(BLACK_BRUSH);			
	g_ToolBuffer.ClearScreen(BLACK_BRUSH);			
}
예제 #2
0
void Init(HWND hWnd)
{
    // Set our global window handle to our main window
    g_hWnd = hWnd;

    // Create our double buffering our window
    g_Buffer.CreateDoubleBuffering(hWnd);

    // This is where we create the image of our character
    HBITMAP hPlayerImage = g_Buffer.LoadABitmap((LPSTR)kPlayerImage);

    // Initialize our player with it's image and position
    g_Player.Init(hPlayerImage, kPlayerStartX, kPlayerStartY);

    // Init, load and draw the first map file
    g_Map.Load(kStartMap);
    g_Map.SetDrawFlag(true);

    // Here we load then play the starting background music
    if(!g_Music.Init("techno.mod"))
        exit(0);

    g_Music.PlaySong();

    // we need to seed our random number generator (rand()) for moving npcs.
    srand(GetTickCount());

    // Set the backbuffer to black first (This clears the backbuffer)
    g_Buffer.ClearScreen(BLACK_BRUSH);
}
예제 #3
0
파일: Main.cpp 프로젝트: CHMyFork/tutorials
void Init(HWND hWnd)
{
    // Set our global window handle to our main window
    g_hWnd = hWnd;

    // Create our double buffering for each window
    g_Buffer.CreateDoubleBuffering(hWnd);
    g_ToolBuffer.CreateDoubleBuffering(g_hWndTool);

    // Set the map to default
    g_Map.SetDefault();

    // Load the tiles into the global lists and then get the scroll bar max scroll position
    g_ScrollInfo.nMax = LoadTiles();

    // By default set the current tile type to map tiles
    g_Map.SetCurrentType(TILE_TYPE);

    // Set our current map to ....  our current map :)
    g_pCurrentMap = &g_Map;

    // Initialize the scroll bar information
    g_ScrollInfo.cbSize = sizeof(SCROLLINFO);
    g_ScrollInfo.nMin = 0;
    g_ScrollInfo.nPage = 1;
    g_ScrollInfo.fMask = SIF_PAGE | SIF_RANGE;
    SetScrollInfo(g_hWndTool, SB_VERT, &g_ScrollInfo, FALSE);


//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////

    // Here we set the current pen to red for drawing our exit rectangles
    g_Buffer.SetPen(PS_SOLID,2,RGB(255,0,0));

//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


    // Set the backbuffer to black first (This clears the backbuffer)
    g_Buffer.ClearScreen(BLACK_BRUSH);
    g_ToolBuffer.ClearScreen(BLACK_BRUSH);
}