I'm really confused!

Started by
7 comments, last by Si0n 19 years, 4 months ago
I'm in GameTutorials.com's AsciiMapEditor Tutorial numero Uno, and Ihave a question Why when I call the setDefault function, itdoesn't display anything on the screen...

void rpg::Map::setDefault()
{
    SMALL_RECT drawRect = { 0, 0, MAP_WIDTH - 1, MAP_HEIGHT - 1 };
    HANDLE out_handle = GetStdHandle(STD_OUTPUT_HANDLE),
    		in_handle = GetStdHandle(STD_INPUT_HANDLE);
    
    SetConsoleWindowInfo(out_handle, true, &drawRect);
    SetConsoleMode(in_handle, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
    
    m_MapName.clear();
    
    m_Tiles.clear();
    m_Items.clear();
    m_NPCs.clear();
    m_Enemies.clear(); 
    m_Exits.clear();
    
    Tile defaultTile;
    CHAR_INFO dTile = { '#', FOREGROUND_GREEN };
    defaultTile.setCharInfo(dTile);
    
    for (int h = 0; h < MAP_HEIGHT - EDITOR_HEIGHT; h++)
    {
        for (int w = 0; w < MAP_WIDTH; w++)
        {
            defaultTile.setLoc(w, h);
            m_Tiles.push_back(defaultTile);
            
            m_ScreenBuffer[w + h * MAP_WIDTH] = dTile;
        }
    }
    COORD zerZero = { 0, 0 }, scrSize = { MAP_WIDTH, MAP_HEIGHT };
    WriteConsoleOutput(out_handle, m_ScreenBuffer, scrSize, zerZero, &drawRect);

}  


Suppose that in the main I create a new Map and call Map.setDefault(); If my code confuses the hell out of you guyts, you can take a look at GameTutorial's (just look at Tiles.cpp) thanks =) [Edited by - superpig on November 27, 2004 10:51:57 AM]
Advertisement
Just a guess, since I have no idea what API that is, but in:
WriteConsoleOutput(out_handle, m_ScreenBuffer, scrSize, zerZero, &drawRect);


Are you sure the two coordinates shouldn't be the other way around (..., zerZero, scrSize, ...)?
No, it is supposed to be the wrong way, and I don't know why I used to get it wrong all the time.
Btw, thsoe are teh standard DOS functions that come in <windows.h>
By the way, is this much different from loading bitmaps?
The only thing I can think of is that EDITOR_HEIGHT would be more than MAP_HEIGHT (if it is the size of the editor and the map together), so your loop would never be run. Other than that, nothing jumps out at me.
--Eric BurnettI know I have mnemophobia, but I can't remember what it is.
EDITOR_HEIGHT = 5
MAP_HEIGHT = 50
MAP_WIDTH = 80

I don't think it's that... damn, that really annoys me and I don't know why. =P =D
Also, the other stuff like liek the Editor itself just don't show (even in the Tutorials that I d/led)
My bestguess is taht "SetConsoleWindowInfo(out_handle, true, &drawRect);"
is not making the windows 80 x 50 for soem reason...
Yes, that is exactly what it is... :( The function is returning false.
How can I change my windows size then?

btw,
const int MAP_WIDTH = 80, MAP_HEIGHT = 50;
const int EDITOR_HEIGHT = 5;
nm, I figured it out =)

This topic is closed to new replies.

Advertisement