[Назад] Содержание [Дальше]
|
Совет:
|
Пример
:
{
SDL_Event event;
SDL_WaitEvent(&event);
switch
(event.type) {
case
SDL_KEYDOWN:
printf("The %s key was pressed!\n",
SDL_GetKeyName(event.key.keysym.sym));
break;
case
SDL_QUIT:
exit(0);
}
}
|
|
Совет:
|
Пример
:
{
SDL_Event event;
while
( SDL_PollEvent(&event) ) {
switch
(event.type) {
case
SDL_MOUSEMOTION:
printf("Mouse moved by %d,%d to (%d,%d)\n",
event.motion.xrel, event.motion.yrel,
event.motion.x, event.motion.y);
break;
case
SDL_MOUSEBUTTONDOWN:
printf("Mouse button %d pressed at (%d,%d)\n",
event.button.button, event.button.x, event.button.y);
break;
case
SDL_QUIT:
exit(0);
}
}
}
|
|
Совет:
|
Пример
:
{
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
}
void
CheckMouseHover(void)
{
int
mouse_x, mouse_y;
SDL_PumpEvents();
SDL_GetMouseState(&mouse_x, &mouse_y);
if
( (mouse_x < 32) && (mouse_y < 32) ) {
printf("Mouse in upper left hand corner!\n");
}
}
|
[
Назад
]
Содержание
[
Дальше
]