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/***************************************************************************- 1945 -(C) 2003 by Alberto Garcia SerranoProgramación <strong>de</strong> vi<strong>de</strong>ojuegos <strong>con</strong> <strong>SDL</strong>***************************************************************************/#inclu<strong>de</strong> #inclu<strong>de</strong> #inclu<strong>de</strong> #inclu<strong>de</strong> #inclu<strong>de</strong> #inclu<strong>de</strong> "<strong>SDL</strong>_mixer.h"#inclu<strong>de</strong> "<strong>SDL</strong>_ttf.h"#inclu<strong>de</strong> "csprite.h"// mapa#<strong>de</strong>fine MAXTILES 10#<strong>de</strong>fine MAXMAP 400char mapa[401];<strong>SDL</strong>_Surface *screen;<strong>SDL</strong>_Rect rect;CFrame fnave;CFrame fmalo1_1;CFrame fmalo1_2;CFrame fmalo1_3;CFrame fmalo1_4;CFrame fmalo1_5;CFrame fmalo2;CFrame fmalo3;CFrame bala;CFrame ex1;CFrame ex2;CFrame ex3;CFrame ex4;CFrame ex5;CFrame ex6;CFrame ex7;CFrame dis;CFrame dis2;CFrame vida;CFrame pant;CFrame frsuelo[MAXTILES];CFrame flevel;CSprite slevel(1);CSprite suelo[MAXTILES];CSprite pantalla(1);CSprite explo<strong>de</strong>(12);CSprite nave(1);CSprite malo2(1);CSprite malo3(1);CSprite malo1(5);CSprite mibala(1);CSprite dispene(2);CSprite life(1);int ciclos,leveltime;int indice, indice_in;int nexplosiones=7,nmalos=6,nbalas=6,ndispenemigos=7,mibalax[7],mibalay[7];int done=0,estado=0, <strong>con</strong>jefe=0, level=1, score=0;Uint32 ini_milisegundos, fin_milisegundos, frametime;Sint16 joyx,joyy;Mix_Music *musica;Mix_Chunk *explosion,*disparo;<strong>SDL</strong>_Joystick *joystick;TTF_Font *fuente;<strong>SDL</strong>_Surface *ttext;<strong>SDL</strong>_Color bgcolor,fgcolor;<strong>SDL</strong>_Rect rectangulo;FILE *f;struct minave {int activo,x,y,vidas,time;} jugador;123
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 Lstruct naveenemiga {int activo,x,y,dx,dy,tipo,estado,impactos,nframe;} enemigo[7];struct explosion {int activo,x,y,nframe;} exp[8];struct disparo {int activo,x,y,dx,dy,estado,time;} disp[8];int dx=2,dy=2;void creaexplosion(int);void creadispenemigo(int);void ResetTimeBase(void);void creajefe(void);void LoadLevel(int);int CurrentTime(void);void DrawScene(<strong>SDL</strong>_Surface *screen) {int i,j,t,x,y;char msg[30];// movimiento <strong>de</strong>l scenario (scroll)indice_in+=2;if (indice_in>=64) {indice_in=0;indice-=10;}if (indice