10.07.2015 Views

[ebook]Programacion de videojuegos con SDL

[ebook]Programacion de videojuegos con SDL

[ebook]Programacion de videojuegos con SDL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

P R O G R A M A C I Ó N D E V I D E O J U E G O S C O N S D L// lectura directa <strong>de</strong>l joystickjoyx = <strong>SDL</strong>_JoystickGetAxis(joystick, 0);joyy = <strong>SDL</strong>_JoystickGetAxis(joystick, 1);if (joyy < -10) {y-=5;}if (joyy > 10) {y+=5;}if (joyx < -10) {x-=5;}if (joyx > 10) {x+=5;}// Lectura <strong>de</strong> eventoswhile ( <strong>SDL</strong>_PollEvent(&event) ) {// salir <strong>de</strong>l programa si se pulsa el boton <strong>de</strong>l joystickif ( event.type == <strong>SDL</strong>_JOYBUTTONDOWN) {done = 1;}}}// salir <strong>de</strong>l programa si se pulsa una tecla// o se cierra la ventanaif ( event.type == <strong>SDL</strong>_KEYDOWN || event.type == <strong>SDL</strong>_QUIT)done = 1;// liberar superficie<strong>SDL</strong>_FreeSurface(image);// cerramos el joystickif (<strong>SDL</strong>_JoystickOpened(0)) {<strong>SDL</strong>_JoystickClose(joystick);}}return 0;50

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!