Displaying Keys

Hey,

Im using BFont to use a PNG font.

I want to do something really simple to test it out… so I tried displaying
the key being pressed.

Well, I can’t get it to work… it just crashes.

SDL_Event event;

int quit = 0;

while(!quit)
{

	while(SDL_PollEvent(&event))
	{
		switch(event.type)
		{
			case SDL_KEYDOWN:
				CenteredPutString(screen, 0, SDL_GetKeyName(event.key.keysm.sym);
				break;

			case SDL_QUIT:
				quit = 1;
				break;
		}

	}

}

Doesn’t work… just crashes… any suggestions?_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

Are you sure SDL is being initialized properly?
You’re missing a ) on :
CenteredPutString(screen, 0, SDL_GetKeyName(event.key.keysm.sym);
but I assume that was just in the email… seing as it compiled for you.
I dont use BFont, but the SDL portion of the code is fine as far as I
can see.

     -James

Rob R wrote:>

Hey,

Im using BFont to use a PNG font.

I want to do something really simple to test it out… so I tried
displaying the key being pressed.

Well, I can’t get it to work… it just crashes.

SDL_Event event;

int quit = 0;

while(!quit)
{

    while(SDL_PollEvent(&event))
    {
        switch(event.type)
        {
            case SDL_KEYDOWN:
                CenteredPutString(screen, 0, 

SDL_GetKeyName(event.key.keysm.sym);
break;

            case SDL_QUIT:
                quit = 1;
                break;
        }

    }

}

Doesn’t work… just crashes… any suggestions?


Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

Hi,

do you use a hardware surface. BFont has a bug there… Are you sure that the
characters within the returned string are in your image?

Btw. if you want to very easily create BFont fonts (bmp’s not png’s), take a
look here:

http://www.libsdl.org/applications.php?match_id=1147>On Wed, 04 Dec 2002 22:55:05 -0600 “Rob R” wrote.

Hey,

Im using BFont to use a PNG font.

I want to do something really simple to test it out… so I tried displaying

the key being pressed.

Well, I can’t get it to work… it just crashes.

SDL_Event event;

int quit = 0;

while(!quit)
{

  while(SDL_PollEvent(&event))
  {
  	switch(event.type)
  	{
  		case SDL_KEYDOWN:
  			CenteredPutString(screen, 0, SDL_GetKeyName(event.key.keysm.sym);
  			break;

  		case SDL_QUIT:
  			quit = 1;
  			break;
  	}

  }

}

Doesn’t work… just crashes… any suggestions?


Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl