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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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 LPor último (por ahora) quiero presentaros la siguiente función:<strong>SDL</strong>_Vi<strong>de</strong>oInfo *<strong>SDL</strong>_GetVi<strong>de</strong>oInfo(void);Su misión es <strong>de</strong>volvernos información sobre el modo <strong>de</strong> vi<strong>de</strong>o actual. Si aún no se hainicializado un modo <strong>de</strong> vi<strong>de</strong>o, nos <strong>de</strong>vuelve el “mejor” modo disponible (siempre según <strong>SDL</strong>).Esta función no tiene parámetros, y <strong>de</strong>vuelve el resultado en una variable <strong>de</strong> tipo<strong>SDL</strong>_Vi<strong>de</strong>oInfo, que tiene la siguiente estructura:type<strong>de</strong>f struct{Uint32 hw_available:1;Uint32 wm_available:1;Uint32 blit_hw:1;Uint32 blit_hw_CC:1;Uint32 blit_hw_A:1;Uint32 blit_sw:1;Uint32 blit_sw_CC:1;Uint32 blit_sw_A:1;Uint32 blit_fill;Uint32 vi<strong>de</strong>o_mem;<strong>SDL</strong>_PixelFormat *vfmt;} <strong>SDL</strong>_Vi<strong>de</strong>oInfo;El significado <strong>de</strong> cada campo es el siguiente:Hw_available Indica si se pue<strong>de</strong>n crear superficies en memoria <strong>de</strong> vi<strong>de</strong>o.Wm_available Indica si hay un manejador <strong>de</strong> ventanas disponible.blit_hwblit_hw_CCblit_hw_Ablit_swblit_sw_CCblit_sw_Ablit_fillvi<strong>de</strong>o_memVfmtIndica si el blitting hardware - hardware está acelerado.Indica si el blitting <strong>con</strong> transparencias hardware – hardware está acelerado.Indica si el blitting <strong>con</strong> alpha hardware – hardware está acelerado.Indica si el blitting software - hardware está acelerado.Indica si el blitting <strong>con</strong> transparencias software – hardware está acelerado.Indica si el blitting <strong>con</strong> alpha software – hardware está acelerado.Indica si el rellenado <strong>de</strong> color está acelerado.Cantidad <strong>de</strong> memoria total en Kilobites.Puntero a la estructura <strong>SDL</strong>_PixelFormat que <strong>con</strong>tiene el formato <strong>de</strong> píxel <strong>de</strong>lsistema gráfico.En el tintero nos <strong>de</strong>jamos muchas cosas sobre el vi<strong>de</strong>o, pero ya tenemos las herramientasnecesarias para comenzar a programar vi<strong>de</strong>ojuegos. En la documentación <strong>de</strong> la librería <strong>SDL</strong>pue<strong>de</strong>s en<strong>con</strong>trar información sobre muchos más tópicos que no hemos tratado aquí, comotrabajo <strong>con</strong> paletas <strong>de</strong> color, acceso directo a las superficies, etc... Con los <strong>con</strong>ocimientos queahora tienes <strong>de</strong>berías po<strong>de</strong>r seguir sin problema esta documentación.Gestión <strong>de</strong> eventosLa gestión <strong>de</strong> eventos <strong>de</strong> <strong>SDL</strong> es realmente cómoda y fácil <strong>de</strong> usar. Seamos sinceros,si te las has visto <strong>con</strong> el sistema <strong>de</strong> eventos <strong>de</strong> Windows, <strong>SDL</strong> te va a parecer un juego<strong>de</strong> niños. El subsistema <strong>de</strong> eventos <strong>de</strong> <strong>SDL</strong> se inicializa junto al subsistema <strong>de</strong> vi<strong>de</strong>o, porlo que no hay que inicializarlo expresamente. Todo esto está muy bien, pero ¿qué es unevento? Bien, en general, un evento es algo que suce<strong>de</strong> durante la ejecución <strong>de</strong>lprograma.38

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

Saved successfully!

Ooh no, something went wrong!