IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SDL Discussion :

problème avec une bibliothèque


Sujet :

SDL

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Août 2005
    Messages
    411
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2005
    Messages : 411
    Points : 192
    Points
    192
    Par défaut problème avec une bibliothèque
    bonjour,

    voici une librairie qui est utilisée pour gérer les collisions 2D.
    http://www.libsdl.org/libraries.php?...ion&perpage=50

    celle-ci ne compile pas avec Dev-C++ : voici les erreurs :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    In function `SDL_CollideTransparentPixelTest': 
    syntax error before "int"
    avez-vous une idée svp ?

    merci

  2. #2
    Expert éminent sénior

    Avatar de fearyourself
    Homme Profil pro
    Ingénieur Informaticien Senior
    Inscrit en
    Décembre 2005
    Messages
    5 121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Ingénieur Informaticien Senior
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2005
    Messages : 5 121
    Points : 11 877
    Points
    11 877
    Par défaut
    Montre le code autour de l'erreur, c'est peut-être réparable...

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Août 2005
    Messages
    411
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2005
    Messages : 411
    Points : 192
    Points
    192
    Par défaut
    en fait, peut importe le code qui suit, meme avec un simple main.c, la meme erreur est présente.

    sinon voici le code du .h :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
     
    /*
        SDL_collide:  A 2D collision detection library for use with SDL
        Copyright (C) 2005 Amir Taaki
     
        This library is free software; you can redistribute it and/or
        modify it under the terms of the GNU Library General Public
        License as published by the Free Software Foundation; either
        version 2 of the License, or (at your option) any later version.
     
        This library is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        Library General Public License for more details.
     
        You should have received a copy of the GNU Library General Public
        License along with this library; if not, write to the Free
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
        Amir Taaki
        genjix@gmail.com
     
        Rob Loach
        http://robloach.net
    */
     
    /* A simple library for collision detection using SDL */
     
    #ifndef _SDL_COLLIDE_h
    #define _SDL_COLLIDE_h
     
    /* Set up for C function definitions, even when using C++ */
    #ifdef __cplusplus
    extern "C" {
    #endif
     
    /**
     * SDL surface test if offset (u,v) is a transparent pixel
     */
    int SDL_CollideTransparentPixelTest(SDL_Surface *surface , int u , int v)
     
    /**
     * Pixel-perfect collision between two surfaces.
     *
     * @param SA the first surface to check
     * @param Ax1 the top-left X-coordinate of surface @a SA
     * @param Ay1 the top-left Y-coordinate of surface @a SA
     * @param SB the second surface to check
     * @param Bx1 the top-left X-coordinate of surface @a SB
     * @param By1 the top-left Y-coordinate of surface @a SB
     *
     * @return non-zero on collision, 0 otherwise
     */
    int SDL_CollidePixel(SDL_Surface *as , int ax , int ay ,
                           SDL_Surface *bs , int bx , int by)
     
    /**
     * Bounding-box collision between two surfaces.
     *
     * @param SA the first surface to check
     * @param Ax1 the top-left X-coordinate of surface @a SA
     * @param Ay1 the top-left Y-coordinate of surface @a SA
     * @param SB the second surface to check
     * @param Bx1 the top-left X-coordinate of surface @a SB
     * @param By1 the top-left Y-coordinate of surface @a SB
     *
     * @return non-zero on collision, 0 otherwise
     */
     
    // ERREUR ICI !!! 
    int SDL_CollideBoundingBox(SDL_Surface *sa , int ax , int ay ,
                                 SDL_Surface *sb , int bx , int by)
     
    /**
     * Bounding-box collision between two rectangles.
     *
     * @param A the first rectangle to check
     * @param B the second rectangle to check
     *
     * @return non-zero on collision, 0 otherwise
     */
    int SDL_CollideBoundingBox(SDL_Rect a , SDL_Rect b)
     
    /**
     * tests whether 2 circles intersect
     *
     * circle1 : centre (x1,y1) with radius r1
     * circle2 : centre (x2,y2) with radius r2
     *
     * (allow distance between circles of offset)
     */
    int SDL_CollideBoundingCircle(int x1 , int y1 , int r1 ,
                                    int x2 , int y2 , int r2 , int offset)
     
    /**
     * a circle intersection detection algorithm that will use
     * the position of the centre of the surface as the centre of
     * the circle and approximate the radius using the width and height
     * of the surface (for example a rect of 4x6 would have r = 2.5).
     */
    int SDL_CollideBoundingCircle(SDL_Surface *a , int x1 , int y1 ,
                                    SDL_Surface *b , int x2 , int y2 ,
                                    int offset)
     
     
    /* Ends C function definitions when using C++ */
    #ifdef __cplusplus
    }
    #endif
     
    #endif /* _SDL_COLLIDE_h */

  4. #4
    Expert éminent sénior

    Avatar de fearyourself
    Homme Profil pro
    Ingénieur Informaticien Senior
    Inscrit en
    Décembre 2005
    Messages
    5 121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Ingénieur Informaticien Senior
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2005
    Messages : 5 121
    Points : 11 877
    Points
    11 877
    Par défaut
    C'est bizarre, il manque tous les ';' à la fin des prototypes...

  5. #5
    Rédacteur

    Avatar de loka
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Novembre 2004
    Messages
    2 672
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Novembre 2004
    Messages : 2 672
    Points : 5 509
    Points
    5 509
    Par défaut
    Citation Envoyé par fearyourself
    C'est bizarre, il manque tous les ';' à la fin des prototypes...
    oui c'est exactment ce que je me disais aussi.

  6. #6
    Expert éminent sénior

    Avatar de fearyourself
    Homme Profil pro
    Ingénieur Informaticien Senior
    Inscrit en
    Décembre 2005
    Messages
    5 121
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Ingénieur Informaticien Senior
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2005
    Messages : 5 121
    Points : 11 877
    Points
    11 877
    Par défaut
    Ok, j'ai pris un peu de temps pour regarder cette bibliothèque...

    Je n'ai pas regarder le .c mais seulement le .h :

    - Manque de ';' à la fin des prototypes
    - Polymorphisme dans un langage qui ne le supporte pas

    En gros, prend le code, fabrique tes propres fonctions avec, parce que dans l'état actuel, ce code est inutilisable.

    Jc

  7. #7
    Rédacteur

    Avatar de loka
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Novembre 2004
    Messages
    2 672
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Novembre 2004
    Messages : 2 672
    Points : 5 509
    Points
    5 509
    Par défaut
    Une version corrigé (enfin j'espere que c'est bon ^^) :

    http://lokamhal.free.fr/ressources/sdl_collide.zip

  8. #8
    Membre habitué
    Profil pro
    Inscrit en
    Août 2005
    Messages
    411
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2005
    Messages : 411
    Points : 192
    Points
    192
    Par défaut
    Citation Envoyé par loka
    Une version corrigé (enfin j'espere que c'est bon ^^) :

    http://lokamhal.free.fr/ressources/sdl_collide.zip
    en la testant on constate qu'il y a quelques nouvelles erreurs du meme type :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    SDL_collide.h:82: error: conflicting types for 'SDL_CollideBoundingBox'
    SDL_collide.h:72: error: previous declaration of 'SDL_CollideBoundingBox' was here
    SDL_collide.h:82: error: conflicting types for 'SDL_CollideBoundingBox'
    SDL_collide.h:72: error: previous declaration of 'SDL_CollideBoundingBox' was here
    SDL_collide.h:103: error: conflicting types for 'SDL_CollideBoundingCircle'
    SDL_collide.h:93: error: previous declaration of 'SDL_CollideBoundingCircle' was here
     
    SDL_collide.h:103: error: conflicting types for 'SDL_CollideBoundingCircle'
    SDL_collide.h:93: error: previous declaration of 'SDL_CollideBoundingCircle' was here

  9. #9
    Rédacteur
    Avatar de MrDuChnok
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2002
    Messages
    2 112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2002
    Messages : 2 112
    Points : 4 240
    Points
    4 240
    Par défaut
    C'est normal, ces erreurs proviennent du faite que :

    Citation Envoyé par fearyourself
    - Polymorphisme dans un langage qui ne le supporte pas
    Si vous jugez mon post utile dans la résolution de votre problème, n'hésitez pas à utiliser le système de vote afin d'améliorer la qualité du forum

  10. #10
    Rédacteur

    Avatar de loka
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Novembre 2004
    Messages
    2 672
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Novembre 2004
    Messages : 2 672
    Points : 5 509
    Points
    5 509
    Par défaut
    Tant pis

    En effet en regardant mieux... c'est du n'importe quoi

  11. #11
    Rédacteur
    Avatar de MrDuChnok
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2002
    Messages
    2 112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2002
    Messages : 2 112
    Points : 4 240
    Points
    4 240
    Par défaut
    Sinon tu renommes vite fait les fonctions, ça devrait pas prendre bien longtemps ^^.
    Par exemple tu rajoute un S comme suffixe aux fonctions dont le premier argument est SDL_Surface*. Ainsi elles auront encore un nom compréhensible, et tu n'aura plus ce soucis de polymorphisme.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    int SDL_CollideBoundingBox(SDL_Surface *sa , int ax , int ay ,
                                 SDL_Surface *sb , int bx , int by);
    devient : (changement à faire dans le .h et le .c)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    int SDL_CollideBoundingBoxS(SDL_Surface *sa , int ax , int ay ,
                                 SDL_Surface *sb , int bx , int by);
    et
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    int SDL_CollideBoundingCircle(SDL_Surface *a , int x1 , int y1 ,
                                    SDL_Surface *b , int x2 , int y2 ,
                                    int offset);
    devient :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    int SDL_CollideBoundingCircleS(SDL_Surface *a , int x1 , int y1 ,
                                    SDL_Surface *b , int x2 , int y2 ,
                                    int offset);
    Et ça devrai (pas testé) être utilisable.
    Si vous jugez mon post utile dans la résolution de votre problème, n'hésitez pas à utiliser le système de vote afin d'améliorer la qualité du forum

  12. #12
    Membre habitué
    Profil pro
    Inscrit en
    Août 2005
    Messages
    411
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2005
    Messages : 411
    Points : 192
    Points
    192
    Par défaut
    ca compile mais cette fois, il y a une erreur au niveau de l'execution :

    voici la partie principale du message d'erreur (sous forme de msgbox) qui survient :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    FILE : sdl_collide.c
    line 17
    expression : 	!((u < surface->w) || (v < surface->h))
    assertion failure
    en plus, on peut constater qu'il y a un #include "assert.h" et le fichier assert.h n'est pas présent...

  13. #13
    Membre habitué
    Profil pro
    Inscrit en
    Août 2005
    Messages
    411
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2005
    Messages : 411
    Points : 192
    Points
    192
    Par défaut
    c'est bon en fait il y avait un commentaire au dessus qui disait qu'il fallait juste commenter l'utilisation de la fonction assert si il y avait un problème...

    merci

    a+

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 29/07/2010, 15h16
  2. Réponses: 4
    Dernier message: 07/05/2009, 15h54
  3. Réponses: 22
    Dernier message: 20/05/2008, 10h25
  4. Injection avec une autre méthode que le setter.
    Par Tiaps dans le forum Spring
    Réponses: 2
    Dernier message: 22/05/2007, 23h37
  5. [LG] Inversion avec une boucle tant que
    Par erickson dans le forum Langage
    Réponses: 2
    Dernier message: 09/12/2005, 15h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo