From 906514ba3b88834b85da20a4feaedacd25faac20 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 10 Mar 2016 21:38:15 +0100 Subject: [PATCH] SDL personal lib --- SDL#1/Sprite.cpp | 126 +++++++++++++++++++++++++++++++++++++++++++++++ SDL#1/Sprite.h | 61 +++++++++++++++++++++++ SDL#1/exe | Bin 14970 -> 34813 bytes SDL#1/main.cpp | 58 +++++++++++++++++----- SDL#1/main.h | 7 ++- SDL#1/main.o | Bin 6952 -> 48336 bytes SDL#1/makefile | 2 +- SDL#1/sdltl.cpp | 37 ++++++++++++-- SDL#1/sdltl.h | 10 +++- SDL#1/sprite.h | 34 ------------- 10 files changed, 282 insertions(+), 53 deletions(-) create mode 100644 SDL#1/Sprite.cpp create mode 100644 SDL#1/Sprite.h delete mode 100644 SDL#1/sprite.h diff --git a/SDL#1/Sprite.cpp b/SDL#1/Sprite.cpp new file mode 100644 index 0000000..ff9dd56 --- /dev/null +++ b/SDL#1/Sprite.cpp @@ -0,0 +1,126 @@ + +/* [CONSTRUCTOR] Construction de la surface vide +=========================================================*/ +Sprite::Sprite(int x, int y, int w, int h){ + _surface = SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0, 0); + + // On definit les dimensions + _rect = (SDL_Rect){x, y, w, h}; + + // On applique les offset + SDL_SetClipRect( _surface, &_rect ); + +} + + + +/* [CONSTRUCTOR] Construction de la surface avec couleur +=========================================================*/ +Sprite::Sprite(int c[], int x, int y, int w, int h){ + _surface = SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0, 0); + + // On recupere la couleur + Uint32 color = SDL_MapRGB( _surface->format, c[0], c[1], c[2]); + + // On remplit avec la couleur + SDL_FillRect( _surface, NULL, color ); + + // On definit les dimensions + _rect = (SDL_Rect){x, y, w, h}; + + // On applique les offset + SDL_SetClipRect( _surface, &_rect ); +} + + + +/* [CONSTRUCTOR] Construction de la surface avec image +=========================================================*/ +Sprite::Sprite(const char url[], int x, int y, int w, int h){ + /* (1) On cree la surface (avec image) */ + // _surface = SDL_LoadBMP( url ); + _surface = IMG_Load( url ); + + // Gestion erreur + if( _surface == NULL ) + return; + + // On definit les dimensions + _rect = (SDL_Rect){x, y, w, h}; + + // On applique les offset + SDL_SetClipRect( _surface, &_rect ); + +} + + + +/* [APPENDTO] Ajoute le Sprite a une autre +=========================================================*/ +void Sprite::appendTo(SDL_Surface *dest){ + SDL_BlitSurface( _surface, NULL, dest, &_rect ); +} + +/* [SURFACE] Retourne la surface +=========================================================*/ +SDL_Surface *Sprite::surface(){ return _surface; } + + + + + + + + + + + + + + + + +/**********************************/ +/*********** SPRITEGROUP **********/ +/**********************************/ +/* [CONSTRUCTOR] Initialisation de la liste de Sprite +=========================================================*/ +SpriteGroup::SpriteGroup(){ + // _sprites = new vector(0); +} + +/* [ADD] Ajoute un Sprite au groupe +=========================================================*/ +void SpriteGroup::add(Sprite *s){ + _sprites.push_back( s ); +} + +/* [REMOVE] Suppression d'un Sprite du groupe +=========================================================*/ +void SpriteGroup::remove(Sprite *s){ + int index = -1; // on cherche l'indice du sprite + + // On parcours la liste pour trouver l'indice + for( int i = 0 ; i < _sprites.size() ; i++ ) + if( _sprites[i] == s ) index = i; + + // Si on a pas trouve l'indice + if( index == -1 ) return; + + // On supprime le sprite de la liste + _sprites.erase(_sprites.begin() + index ); + +} + +/* [APPEBDTI] Ajoute tous les Sprite du groupe a une surface parente +=========================================================*/ +void SpriteGroup::appendTo(SDL_Surface *dest){ + for( int i = 0 ; i < _sprites.size() ; i++ ) + _sprites[i]->appendTo( dest ); +} + +/* [GET] Retourne le Sprite d'index donne +=========================================================*/ +Sprite* SpriteGroup::get(int i){ + return _sprites[i]; +} \ No newline at end of file diff --git a/SDL#1/Sprite.h b/SDL#1/Sprite.h new file mode 100644 index 0000000..4fa6f30 --- /dev/null +++ b/SDL#1/Sprite.h @@ -0,0 +1,61 @@ +#ifndef DEF_SPRITE_H + + #define DEF_SPRITE_H + + /* [LIBS] Internes + =========================================================*/ + #include "SDL.h" + #include "SDL_image.h" + #include + + /* [LIBS] Externes + =========================================================*/ + + + /* [NS] Namespaces + =========================================================*/ + using namespace std; + + + class Sprite{ + + public: + Sprite(int x, int y, int w, int h); + Sprite(int c[], int x, int y, int w, int h); + Sprite(const char url[], int x, int y, int w, int h); + + // ~Sprite(); + void appendTo(SDL_Surface *dest); + + // GETTERS + SDL_Surface *surface(); + + private: + SDL_Surface *_surface; + SDL_Rect _rect; + + }; + + /* [AGGR] Groupement de Sprite + =========================================================*/ + class SpriteGroup{ + + public: + SpriteGroup(); + void add(Sprite *s); + void remove(Sprite *s); + Sprite* get(int i); + void appendTo(SDL_Surface *dest); + + private: + vector _sprites; + + }; + + + /* [BODY] Inclusion du corps + =========================================================*/ + #include "Sprite.cpp" + + +#endif \ No newline at end of file diff --git a/SDL#1/exe b/SDL#1/exe index a337d2fee981ce8116d8c966c78052816b482c29..40da867f44b70fcae5b1edbd66a59bee5147f1a5 100755 GIT binary patch literal 34813 zcmeHwe|%KcweQI!QLGRmphmPXDp*j7`2_}lPC_P5G|`wJnkslQBm+eA%b5uTZ?UwY zKBf`Nv(^u_wwK$FujRJdM=KYR`XKx$!M@%$^{P!AID6sjRw!UQTuwjQlw6tIzRH2h~W2-gr9#h05u$vi3-m2y!jr(w3(uc2-qsiD6* z;n%r5zzFvcu*&!|26eU7?}VG_en+kn*pchu8x2QApN6{J-6%(Pp6Qh>f;CcKD!;_~ zM-|Zha9wN5$|XhDwKgwmZE5f7UesN@WYLnM+)zhu0k@mWY`!p~fD>)e0s`P%m4vaH(<9eR~`SL09j+vdK!w97NA&m-Ek_`42&rQSD2 zzyF&jKjr?*iSzbs`F+;UA8xqpy?^^%)~sz)mvvV>w0oiVjY^0my{?7g8A&*uDd=xO zHktgDDdc~Ug8rEldNSakWco)^$UmEc{*x4XE=*z1>nZe1Ng@B|6!LeW!;;zm#T4?N zNuhsf3Ox^}(36=$zAy#-#uWZpoPu7P!p?muAG}-%2nf|*|(APpwwsnd1@ZF7& zh+P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O#xeN)Z;gk@b zX{ZJfHTHV92IzFN|3>=MAS17i`S5WZfMS-!15z_Fkal>vkYNpT8sURIDXS zuD9>(3$!$BZ&{Z?kX0|I3x@vBNbt{X9^VS&LUMjrC;00L`rsfZu|LOv0y5?2ODSjA z^R(wN%l9dUuH!opb=j!1SWQ=EB1X;T`;J6?=8zqOJj2;vdSGcW&2;(%AnTie>0ejS z#|hbf<<|wiSid& diff --git a/SDL#1/main.cpp b/SDL#1/main.cpp index e72a87e..62fb6fc 100644 --- a/SDL#1/main.cpp +++ b/SDL#1/main.cpp @@ -1,11 +1,13 @@ #include "main.h" // On cree un sdl-toplevel statique -static sdltl *mgr; +static sdltl *mgr = NULL; +static bool running = true; int main(int argc, char* argv[]) { + srand(time(0)); /* [0] Initialisation de SDL =========================================================*/ @@ -13,25 +15,57 @@ int main(int argc, char* argv[]) { /* [1] Creation de la fenetre =========================================================*/ - if( !mgr->status() ) - cout << "Erreur: " << SDL_GetError() << endl; + if( !mgr->status() ) cout << "Erreur: " << SDL_GetError() << endl; /* [3] On definit le background color =========================================================*/ - // mgr->setBackground(255, 0, 255); - mgr->setBackground(255, 0, 0); - bool imageLoaded = mgr->setImage( "src/1.bmp" ); + mgr->setBackground(255, 255, 255); + // bool imageLoaded = mgr->setImage( "src/1.bmp" ); + + + + /* [4] On ajoute une sprite + =========================================================*/ + SpriteGroup back; + + /* (1) Bloc vide */ + back.add( new Sprite( 0, 0, 200, 200 ) ); + + /* (2) Bloc rose */ + int pink[] = {255, 0, 255}; + back.add( new Sprite(pink, 200, 0, 200, 200 ) ); + + /* (2) Bloc image */ + back.add( new Sprite("src/1.bmp", 400, 0, 200, 200 ) ); + + + + + /* [5] On ajoute les elements + mise a jour affichage + =========================================================*/ + back.appendTo( mgr->screen() ); mgr->update(); + + /* [n-1] Boucle infinie =========================================================*/ - // while(1){ - mgr->waitEvent(SDL_QUIT, &eventHandler); - // } - // SDL_Delay(5000); + mgr->manageFps(FPS); + running = true; + while(running){ + + mgr->waitEvent(SDL_QUIT, &quitEventHandler); + + // Gestion des FPS (vitesse de la boucle) + mgr->manageFps(); + } + + + + @@ -42,7 +76,7 @@ int main(int argc, char* argv[]) { } -void eventHandler(SDL_Event *e){ +void quitEventHandler(SDL_Event *e){ cout << "Ferme" << endl; - delete mgr; + running = false; } \ No newline at end of file diff --git a/SDL#1/main.h b/SDL#1/main.h index e2a507d..26ca25d 100644 --- a/SDL#1/main.h +++ b/SDL#1/main.h @@ -5,11 +5,12 @@ /* [LIB] Internes =========================================================*/ #include + #include /* [LIB] Externes =========================================================*/ #include "sdltl.h" // gestion de la fenetre et SDL - #include "sprite.h" // gestion des sprites + #include "Sprite.h" // gestion des sprites /* [NS] Namespace =========================================================*/ @@ -20,8 +21,10 @@ #define WIN_WIDTH 600 #define WIN_HEIGHT 400 + #define FPS 60 + /* [FONCTIONS] Fonctions du corps =========================================================*/ - void eventHandler(SDL_Event *e); + void quitEventHandler(SDL_Event *e); #endif \ No newline at end of file diff --git a/SDL#1/main.o b/SDL#1/main.o index 8a70f358c29d613fabd03e9f109e99cf1ec93ff1..91107d14109804b7053e356086460deb5db77ba2 100644 GIT binary patch literal 48336 zcmc(I4}4rzmH$g7X)6>OO2sG$A+*{GElC?n3I)?P(@r3*Lz6(QrITqgZ6f){WKvR= zcB=uF`GqQoxD^r0PsJiA6|e-YG_s1mznjZ=w9-l($jd zL3tPDNy<}{Z=}4J@=cWg1Le0+zJ>Cwlz)=)TPeSt@;fL`Q{GScos@ry@=sHKH|6(G zelO*pqkKE%_fh@@%D+hYmnh#s`Gb^ynewkv{x!;XQvNXIk5K*%${(ZrTa-UR`L`i& zh@^iL={sH$NpBvDq$6@r2Qj*IcQ zfBDh=hU368y6EWwIA4@Loc_so9OvZ4&)`=ieTdi_K-c0TlpX1>DvI1T*fR-F4pvQ) z@(}bB7gKrObNlZin}GyuRx*fOC{Q%K{IBV$duhf{oz-q>>dRz;J_-dxN4HBMLK*!!Tk*< zz#HH=viLcvTgn}VHW-Q=3M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yU@@Kq8~Bv*=mjlh$)j-KmLtt5&H5+D^G2+DGOBdu=cYiz=S7iVqO$L@gfi;~rOp-S6lIa+%mP8iUgxYTuY`A=&39B`g zE2t2l(Sqx@lPxMWS;(m)%uFpIcjc-2n5M$~jKLf-+RZ;?{G@SzScS_x(iwu|ZmT$ROyqBHT+|2GI?@!u>Ab&5 z?9h2H6L~tnvqYZG@4E!2`OXoX=DR>}n(sDL2EzDxmyI9d16)@v@Q6C^B=U!ur2E=U zaB62S!H*F6CpeDwzXp%6FGO%#L7uozg*XE-d<3=ej=;q|;+zLB^YKd_{5?MYg$G~Y zmFR( LTYu-lMV STRUCTURE DE FICHIERS POUR LES EXECUTABLES init: clean diff --git a/SDL#1/sdltl.cpp b/SDL#1/sdltl.cpp index 5290f44..b823c03 100644 --- a/SDL#1/sdltl.cpp +++ b/SDL#1/sdltl.cpp @@ -1,6 +1,10 @@ /* [CONSTRUCTOR] Constructeur de la classe =========================================================*/ sdltl::sdltl(const char *t, int w, int h){ + // default values + _lasttick = 0; + _fpstime = 1000/60; + SDL_Init( SDL_INIT_EVERYTHING ); _window = NULL; @@ -9,8 +13,8 @@ sdltl::sdltl(const char *t, int w, int h){ // Creation de la fenetre _window = SDL_CreateWindow( t, - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_SHOWN @@ -36,7 +40,9 @@ sdltl::~sdltl(){ /* [STATUS] Retourne le status =========================================================*/ -bool sdltl::status(){ return _status; } +bool sdltl::status(){ + return _window != NULL && _screen != NULL; +} /* [WINDOW] Retourne la fenetre @@ -100,4 +106,29 @@ void sdltl::waitEvent(SDL_EventType t, void(*handler)(SDL_Event*)){ (*handler)(&event); } +} + +/* [MANAGEFTP] Gestion de la vitesse de boucle +=========================================================*/ +void sdltl::manageFps(const int fps){ + /* (1) Definition de fps */ + if( fps != 0 ) _fpstime = 1000/fps; + + /* (2) Initialisation timer */ + if( _lasttick == 0 ) + _lasttick = SDL_GetTicks(); + + /* (3) Utilisation en fin de WHILE() */ + + // 1 > Si trop rapide, on attends + definit _lasttick + else if( SDL_GetTicks()-_lasttick < _fpstime ){ + SDL_Delay( _fpstime - (SDL_GetTicks()-_lasttick) ); + + _lasttick = SDL_GetTicks() + _fpstime - (SDL_GetTicks()-_lasttick); + + // 2 > Temps ok + }else + _lasttick = SDL_GetTicks(); + + } \ No newline at end of file diff --git a/SDL#1/sdltl.h b/SDL#1/sdltl.h index 2aa0bab..b59d926 100644 --- a/SDL#1/sdltl.h +++ b/SDL#1/sdltl.h @@ -26,11 +26,19 @@ void setBackground(int r, int g, int b); bool setImage(const char *url); void waitEvent(SDL_EventType t, void(*handler)(SDL_Event*) ); - void update(); + void manageFps(const int fps=0); + private: + // gestion FPS + Uint32 _lasttick; + Uint32 _fpstime; + + // status de l'initialisation bool _status; + + // Elements utiles SDL_Window *_window; SDL_Surface *_screen; diff --git a/SDL#1/sprite.h b/SDL#1/sprite.h deleted file mode 100644 index 917b221..0000000 --- a/SDL#1/sprite.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef DEF_SPRITE_H - - #define DEF_SPRITE_H - - /* [LIBS] Internes - =========================================================*/ - #include "SDL.h" - - /* [LIBS] Externes - =========================================================*/ - - - /* [NS] Namespaces - =========================================================*/ - using namespace std; - - - class Sprite{ - - public: - Sprite(); - ~Sprite(); - - private: - - }; - - - /* [BODY] Inclusion du corps - =========================================================*/ - // #include "sprite.cpp" - - -#endif \ No newline at end of file