Reading and Writing

Hi people… how can i read inputs when my SDL screen is turn on?(i think to
use sdl event, but it’s not good because it read one by one)
and… how can i write characters on som particular position with particular
font???
thanks for the help!

Hi Igor,

El Lunes 21 Mayo 2007, Igor Castro escribi?:

(i think to use sdl event, but it’s not good because it read one by one)

I don’t understand this very well. Events are stored in a queue one by one,
ordered by their arrival time. You usually get them from that queue until it
is empty, so you can always get all the events up to date.

and… how can i write characters on som particular position with particular
font???

You first read the key strokes, then use SDL TTF to render the text in
whatever font you want into a surface, then you blit it where you want on the
screen.

HTH,

Alberto

how can i read the key strokes? using the queue events? or something like
"scanf" in sdl?
thanks very much!On 5/21/07, Alberto Luaces wrote:

Hi Igor,

El Lunes 21 Mayo 2007, Igor Castro escribi?:

(i think to use sdl event, but it’s not good because it read one by one)

I don’t understand this very well. Events are stored in a queue one by
one,
ordered by their arrival time. You usually get them from that queue until
it
is empty, so you can always get all the events up to date.

and… how can i write characters on som particular position with
particular
font???

You first read the key strokes, then use SDL TTF to render the text in
whatever font you want into a surface, then you blit it where you want on
the
screen.

HTH,

Alberto


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

El Lunes 21 Mayo 2007, escribi?:

how can i read the key strokes? using the queue events?

Yes: first you retrieve the event and look at its type. If it is a SDL_KEYDOWN
event, it means that you can extract a SDL_KeyboardEvent from it, which in
turn has a SDL_keysym variable which says which key was pressed (look at the
documentation). Depending of what you are looking for (wait for a certain
keypress or get what character was typed), you’ll find useful any of the
SDL_keysym fields:

typedef struct{
Uint8 scancode;
SDLKey sym;
SDLMod mod;
Uint16 unicode; /* <-- This is likely what you are looking for */
} SDL_keysym;

HTH,

Alberto

how can i read the key strokes? using the queue events?

Yes: first you retrieve the event and look at its type. If it is a
SDL_KEYDOWN
event, it means that you can extract a SDL_KeyboardEvent from it, which in
turn has a SDL_keysym variable which says which key was pressed (look at
the
documentation). Depending of what you are looking for (wait for a certain
keypress or get what character was typed), you’ll find useful any of the
SDL_keysym fields:

I find that it’s best to use the event loop just to check for special keys,
like escape,
or keys to toggle full-screen / windowed modes. When reading actual game
keys
it is better to use SDL_GetKeyState(), since you can check for multiple keys
being
pressed at once.

Cheers,
Peter

Ok… and how to wirte? i download SDL_ttf and put the .h in my lib folder,
put the .dll in windows/system32.
After i include SDL_tff.h in my project and i get the error:"undefined
reference to TTF_Init()"
i’m using DEV-CPP
thanks!On 5/21/07, Peter Ketting wrote:

how can i read the key strokes? using the queue events?

Yes: first you retrieve the event and look at its type. If it is a
SDL_KEYDOWN
event, it means that you can extract a SDL_KeyboardEvent from it, which
in
turn has a SDL_keysym variable which says which key was pressed (look at
the
documentation). Depending of what you are looking for (wait for a
certain
keypress or get what character was typed), you’ll find useful any of the
SDL_keysym fields:

I find that it’s best to use the event loop just to check for special
keys,
like escape,
or keys to toggle full-screen / windowed modes. When reading actual game
keys
it is better to use SDL_GetKeyState(), since you can check for multiple
keys
being
pressed at once.

Cheers,
Peter


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

El Lunes 21 Mayo 2007, Igor Castro escribi?:

After i include SDL_tff.h in my project and i get the error:“undefined
reference to TTF_Init()”

You have to link against that library, just as you are doing with SDL. As you
are using Mingw, you’ll have to add “-lSDL_ttf” to the linker parameters.

Alberto