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}atexit(TTF_Quit);inicializa();InitSprites();while (done == 0) {switch (estado) {case 0:InitEstados();pantalla.setx(0);pantalla.sety(0);pantalla.draw(screen);<strong>SDL</strong>_Flip(screen);// <strong>de</strong>sactivamos la música (si estaba activada)Mix_HaltMusic();while (estado==0 && done==0) {while (<strong>SDL</strong>_PollEvent(&event)) {if (event.type == <strong>SDL</strong>_QUIT) {done=1;}if (event.type == <strong>SDL</strong>_KEYDOWN || event.type == <strong>SDL</strong>_JOYBUTTONDOWN) {}if (event.key.keysym.sym == <strong>SDL</strong>K_ESCAPE) {done=1;} else {score=0;estado=1;LoadLevel(1);}// Activamos la músicaMix_PlayMusic(musica,-1);}}break;case 1:// Inicializamos el timer para <strong>con</strong>trol <strong>de</strong> tiempo.ResetTimeBase();ciclos++;// cada 20 ciclos se crea un enemigoif ((!(ciclos % 20)) && <strong>con</strong>jefe==0) {creaenemigo();}// ¿final <strong>de</strong> fase?if (ciclos>=5000 && <strong>con</strong>jefe==0) {// creamos la nave jefe.creajefe();<strong>con</strong>jefe=1;}// tiempo <strong>de</strong>s<strong>de</strong> que se <strong>de</strong>struye al jefe// hasta que cambiamos <strong>de</strong> nivel.if ((<strong>con</strong>jefe == 2) && (leveltime-- 2) level=1;LoadLevel(level);134

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

Saved successfully!

Ooh no, something went wrong!