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 L/***************************************************************************Ejemplo7_1(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> "csprite.h"#<strong>de</strong>fine MAXMAP 400#<strong>de</strong>fine MAXBALAS 8<strong>SDL</strong>_Surface *screen;CFrame fnave;CFrame fmalo;CFrame tile1;CFrame tile2;CFrame tile3;CFrame labala;CFrame ex1;CFrame ex2;CFrame ex3;CFrame ex4;CFrame ex5;CFrame ex6;CFrame ex7;CSprite nave(1);CSprite malo(1);CSprite suelo[3];CSprite mibala(1);CSprite explo<strong>de</strong>(8);<strong>SDL</strong>_Rect rectangulo;<strong>SDL</strong>_Joystick *joystick;char mapa[401];int joyx, joyy;int done=0;int indice, indice_in;FILE *f;// estructura que <strong>con</strong>tiene la información// <strong>de</strong> nuestro aviónstruct minave {int x,y;} jugador;// Estructura que <strong>con</strong>tiene información// <strong>de</strong>l avión enemigostruct naveenemiga {int x,y,estado;} enemigo;// Estructura que <strong>con</strong>tine información// <strong>de</strong> los disparos <strong>de</strong> nuestro aviónstruct disparo {int x,y;} bala[MAXBALAS+1];// Estructura que <strong>con</strong>tiene información// <strong>de</strong> la explosiónstruct explosion {int activo,x,y,nframe;} exp;void muevenave() {// estado 1. Movimiento a la <strong>de</strong>recha.if (enemigo.estado == 1) {112

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

Saved successfully!

Ooh no, something went wrong!