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.

Nuevo archivoAhora tendremos una ventana <strong>de</strong> edición lista para empezar a teclear. Introduce elsiguiente código que utilizaremos para probar la librería.#inclu<strong>de</strong> #inclu<strong>de</strong> #inclu<strong>de</strong> int main(int argc, char *argv[]) {<strong>SDL</strong>_Surface *screen;<strong>SDL</strong>_Event event;int done = 0;atexit(<strong>SDL</strong>_Quit);// Iniciar <strong>SDL</strong>if (<strong>SDL</strong>_Init(<strong>SDL</strong>_INIT_VIDEO) < 0) {printf("No se pudo iniciar <strong>SDL</strong>: %s\n",<strong>SDL</strong>_GetError());exit(1);}// Activamos modo <strong>de</strong> vi<strong>de</strong>oscreen = <strong>SDL</strong>_SetVi<strong>de</strong>oMo<strong>de</strong>(640,480,24,<strong>SDL</strong>_HWSURFACE);if (screen == NULL) {printf("No se pue<strong>de</strong> inicializar el modo gráfico:\n",<strong>SDL</strong>_GetError());exit(1);}// Esperamos la pulsación <strong>de</strong> una tecla para salirwhile(done == 0) {while ( <strong>SDL</strong>_PollEvent(&event) ) {if ( event.type == <strong>SDL</strong>_KEYDOWN )done = 1;}140

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

Saved successfully!

Ooh no, something went wrong!