push pending changed / update SDL#4
This commit is contained in:
parent
df73278733
commit
6f779f7ce1
|
@ -0,0 +1,86 @@
|
||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Mac",
|
||||||
|
"includePath": [
|
||||||
|
"/usr/include",
|
||||||
|
"/usr/include/SDL2",
|
||||||
|
"/usr/local/include",
|
||||||
|
"${workspaceRoot}"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"intelliSenseMode": "clang-x64",
|
||||||
|
"browse": {
|
||||||
|
"path": [
|
||||||
|
"/usr/include",
|
||||||
|
"/usr/local/include",
|
||||||
|
"${workspaceRoot}"
|
||||||
|
],
|
||||||
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": ""
|
||||||
|
},
|
||||||
|
"macFrameworkPath": [
|
||||||
|
"/System/Library/Frameworks",
|
||||||
|
"/Library/Frameworks"
|
||||||
|
],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c11",
|
||||||
|
"cppStandard": "c++17"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"/usr/include/c++/5.4.0",
|
||||||
|
"/usr/include/x86_64-linux-gnu/c++/5.4.0",
|
||||||
|
"/usr/local/include",
|
||||||
|
"/usr/include",
|
||||||
|
"/usr/include/x86_64-linux-gnu",
|
||||||
|
"${workspaceRoot}",
|
||||||
|
"/usr/include/linux",
|
||||||
|
"/usr/include/linux",
|
||||||
|
"/usr/include/SDL2"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"intelliSenseMode": "clang-x64",
|
||||||
|
"browse": {
|
||||||
|
"path": [
|
||||||
|
"/usr/include/c++/5.4.0",
|
||||||
|
"/usr/include/x86_64-linux-gnu/c++/5.4.0",
|
||||||
|
"/usr/local/include",
|
||||||
|
"/usr/include",
|
||||||
|
"/usr/include/x86_64-linux-gnu",
|
||||||
|
"${workspaceRoot}"
|
||||||
|
],
|
||||||
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": ""
|
||||||
|
},
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c11",
|
||||||
|
"cppStandard": "c++17"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Win32",
|
||||||
|
"includePath": [
|
||||||
|
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
|
||||||
|
"${workspaceRoot}"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"_DEBUG",
|
||||||
|
"UNICODE"
|
||||||
|
],
|
||||||
|
"intelliSenseMode": "msvc-x64",
|
||||||
|
"browse": {
|
||||||
|
"path": [
|
||||||
|
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
|
||||||
|
"${workspaceRoot}"
|
||||||
|
],
|
||||||
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": ""
|
||||||
|
},
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c11",
|
||||||
|
"cppStandard": "c++17"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"iostream": "cpp",
|
||||||
|
"ctime": "cpp"
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,7 @@
|
||||||
class xSprite;
|
class xSprite;
|
||||||
#include "xSDL.h" // Librairie perso
|
#include "xSDL.h" // Librairie perso
|
||||||
#include "xMario.h" // Elements utiles au jeu
|
#include "xMario.h" // Elements utiles au jeu
|
||||||
|
|
||||||
#include "xSDL.cpp" // Librairie perso
|
#include "xSDL.cpp" // Librairie perso
|
||||||
#include "xMario.cpp" // Elements utiles au jeu
|
#include "xMario.cpp" // Elements utiles au jeu
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ void xMarioMario::spreadTurn(){
|
||||||
_pos = "TL";
|
_pos = "TL";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (1.2) HAUT - DROITE */
|
/* (1.2) HAUT - DROITE */
|
||||||
|
@ -138,14 +138,14 @@ void xMarioMario::spreadTurn(){
|
||||||
// _pos = "BC";
|
// _pos = "BC";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (2.1) BAS - GAUCHE */
|
/* (2.1) BAS - GAUCHE */
|
||||||
}else if( left ){ // bl
|
}else if( left ){ // bl
|
||||||
if( _pos != "BL" ){
|
if( _pos != "BL" ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (2.2) BAS - DROITE */
|
/* (2.2) BAS - DROITE */
|
||||||
|
@ -172,8 +172,8 @@ void xMarioMario::spreadTurn(){
|
||||||
_pos = "NR";
|
_pos = "NR";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (3.1) NORMAL - GAUCHE */
|
/* (3.1) NORMAL - GAUCHE */
|
||||||
}else if( left ){ // nl
|
}else if( left ){ // nl
|
||||||
if( _pos != "NL" ){
|
if( _pos != "NL" ){
|
||||||
|
@ -186,7 +186,7 @@ void xMarioMario::spreadTurn(){
|
||||||
_pos = "NL";
|
_pos = "NL";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (3.2) NORMAL - DROITE */
|
/* (3.2) NORMAL - DROITE */
|
||||||
|
|
|
@ -21,7 +21,7 @@ xManager::xManager(const char *t, int w, int h){
|
||||||
SDL_WINDOWPOS_CENTERED,
|
SDL_WINDOWPOS_CENTERED,
|
||||||
w,
|
w,
|
||||||
h,
|
h,
|
||||||
SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL
|
SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL
|
||||||
);
|
);
|
||||||
|
|
||||||
// Gestion erreur
|
// Gestion erreur
|
||||||
|
@ -180,7 +180,7 @@ bool xManager::hit(xSprite* current, int movex, int movey){
|
||||||
|| (a.x+a.w > _winrect.x+_winrect.w ) // Inclus a gauche
|
|| (a.x+a.w > _winrect.x+_winrect.w ) // Inclus a gauche
|
||||||
|| (a.y < _winrect.y ) // Inclus en haut
|
|| (a.y < _winrect.y ) // Inclus en haut
|
||||||
|| (a.y+a.h > _winrect.y+_winrect.h ) // Inclus en bas
|
|| (a.y+a.h > _winrect.y+_winrect.h ) // Inclus en bas
|
||||||
){
|
){
|
||||||
// Si on tombe, on meurt
|
// Si on tombe, on meurt
|
||||||
if( a.y+a.h > _winrect.y+_winrect.h )
|
if( a.y+a.h > _winrect.y+_winrect.h )
|
||||||
state = 2;
|
state = 2;
|
||||||
|
@ -236,7 +236,7 @@ bool xManager::hit(xSprite* current, int movex, int movey){
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
bool xManager::hit(string current, int movex, int movey){
|
bool xManager::hit(string current, int movex, int movey){
|
||||||
if( !this->status() ) return true;
|
if( !this->status() ) return true;
|
||||||
|
|
||||||
_mutex_hit.try_lock();
|
_mutex_hit.try_lock();
|
||||||
|
|
||||||
/* (1) On recupere le SDL_Rect destination du sprite courant */
|
/* (1) On recupere le SDL_Rect destination du sprite courant */
|
||||||
|
@ -251,17 +251,17 @@ bool xManager::hit(string current, int movex, int movey){
|
||||||
|
|
||||||
// Retour du resultat
|
// Retour du resultat
|
||||||
_mutex_hit.unlock();
|
_mutex_hit.unlock();
|
||||||
return this->hit(sprite, movex, movey);
|
return this->hit(sprite, movex, movey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [GET] Renvoie le sprite
|
/* [GET] Renvoie le sprite
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
xSprite *xManager::get(string index){
|
xSprite *xManager::get(string index){
|
||||||
if( !this->status() ) return NULL;
|
if( !this->status() ) return NULL;
|
||||||
|
|
||||||
|
|
||||||
// On cherche la texture avec l'index
|
// On cherche la texture avec l'index
|
||||||
for( int i = 0 ; i < _indexes.size() ; i++ )
|
for( int i = 0 ; i < _indexes.size() ; i++ )
|
||||||
|
@ -361,10 +361,10 @@ void xManager::manageFps(const int fps){
|
||||||
if( !this->status() ) return;
|
if( !this->status() ) return;
|
||||||
|
|
||||||
/* (1) Definition de fps */
|
/* (1) Definition de fps */
|
||||||
if( fps != 0 )
|
if( fps != 0 )
|
||||||
_fpstime = 1000/fps;
|
_fpstime = 1000/fps;
|
||||||
|
|
||||||
if( _lasttick == 0 )
|
if( _lasttick == 0 )
|
||||||
_lasttick = SDL_GetTicks()-_fpstime;
|
_lasttick = SDL_GetTicks()-_fpstime;
|
||||||
|
|
||||||
/* (2) Utilisation en fin de boucle */
|
/* (2) Utilisation en fin de boucle */
|
||||||
|
@ -372,7 +372,7 @@ void xManager::manageFps(const int fps){
|
||||||
// 1 > Si trop rapide, on attends
|
// 1 > Si trop rapide, on attends
|
||||||
if( SDL_GetTicks()-_lasttick < _fpstime )
|
if( SDL_GetTicks()-_lasttick < _fpstime )
|
||||||
SDL_Delay( _fpstime - (SDL_GetTicks()-_lasttick) );
|
SDL_Delay( _fpstime - (SDL_GetTicks()-_lasttick) );
|
||||||
|
|
||||||
// On enregistre le temps actuel
|
// On enregistre le temps actuel
|
||||||
_lasttick = SDL_GetTicks();
|
_lasttick = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
|
@ -474,6 +474,6 @@ void xManager::manageEvents(SDL_Event *event){
|
||||||
void xManager::debug(){
|
void xManager::debug(){
|
||||||
for( int i = 0 ; i < _sprites.size() ; i++ ){
|
for( int i = 0 ; i < _sprites.size() ; i++ ){
|
||||||
cerr << "INDEX: " << _indexes[i] << " AT " << i << endl;
|
cerr << "INDEX: " << _indexes[i] << " AT " << i << endl;
|
||||||
cerr << " (" << (*_sprites[i]->dst()).x <<","<<(*_sprites[i]->dst()).y<<") -> (" << (*_sprites[i]->dst()).w << ", " << (*_sprites[i]->dst()).h << ")" << endl;
|
cerr << " (" << (*_sprites[i]->dst()).x <<","<<(*_sprites[i]->dst()).y<<") -> (" << (*_sprites[i]->dst()).w << ", " << (*_sprites[i]->dst()).h << ")" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,7 +40,7 @@
|
||||||
// 0 -> Boucle infinie
|
// 0 -> Boucle infinie
|
||||||
// 1 -> Arret jeu
|
// 1 -> Arret jeu
|
||||||
// 2 -> mort
|
// 2 -> mort
|
||||||
|
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
void debug();
|
void debug();
|
||||||
|
|
|
@ -32,7 +32,7 @@ xSprite::xSprite(xManager *m, const int rgb[]){
|
||||||
|
|
||||||
// On recupere la couleur
|
// On recupere la couleur
|
||||||
Uint32 color = SDL_MapRGBA( surf->format, rgb[0], rgb[1], rgb[2], rgb[3]);
|
Uint32 color = SDL_MapRGBA( surf->format, rgb[0], rgb[1], rgb[2], rgb[3]);
|
||||||
|
|
||||||
|
|
||||||
// On cree la texture a partir de la surface
|
// On cree la texture a partir de la surface
|
||||||
_texture = SDL_CreateTextureFromSurface(_manager->renderer(), surf);
|
_texture = SDL_CreateTextureFromSurface(_manager->renderer(), surf);
|
||||||
|
@ -50,7 +50,7 @@ xSprite::xSprite(xManager *m, const int rgb[]){
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
xSprite::xSprite(xManager *m, const char *url){
|
xSprite::xSprite(xManager *m, const char *url){
|
||||||
_type = "basic";
|
_type = "basic";
|
||||||
|
|
||||||
_manager = m;
|
_manager = m;
|
||||||
_texture = NULL;
|
_texture = NULL;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ xSprite::xSprite(xManager *m, const char *url){
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
xSprite::xSprite(xManager *m, SDL_Texture *t){
|
xSprite::xSprite(xManager *m, SDL_Texture *t){
|
||||||
_type = "basic";
|
_type = "basic";
|
||||||
|
|
||||||
_manager = m;
|
_manager = m;
|
||||||
_texture = t;
|
_texture = t;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void xSprite::setTexture(const int rgb[]){
|
||||||
|
|
||||||
// On recupere la couleur
|
// On recupere la couleur
|
||||||
Uint32 color = SDL_MapRGBA( surf->format, rgb[0], rgb[1], rgb[2], rgb[3]);
|
Uint32 color = SDL_MapRGBA( surf->format, rgb[0], rgb[1], rgb[2], rgb[3]);
|
||||||
|
|
||||||
|
|
||||||
// On cree la texture a partir de la surface
|
// On cree la texture a partir de la surface
|
||||||
_texture = SDL_CreateTextureFromSurface(_manager->renderer(), surf);
|
_texture = SDL_CreateTextureFromSurface(_manager->renderer(), surf);
|
||||||
|
@ -118,7 +118,7 @@ void xSprite::setTexture(const char *url){
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
void xSprite::setTexture(SDL_Texture *t){
|
void xSprite::setTexture(SDL_Texture *t){
|
||||||
_type = "basic";
|
_type = "basic";
|
||||||
|
|
||||||
_texture = NULL;
|
_texture = NULL;
|
||||||
|
|
||||||
_texture = t;
|
_texture = t;
|
||||||
|
@ -140,7 +140,7 @@ vector<int> xSprite::move(int x, int y){
|
||||||
|
|
||||||
|
|
||||||
vector<int> result(2, 0);
|
vector<int> result(2, 0);
|
||||||
|
|
||||||
|
|
||||||
/* (1) Variables utiles */
|
/* (1) Variables utiles */
|
||||||
int incrx = x;
|
int incrx = x;
|
||||||
|
@ -169,7 +169,7 @@ vector<int> xSprite::move(int x, int y){
|
||||||
_mutex_move.unlock();
|
_mutex_move.unlock();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (4) Sinon, on decremente les deplacements 'alternativement' */
|
/* (4) Sinon, on decremente les deplacements 'alternativement' */
|
||||||
|
@ -195,7 +195,7 @@ vector<int> xSprite::move(int x, int y){
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// retour
|
// retour
|
||||||
_mutex_move.unlock();
|
_mutex_move.unlock();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ void xSprite::onCollide(vector<bool> from, xSprite* by){
|
||||||
// if( from[0] == 0 && from[1] == 0 )
|
// if( from[0] == 0 && from[1] == 0 )
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
|
|
||||||
// cerr << _type << " collided with " << by->_type << " from ";
|
// cerr << _type << " collided with " << by->_type << " from ";
|
||||||
|
|
||||||
// if( from[0] != 0 )
|
// if( from[0] != 0 )
|
||||||
|
@ -263,7 +263,7 @@ void xSprite::dimensions(SDL_Rect r){
|
||||||
|
|
||||||
/* [DIMENSIONS] Definition des dimensions de la texture+clip
|
/* [DIMENSIONS] Definition des dimensions de la texture+clip
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
void xSprite::dimensions(SDL_Rect r, SDL_Rect clip){
|
void xSprite::dimensions(SDL_Rect r, SDL_Rect clip){
|
||||||
/* (1) On definit les dimensions */
|
/* (1) On definit les dimensions */
|
||||||
_dst = (SDL_Rect){r.x, r.y, r.w, r.h};
|
_dst = (SDL_Rect){r.x, r.y, r.w, r.h};
|
||||||
_src = (SDL_Rect){clip.x, clip.y, clip.w, clip.h};
|
_src = (SDL_Rect){clip.x, clip.y, clip.w, clip.h};
|
||||||
|
@ -281,13 +281,13 @@ void xSprite::push(string index){
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
void xSprite::pull(string index){
|
void xSprite::pull(string index){
|
||||||
_index = index;
|
_index = index;
|
||||||
|
|
||||||
_manager->pull( index );
|
_manager->pull( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* [PULL] Retire une sprite du rendu
|
/* [PULL] Retire une sprite du rendu
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
void xSprite::pull(){
|
void xSprite::pull(){
|
||||||
_manager->pull( this );
|
_manager->pull( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
class xSprite{
|
class xSprite{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xSprite(xManager *m); // Sprite vide
|
xSprite(xManager *m); // Sprite vide
|
||||||
xSprite(xManager *m, const int rgb[]); // Sprite couleur
|
xSprite(xManager *m, const int rgb[]); // Sprite couleur
|
||||||
xSprite(xManager *m, const char *url); // Sprite image
|
xSprite(xManager *m, const char *url); // Sprite image
|
||||||
xSprite(xManager *m, SDL_Texture *t); // Sprite texture
|
xSprite(xManager *m, SDL_Texture *t); // Sprite texture
|
||||||
|
|
Loading…
Reference in New Issue