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/***************************************************************************Ejemplo6_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"// Mapa <strong>de</strong> tiles// cada tile tiene 64x64 píxeles// una pantalla tiene 10x10 tilesint mapa[100]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};<strong>SDL</strong>_Surface *screen;CFrame fnave;CFrame fmalo;CFrame tile1;CFrame tile2;CFrame tile3;CSprite nave(1);CSprite malo(1);CSprite suelo[3];<strong>SDL</strong>_Rect rectangulo;<strong>SDL</strong>_Joystick *joystick;int joyx, joyy;int done=0;// 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;} enemigo;// Dibuja los esprites en la pantallavoid DrawScene(<strong>SDL</strong>_Surface *screen) {int i,j,x,y,t;//dibujar escenariofor (i=0 ; i

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

Saved successfully!

Ooh no, something went wrong!